Bug 18072: (QA follow-up) Remove warning from tests
authorTomas Cohen Arazi <tomascohen@theke.io>
Mon, 11 Sep 2017 18:22:49 +0000 (15:22 -0300)
committerNick Clemens <nick@bywatersolutions.com>
Wed, 18 Jul 2018 17:42:42 +0000 (17:42 +0000)
This patch removes a warning from Items.t due to bad parameters. It also
makes the tests use Test::Exception.

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
t/db_dependent/Koha/Biblios.t
t/db_dependent/Koha/Items.t

index 0707e0c..61f7433 100644 (file)
@@ -19,7 +19,8 @@
 
 use Modern::Perl;
 
-use Test::More tests => 4;
+use Test::More tests => 5;
+use Test::Exception;
 
 use C4::Biblio;
 use C4::Items;
@@ -184,15 +185,15 @@ subtest 'can_be_transferred' => sub {
     is($biblio->can_be_transferred({ to => $library2 }), 0, 'Given all of items'
         .' of the biblio are from same, transfer limited library, then transfer'
         .' is not possible.');
-    eval { $biblio->can_be_transferred({ to => undef }); };
-    is(ref($@), 'Koha::Exceptions::Library::NotFound', 'Exception thrown when no'
-        .' library given.');
-    eval { $biblio->can_be_transferred({ to => 'heaven' }); };
-    is(ref($@), 'Koha::Exceptions::Library::NotFound', 'Exception thrown when'
-        .' invalid library is given.');
-    eval { $biblio->can_be_transferred({ to => $library2, from => 'hell' }); };
-    is(ref($@), 'Koha::Exceptions::Library::NotFound', 'Exception thrown when'
-        .' invalid library is given.');
+    throws_ok { $biblio->can_be_transferred({ to => undef }); }
+              'Koha::Exceptions::Library::NotFound',
+              'Exception thrown when no library given.';
+    throws_ok { $biblio->can_be_transferred({ to => 'heaven' }); }
+              'Koha::Exceptions::Library::NotFound',
+              'Exception thrown when invalid library is given.';
+    throws_ok { $biblio->can_be_transferred({ to => $library2, from => 'hell' }); }
+              'Koha::Exceptions::Library::NotFound',
+              'Exception thrown when invalid library is given.';
 };
 
 $schema->storage->txn_rollback;
index 02272d2..3d997b2 100644 (file)
@@ -20,6 +20,7 @@
 use Modern::Perl;
 
 use Test::More tests => 9;
+use Test::Exception;
 
 use C4::Circulation;
 use Koha::Item;
@@ -156,14 +157,17 @@ subtest 'can_be_transferred' => sub {
     })->count, 1, 'Given we have added a transfer limit,');
     is($item->can_be_transferred({ to => $library2 }), 0,
        'Item can no longer be transferred between libraries.');
-    is($item->can_be_transferred({ to => $library2, $library1 }), 0,
+    is($item->can_be_transferred({ to => $library2, from => $library1 }), 0,
        'We get the same result also if we pass the from-library parameter.');
-    eval { $item->can_be_transferred({ to => undef }); };
-    is(ref($@), 'Koha::Exceptions::Library::NotFound', 'Exception thrown when no library given.');
-    eval { $item->can_be_transferred({ to => 'heaven' }); };
-    is(ref($@), 'Koha::Exceptions::Library::NotFound', 'Exception thrown when invalid library is given.');
-    eval { $item->can_be_transferred({ to => $library2, from => 'hell' }); };
-    is(ref($@), 'Koha::Exceptions::Library::NotFound', 'Exception thrown when invalid library is given.');
+    throws_ok { $item->can_be_transferred({ to => undef }); }
+              'Koha::Exceptions::Library::NotFound',
+              'Exception thrown when no library given.';
+    throws_ok { $item->can_be_transferred({ to => 'heaven' }); }
+              'Koha::Exceptions::Library::NotFound',
+              'Exception thrown when invalid library is given.';
+    throws_ok { $item->can_be_transferred({ to => $library2, from => 'hell' }); }
+              'Koha::Exceptions::Library::NotFound',
+              'Exception thrown when invalid library is given.';
 };
 
 $retrieved_item_1->delete;