@@ -, +, @@ --- t/db_dependent/Koha/Biblios.t | 19 ++++++++++--------- t/db_dependent/Koha/Items.t | 18 +++++++++++------- 2 files changed, 21 insertions(+), 16 deletions(-) --- a/t/db_dependent/Koha/Biblios.t +++ a/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; --- a/t/db_dependent/Koha/Items.t +++ a/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; --