From 43edddf8c80557c8947147a39becc3de3a5f1722 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Fri, 17 Dec 2021 12:52:17 -0300 Subject: [PATCH] Bug 29553: Regression tests Signed-off-by: Tomas Cohen Arazi --- t/db_dependent/Reserves.t | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Reserves.t b/t/db_dependent/Reserves.t index 9b4122dbd4..a0e9df0016 100755 --- a/t/db_dependent/Reserves.t +++ b/t/db_dependent/Reserves.t @@ -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; +}; -- 2.32.0