From 1af3edd09e543cf4cd3b97d0915d14f609a790e0 Mon Sep 17 00:00:00 2001 From: Katrin Fischer Date: Mon, 25 May 2015 17:01:46 +0200 Subject: [PATCH] Bug 13972: Follow-up - Add unit tests for changed parts of SendAlerts To test: - prove t/db_dependent/Letters.t --- t/db_dependent/Letters.t | 43 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Letters.t b/t/db_dependent/Letters.t index f53e75b..7f209ed 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 => 58; +use Test::More tests => 62; use Test::MockModule; use Test::Warn; @@ -332,6 +332,7 @@ $bookseller->contacts->[0]->email('testemail@mydomain.com'); C4::Bookseller::ModBookseller($bookseller); $bookseller = Koha::Acquisition::Bookseller->fetch({ id => $booksellerid }); +{ warning_is { $err = SendAlerts( 'claimacquisition', [ $ordernumber ], 'TESTACQCLAIM' ) } "Fake sendmail", @@ -340,5 +341,45 @@ warning_is { is($err, 1, "Successfully sent claim"); is($mail{'To'}, 'testemail@mydomain.com', "mailto correct in sent claim"); is($mail{'Message'}, 'my vendor|John Smith|Ordernumber ' . $ordernumber . ' (Silence in the library) (1 ordered)', 'Claim notice text constructed successfully'); +} + +{ +use C4::Serials; + +my $notes = 'notes'; +my $internalnotes = 'intnotes'; +my $subscriptionid = NewSubscription( + undef, "", undef, undef, undef, $biblionumber, + '2013-01-01', 1, undef, undef, undef, + undef, undef, undef, undef, undef, undef, + 1, $notes,undef, '2013-01-01', undef, 1, + undef, undef, 0, $internalnotes, 0, + undef, undef, 0, undef, '2013-12-31', 0 +); +$dbh->do(q{INSERT INTO letter (module, code, name, title, content) VALUES ('serial','RLIST','Serial issue notification','Serial issue notification','<>,<>,<>');}); +my ($serials_count, @serials) = GetSerials($subscriptionid); +my $serial = $serials[0]; + +my $borrowernumber = AddMember( + firstname => 'John', + surname => 'Smith', + categorycode => 'PT', + branchcode => 'CPL', + dateofbirth => $date, + email => 'john.smith@test.de', +); +$dbh->do(q|INSERT INTO alert (borrowernumber, type, externalid) VALUES (?,'issue',?)|, undef, $borrowernumber, $subscriptionid); + + +my $err2; +warning_is { +$err2 = SendAlerts( 'issue', $serial->{serialid}, 'RLIST' ) } + "Fake sendmail", + "SendAlerts is using the mocked sendmail routine"; +is($err2, "", "Successfully sent serial notification"); +is($mail{'To'}, 'john.smith@test.de', "mailto correct in sent serial notification"); +is($mail{'Message'}, 'Silence in the library,'.$subscriptionid.',No. 0', 'Serial notification text constructed successfully'); +} + $dbh->rollback; -- 1.9.1