From 072d6254478b9fda0543d2cf4a5a68a9f7d83dfc Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 20 Aug 2014 17:58:32 +0200 Subject: [PATCH] Bug 11244: Add unit tests for GetPreparedLetter Signed-off-by: Tomas Cohen Arazi --- t/db_dependent/Letters.t | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/t/db_dependent/Letters.t b/t/db_dependent/Letters.t index bf0c1a1cd3..89e511a7a3 100644 --- a/t/db_dependent/Letters.t +++ b/t/db_dependent/Letters.t @@ -21,10 +21,13 @@ use Modern::Perl; use Test::More tests => 45; +use MARC::Record; +use C4::Biblio qw( AddBiblio ); use C4::Context; use C4::Letters; use C4::Members; use C4::Branch; +use Koha::DateUtils qw( dt_from_string output_pref ); use t::lib::Mocks; my $dbh = C4::Context->dbh; @@ -37,13 +40,17 @@ $dbh->do(q|DELETE FROM letter|); $dbh->do(q|DELETE FROM message_queue|); $dbh->do(q|DELETE FROM message_transport_types|); +my $date = dt_from_string; my $borrowernumber = AddMember( firstname => 'Jane', surname => 'Smith', categorycode => 'PT', branchcode => 'CPL', + dateofbirth => $date, ); +my $marc_record = MARC::Record->new; +my( $biblionumber, $biblioitemnumber ) = AddBiblio( $marc_record, '' ); # GetMessageTransportTypes my $mtts = C4::Letters::GetMessageTransportTypes(); @@ -126,7 +133,10 @@ The following item(s) is/are currently <>: <>. <>, Barcode: <> -Thank-you for your prompt attention to this matter.|; +Thank-you for your prompt attention to this matter. +Don't forget your date of birth: <>. +Look at this wonderful biblio timestamp: <>. +|; $dbh->do( q|INSERT INTO letter(branchcode,module,code,name,is_html,title,content,message_transport_type) VALUES ('CPL','my module','my code','my name',1,?,?,'email')|, undef, $title, $content ); $letters = C4::Letters::GetLetters(); @@ -189,12 +199,13 @@ is( @$alerts, 0, 'delalert removes an alert' ); # GetPreparedLetter t::lib::Mocks::mock_preference('OPACBaseURL', 'http://thisisatest.com'); -$content = 'This is a SMS for an <>'; -$dbh->do( q|INSERT INTO letter(branchcode,module,code,name,is_html,title,content,message_transport_type) VALUES ('CPL','my module','my code','my name',1,'my title',?,'sms')|, undef, $content ); +my $sms_content = 'This is a SMS for an <>'; +$dbh->do( q|INSERT INTO letter(branchcode,module,code,name,is_html,title,content,message_transport_type) VALUES ('CPL','my module','my code','my name',1,'my title',?,'sms')|, undef, $sms_content ); my $tables = { borrowers => $borrowernumber, branches => 'CPL', + biblio => $biblionumber, }; my $substitute = { status => 'overdue', @@ -231,7 +242,9 @@ The following item(s) is/are currently $substitute->{status}: 1. $repeat->[0]->{itemcallnumber}, Barcode: $repeat->[0]->{barcode} 2. $repeat->[1]->{itemcallnumber}, Barcode: $repeat->[1]->{barcode} -Thank-you for your prompt attention to this matter.|; +Thank-you for your prompt attention to this matter. +Don't forget your date of birth: | . output_pref({ dt => $date, dateonly => 1 }) . q|. +Look at this wonderful biblio timestamp: | . output_pref({ dt => $date }) . ".\n"; is( $prepared_letter->{title}, $my_title_letter, 'GetPreparedLetter returns the title correctly' ); is( $prepared_letter->{content}, $my_content_letter, 'GetPreparedLetter returns the content correctly' ); -- 2.39.5