From 3c3c7ef345423e7a38a9ac2eb9b15b5b4603f6a5 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 5 Mar 2021 14:49:22 +0100 Subject: [PATCH] Bug 27058: Add test for IsAvailableForItemLevelRequest and notforloan MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Joonas Kylmälä --- .../Holds/DisallowHoldIfItemsAvailable.t | 35 +++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Holds/DisallowHoldIfItemsAvailable.t b/t/db_dependent/Holds/DisallowHoldIfItemsAvailable.t index 13600eb871..8fd6b2cb1b 100755 --- a/t/db_dependent/Holds/DisallowHoldIfItemsAvailable.t +++ b/t/db_dependent/Holds/DisallowHoldIfItemsAvailable.t @@ -8,7 +8,7 @@ use C4::Items; use Koha::Items; use Koha::CirculationRules; -use Test::More tests => 12; +use Test::More tests => 13; use t::lib::TestBuilder; use t::lib::Mocks; @@ -424,6 +424,39 @@ subtest 'Check item checkout availability with ordered item' => sub { is( $is, 0, "Ordered item cannot be checked out" ); }; +subtest 'Check item availability for hold with ordered item' => sub { + plan tests => 1; + + my $biblio2 = $builder->build_sample_biblio( { itemtype => $itemtype } ); + my $item1 = $builder->build_sample_item( + { biblionumber => $biblio2->biblionumber, + itype => $itemtype2, + homebranch => $library_A, + holdingbranch => $library_A, + notforloan => -1 + } + ); + + $dbh->do("DELETE FROM circulation_rules"); + Koha::CirculationRules->set_rules( + { categorycode => undef, + itemtype => $itemtype2, + branchcode => undef, + rules => { + issuelength => 7, + lengthunit => 8, + reservesallowed => 99, + holds_per_record => 99, + onshelfholds => 2, + } + } + ); + + $is = IsAvailableForItemLevelRequest( $item1, $patron1 ); + is( $is, 1, "Ordered items are available for hold" ); +}; + + # Cleanup $schema->storage->txn_rollback; -- 2.11.0