View | Details | Raw Unified | Return to bug 28230
Collapse All | Expand All

(-)a/t/db_dependent/Message.t (-1 / +67 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 3 of the License, or
8
# (at your option) any later version.
9
#
10
# Koha is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with Koha; if not, see <http://www.gnu.org/licenses>.
17
18
use Modern::Perl;
19
use Test::More tests => 3;
20
21
use utf8;
22
23
use t::lib::TestBuilder;
24
25
use C4::Letters;
26
use Koha::Database;
27
28
my $schema = Koha::Database->schema;
29
$schema->storage->txn_begin();
30
31
my $builder = t::lib::TestBuilder->new();
32
my $dbh = C4::Context->dbh;
33
$dbh->do(q{INSERT INTO letter (module, code, name, title, content) VALUES ('test', 'TEST_MESSAGE','Test', '[% biblio.title %]', "
34
----
35
<<biblio.title>>
36
----
37
")});
38
my $biblio_1 = $builder->build_sample_biblio({ title => "heÄllo" });
39
my $biblio_2 = $builder->build_sample_biblio({ title => "hell❤️" });
40
my $patron = $builder->build_object({ class => 'Koha::Patrons', value => { email => 'test@example.org'} });
41
my $letter = C4::Letters::GetPreparedLetter(
42
    (
43
        module      => 'test',
44
        letter_code => 'TEST_MESSAGE',
45
        tables      => {
46
            biblio => $biblio_1->biblionumber,
47
        },
48
    )
49
);
50
51
C4::Message->enqueue($letter, $patron->unblessed, 'email');
52
my $message = C4::Message->find_last_message($patron->unblessed, 'TEST_MESSAGE', 'email');
53
like( $message->{metadata}, qr{heÄllo} );
54
55
$letter = C4::Letters::GetPreparedLetter(
56
    (
57
        module      => 'test',
58
        letter_code => 'TEST_MESSAGE',
59
        tables      => {
60
            biblio => $biblio_2->biblionumber,
61
        },
62
    )
63
);
64
$message->append($letter);
65
like( $message->{metadata}, qr{heÄllo} );
66
like( $message->{metadata}, qr{hell❤️} );
67

Return to bug 28230