3 # This file is part of Koha.
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.
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.
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>.
19 use Test::More tests => 3;
23 use t::lib::TestBuilder;
25 use C4::Letters qw( GetPreparedLetter );
28 my $schema = Koha::Database->schema;
29 $schema->storage->txn_begin();
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 %]', "
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(
44 letter_code => 'TEST_MESSAGE',
46 biblio => $biblio_1->biblionumber,
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} );
55 $letter = C4::Letters::GetPreparedLetter(
58 letter_code => 'TEST_MESSAGE',
60 biblio => $biblio_2->biblionumber,
64 $message->append($letter);
65 like( $message->{metadata}, qr{heÄllo} );
66 like( $message->{metadata}, qr{hell❤️} );