|
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 |
use Test::MockModule; |
| 21 |
use Test::Warn; |
| 22 |
|
| 23 |
use Encode; |
| 24 |
|
| 25 |
use t::lib::TestBuilder; |
| 26 |
use t::lib::Mocks; |
| 27 |
|
| 28 |
use C4::Circulation; |
| 29 |
use C4::Letters; |
| 30 |
use utf8; |
| 31 |
use Koha::Database; |
| 32 |
|
| 33 |
my $schema = Koha::Database->schema; |
| 34 |
$schema->storage->txn_begin(); |
| 35 |
|
| 36 |
my $builder = t::lib::TestBuilder->new(); |
| 37 |
my $dbh = C4::Context->dbh; |
| 38 |
$dbh->do(q{INSERT INTO letter (module, code, name, title, content) VALUES ('test', 'TEST_MESSAGE','Test', '[% biblio.title %]', " |
| 39 |
---- |
| 40 |
<<biblio.title>> |
| 41 |
---- |
| 42 |
")}); |
| 43 |
my $biblio_1 = $builder->build_sample_biblio({ title => "heÄllo" }); |
| 44 |
my $biblio_2 = $builder->build_sample_biblio({ title => "hell❤️" }); |
| 45 |
my $patron = $builder->build_object({ class => 'Koha::Patrons', value => { email => 'test@example.org'} }); |
| 46 |
my $letter = C4::Letters::GetPreparedLetter( |
| 47 |
( |
| 48 |
module => 'test', |
| 49 |
letter_code => 'TEST_MESSAGE', |
| 50 |
tables => { |
| 51 |
biblio => $biblio_1->biblionumber, |
| 52 |
}, |
| 53 |
) |
| 54 |
); |
| 55 |
|
| 56 |
C4::Message->enqueue($letter, $patron->unblessed, 'email'); |
| 57 |
my $message = C4::Message->find_last_message($patron->unblessed, 'TEST_MESSAGE', 'email'); |
| 58 |
like( $message->{metadata}, qr{heÄllo} ); |
| 59 |
|
| 60 |
$letter = C4::Letters::GetPreparedLetter( |
| 61 |
( |
| 62 |
module => 'test', |
| 63 |
letter_code => 'TEST_MESSAGE', |
| 64 |
tables => { |
| 65 |
biblio => $biblio_2->biblionumber, |
| 66 |
}, |
| 67 |
) |
| 68 |
); |
| 69 |
$message->append($letter); |
| 70 |
#use Data::Printer colored => 1; warn p $content; |
| 71 |
like( $message->{metadata}, qr{heÄllo} ); |
| 72 |
like( $message->{metadata}, qr{hell❤️} ); |
| 73 |
|