From f54c2416b06421118d58df2fa801f40928fdb501 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Mon, 11 Sep 2017 15:22:49 -0300 Subject: [PATCH] Bug 18072: (QA followup) Remove warning from tests 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 --- t/db_dependent/Koha/Biblios.t | 19 ++++++++++--------- t/db_dependent/Koha/Items.t | 18 +++++++++++------- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/t/db_dependent/Koha/Biblios.t b/t/db_dependent/Koha/Biblios.t index 2c7bdbe..b58b4a5 100644 --- a/t/db_dependent/Koha/Biblios.t +++ b/t/db_dependent/Koha/Biblios.t @@ -20,6 +20,7 @@ use Modern::Perl; use Test::More tests => 3; +use Test::Exception; use C4::Biblio; use C4::Items; @@ -133,15 +134,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; diff --git a/t/db_dependent/Koha/Items.t b/t/db_dependent/Koha/Items.t index e7d086b..fefcf1e 100644 --- a/t/db_dependent/Koha/Items.t +++ b/t/db_dependent/Koha/Items.t @@ -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; -- 2.7.4