Bug 29553: Regression tests

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
(cherry picked from commit 6f2f2af680)

Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com>
This commit is contained in:
Tomas Cohen Arazi 2021-12-17 12:52:17 -03:00 committed by Andrew Fuerste-Henry
parent ddc7f0bd1f
commit cd403a6918
1 changed files with 38 additions and 1 deletions

View File

@ -17,7 +17,7 @@
use Modern::Perl;
use Test::More tests => 68;
use Test::More tests => 69;
use Test::MockModule;
use Test::Warn;
@ -1362,3 +1362,40 @@ sub place_item_hold {
# we reached the finish
$schema->storage->txn_rollback();
subtest 'IsAvailableForItemLevelRequest() tests' => sub {
plan tests => 2;
$schema->storage->txn_begin;
my $patron = $builder->build_object( { class => 'Koha::Patrons' } );
my $item_type = undef;
my $item_mock = Test::MockModule->new('Koha::Item');
$item_mock->mock( 'effective_itemtype', sub { return $item_type; } );
my $item = $builder->build_sample_item;
ok(
!C4::Reserves::IsAvailableForItemLevelRequest( $item, $patron ),
"Item not available for item-level hold because no effective item type"
);
# Weird use case to highlight issue
$item_type = '0';
Koha::ItemTypes->search( { itemtype => $item_type } )->delete;
my $itemtype = $builder->build_object(
{
class => 'Koha::ItemTypes',
value => { itemtype => $item_type, notloan => 0 }
}
);
ok(
C4::Reserves::IsAvailableForItemLevelRequest( $item, $patron ),
"Item not available for item-level hold because no effective item type"
);
$schema->storage->txn_rollback;
};