From 0f72535232d9d5165c0e3dd9e158652cf3504be0 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 Signed-off-by: Kyle M Hall --- 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 0b7d125e52..d283c01c82 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 }, ] ); @@ -422,6 +423,17 @@ $bookseller = Koha::Acquisition::Bookseller->fetch({ id => $booksellerid }); # Ensure that the preference 'LetterLog' is set to logging 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' ) } -- 2.39.5