From be90583bd9530c8269c635509cbd540ca570d7a0 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 7 Jun 2016 12:00:59 +0100 Subject: [PATCH] Bug 16624: Add regression tests --- t/db_dependent/Letters.t | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/t/db_dependent/Letters.t b/t/db_dependent/Letters.t index c28f90f..a78dcde 100644 --- a/t/db_dependent/Letters.t +++ b/t/db_dependent/Letters.t @@ -18,7 +18,7 @@ # along with Koha; if not, see . use Modern::Perl; -use Test::More tests => 72; +use Test::More tests => 73; use Test::MockModule; use Test::Warn; @@ -306,7 +306,7 @@ $prepared_letter = GetPreparedLetter(( $my_content_letter = qq|This is a SMS for an $substitute->{status}|; is( $prepared_letter->{content}, $my_content_letter, 'GetPreparedLetter returns the content correctly' ); -$dbh->do(q{INSERT INTO letter (module, code, name, title, content) VALUES ('test_date','TEST_DATE','Test dates','Test dates','This one only contains the date: <>.');}); +$dbh->do(q{INSERT INTO letter (module, code, name, title, content) VALUES ('test_date','TEST_DATE','Test dates','A title with a timestamp: <>','This one only contains the date: <>.');}); $prepared_letter = GetPreparedLetter(( module => 'test_date', branchcode => '', @@ -339,6 +339,20 @@ $prepared_letter = GetPreparedLetter(( )); is( $prepared_letter->{content}, q|And also this one:| . output_pref({ dt => $date, dateonly => 1 }) . q|.|, 'dateonly test 3' ); +t::lib::Mocks::mock_preference( 'TimeFormat', '12hr' ); +my $yesterday_night = $date->clone->add( days => -1 )->set_hour(22); +$dbh->do(q|UPDATE biblio SET timestamp = ? WHERE biblionumber = ?|, undef, $yesterday_night, $biblionumber ); +$dbh->do(q{UPDATE letter SET content = 'And also this one:<>.' WHERE code = 'test_date';}); +$prepared_letter = GetPreparedLetter(( + module => 'test_date', + branchcode => '', + letter_code => 'test_date', + tables => $tables, + substitute => $substitute, + repeat => $repeat, +)); +is( $prepared_letter->{content}, q|And also this one:| . output_pref({ dt => $yesterday_night }) . q|.|, 'dateonly test 3' ); + $dbh->do(q{INSERT INTO letter (module, code, name, title, content) VALUES ('claimacquisition','TESTACQCLAIM','Acquisition Claim','Item Not Received','<>|<>|Ordernumber <> (<>) (<> ordered)');}); # Test that _parseletter doesn't modify its parameters bug 15429 -- 2.8.1