Bug 5260: Unit tests for new functionality in SendAlert
authorKatrin Fischer <katrin.fischer.83@web.de>
Fri, 14 Oct 2016 10:02:33 +0000 (12:02 +0200)
committerKyle M Hall <kyle@bywatersolutions.com>
Fri, 28 Oct 2016 11:52:26 +0000 (11:52 +0000)
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
t/db_dependent/Letters.t

index 0b7d125..d283c01 100644 (file)
@@ -18,7 +18,7 @@
 # along with Koha; if not, see <http://www.gnu.org/licenses>.
 
 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','<<aqbooksellers.name>>|<<aqcontacts.name>>|<order>Ordernumber <<aqorders.ordernumber>> (<<biblio.title>>) (<<aqorders.quantity>> ordered)</order>');});
+$dbh->do(q{INSERT INTO letter (module, code, name, title, content) VALUES ('orderacquisition','TESTACQORDER','Acquisition Order','Order','<<aqbooksellers.name>>|<<aqcontacts.name>>|<order>Ordernumber <<aqorders.ordernumber>> (<<biblio.title>>) (<<aqorders.quantity>> ordered)</order>');});
 
 # 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";