Bug 18072: (QA follow-up) 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 <tomascohen@theke.io>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
This commit is contained in:
Tomás Cohen Arazi 2017-09-11 15:22:49 -03:00 committed by Nick Clemens
parent bd87407798
commit 6db48e9d21
2 changed files with 22 additions and 17 deletions

View 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;

View 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;