From 62444c1b9f095b98f6bcddd37ea505a43f578730 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 27 Apr 2021 10:06:39 +0200 Subject: [PATCH] Bug 28230: Regression tests Signed-off-by: Tomas Cohen Arazi Signed-off-by: Martin Renvoize Bug 28230: Add execute bit to test Signed-off-by: Martin Renvoize Signed-off-by: Jonathan Druart --- t/db_dependent/Message.t | 66 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100755 t/db_dependent/Message.t diff --git a/t/db_dependent/Message.t b/t/db_dependent/Message.t new file mode 100755 index 0000000000..cdb30322c6 --- /dev/null +++ b/t/db_dependent/Message.t @@ -0,0 +1,66 @@ +#!/usr/bin/perl + +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . + +use Modern::Perl; +use Test::More tests => 3; + +use utf8; + +use t::lib::TestBuilder; + +use C4::Letters; +use Koha::Database; + +my $schema = Koha::Database->schema; +$schema->storage->txn_begin(); + +my $builder = t::lib::TestBuilder->new(); +my $dbh = C4::Context->dbh; +$dbh->do(q{INSERT INTO letter (module, code, name, title, content) VALUES ('test', 'TEST_MESSAGE','Test', '[% biblio.title %]', " +---- +<> +---- +")}); +my $biblio_1 = $builder->build_sample_biblio({ title => "heÄllo" }); +my $biblio_2 = $builder->build_sample_biblio({ title => "hell❤️" }); +my $patron = $builder->build_object({ class => 'Koha::Patrons', value => { email => 'test@example.org'} }); +my $letter = C4::Letters::GetPreparedLetter( + ( + module => 'test', + letter_code => 'TEST_MESSAGE', + tables => { + biblio => $biblio_1->biblionumber, + }, + ) +); + +C4::Message->enqueue($letter, $patron->unblessed, 'email'); +my $message = C4::Message->find_last_message($patron->unblessed, 'TEST_MESSAGE', 'email'); +like( $message->{metadata}, qr{heÄllo} ); + +$letter = C4::Letters::GetPreparedLetter( + ( + module => 'test', + letter_code => 'TEST_MESSAGE', + tables => { + biblio => $biblio_2->biblionumber, + }, + ) +); +$message->append($letter); +like( $message->{metadata}, qr{heÄllo} ); +like( $message->{metadata}, qr{hell❤️} ); -- 2.39.5