From 3514b1e78bdd8b8b2eac553d5176599147b68696 Mon Sep 17 00:00:00 2001 From: Katrin Fischer Date: Fri, 14 Oct 2016 12:02:33 +0200 Subject: [PATCH] Bug 5260: Unit tests for new functionality in SendAlert Signed-off-by: Martin Renvoize Signed-off-by: Jonathan Druart --- t/db_dependent/Letters.t | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/t/db_dependent/Letters.t b/t/db_dependent/Letters.t index 0b7d125..d283c01 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 => 74; +use Test::More tests => 78; use Test::MockModule; use Test::Warn; @@ -356,6 +356,7 @@ $prepared_letter = GetPreparedLetter(( 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)');}); +$dbh->do(q{INSERT INTO letter (module, code, name, title, content) VALUES ('orderacquisition','TESTACQORDER','Acquisition Order','Order','<>|<>|Ordernumber <> (<>) (<> ordered)');}); # Test that _parseletter doesn't modify its parameters bug 15429 { @@ -373,7 +374,7 @@ my $booksellerid = C4::Bookseller::AddBookseller( deliverytime => 5, }, [ - { name => 'John Smith', phone => '0123456x1', claimacquisition => 1 }, + { name => 'John Smith', acqprimary => 1, phone => '0123456x1', claimacquisition => 1, orderacquisition => 1 }, { name => 'Leo Tolstoy', phone => '0123456x2', claimissues => 1 }, ] ); @@ -424,6 +425,17 @@ t::lib::Mocks::mock_preference( 'LetterLog', 'on' ); { warning_is { + $err = SendAlerts( 'orderacquisition', $basketno , 'TESTACQORDER' ) } + "Fake sendmail", + "SendAlerts is using the mocked sendmail routine (orderacquisition)"; +is($err, 1, "Successfully sent order."); +is($mail{'To'}, 'testemail@mydomain.com', "mailto correct in sent order"); +is($mail{'Message'}, 'my vendor|John Smith|Ordernumber ' . $ordernumber . ' (Silence in the library) (1 ordered)', 'Order notice text constructed successfully'); +} + + +{ +warning_is { $err = SendAlerts( 'claimacquisition', [ $ordernumber ], 'TESTACQCLAIM' ) } "Fake sendmail", "SendAlerts is using the mocked sendmail routine"; -- 2.1.4