From a2363cb0391624de5b79fe5cb63c362aa0b98999 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Mon, 15 Mar 2021 15:39:30 -0300 Subject: [PATCH] Bug 27069: Adjust tests Signed-off-by: Martin Renvoize Signed-off-by: Kyle M Hall --- t/db_dependent/Circulation/Branch.t | 18 +-- t/db_dependent/Holds.t | 32 ++--- .../Holds/DisallowHoldIfItemsAvailable.t | 4 +- t/db_dependent/Holds/HoldFulfillmentPolicy.t | 6 +- t/db_dependent/HoldsQueue.t | 40 +++--- t/db_dependent/Koha/Biblio.t | 16 +-- t/db_dependent/Koha/Holds.t | 2 +- t/db_dependent/Koha/Item.t | 133 +++++++++--------- t/db_dependent/Reserves.t | 4 +- t/db_dependent/api/v1/holds.t | 2 +- 10 files changed, 131 insertions(+), 126 deletions(-) diff --git a/t/db_dependent/Circulation/Branch.t b/t/db_dependent/Circulation/Branch.t index c8fe89dc97..1a66ad1efb 100755 --- a/t/db_dependent/Circulation/Branch.t +++ b/t/db_dependent/Circulation/Branch.t @@ -174,7 +174,7 @@ Koha::CirculationRules->set_rules( branchcode => $samplebranch2->{branchcode}, itemtype => undef, rules => { - holdallowed => 1, + holdallowed => 'from_home_library', returnbranch => 'holdingbranch', } } @@ -195,7 +195,7 @@ Koha::CirculationRules->set_rules( branchcode => undef, itemtype => undef, rules => { - holdallowed => 3, + holdallowed => 'from_local_hold_group', returnbranch => 'homebranch', } } @@ -206,7 +206,7 @@ Koha::CirculationRules->set_rules( branchcode => $samplebranch1->{branchcode}, itemtype => $sampleitemtype1->{itemtype}, rules => { - holdallowed => 5, + holdallowed => 'invalid_value', returnbranch => 'homebranch', } } @@ -216,7 +216,7 @@ Koha::CirculationRules->set_rules( branchcode => $samplebranch2->{branchcode}, itemtype => $sampleitemtype1->{itemtype}, rules => { - holdallowed => 5, + holdallowed => 'invalid_value', returnbranch => 'holdingbranch', } } @@ -226,7 +226,7 @@ Koha::CirculationRules->set_rules( branchcode => $samplebranch2->{branchcode}, itemtype => $sampleitemtype2->{itemtype}, rules => { - holdallowed => 5, + holdallowed => 'invalid_value', returnbranch => 'noreturn', } } @@ -264,22 +264,22 @@ is_deeply( $samplebranch1->{branchcode}, $sampleitemtype1->{itemtype}, ), - { returnbranch => 'homebranch', holdallowed => 5, @lazy_any }, + { returnbranch => 'homebranch', holdallowed => 'invalid_value', @lazy_any }, "GetBranchitem returns holdallowed and return branch" ); is_deeply( GetBranchItemRule(), - { returnbranch => 'homebranch', holdallowed => 3, @lazy_any }, + { returnbranch => 'homebranch', holdallowed => 'from_local_hold_group', @lazy_any }, "Without parameters GetBranchItemRule returns the values in default_circ_rules" ); is_deeply( GetBranchItemRule( $samplebranch2->{branchcode} ), - { returnbranch => 'holdingbranch', holdallowed => 1, @lazy_any }, + { returnbranch => 'holdingbranch', holdallowed => 'from_home_library', @lazy_any }, "With only a branchcode GetBranchItemRule returns values in default_branch_circ_rules" ); is_deeply( GetBranchItemRule( -1, -1 ), - { returnbranch => 'homebranch', holdallowed => 3, @lazy_any }, + { returnbranch => 'homebranch', holdallowed => 'from_local_hold_group', @lazy_any }, "With only one parametern GetBranchItemRule returns default values" ); diff --git a/t/db_dependent/Holds.t b/t/db_dependent/Holds.t index 3e736f6774..757f6a742d 100755 --- a/t/db_dependent/Holds.t +++ b/t/db_dependent/Holds.t @@ -420,7 +420,7 @@ Koha::CirculationRules->set_rules( branchcode => $branch_1, itemtype => 'CANNOT', rules => { - holdallowed => 0, + holdallowed => 'not_allowed', returnbranch => 'homebranch', } } @@ -430,7 +430,7 @@ Koha::CirculationRules->set_rules( branchcode => $branch_1, itemtype => 'CAN', rules => { - holdallowed => 1, + holdallowed => 'from_home_library', returnbranch => 'homebranch', } } @@ -877,7 +877,7 @@ subtest 'CanItemBeReserved / branch_not_in_hold_group' => sub { branchcode => undef, itemtype => undef, rules => { - holdallowed => 3, + holdallowed => 'from_local_hold_group', hold_fulfillment_policy => 'any', returnbranch => 'any' } @@ -904,7 +904,7 @@ subtest 'CanItemBeReserved / branch_not_in_hold_group' => sub { branchcode => $library2->branchcode, itemtype => undef, rules => { - holdallowed => 2, + holdallowed => 'from_any_library', hold_fulfillment_policy => 'any', returnbranch => 'any' } @@ -924,7 +924,7 @@ subtest 'CanItemBeReserved / branch_not_in_hold_group' => sub { branchcode => $library2->branchcode, itemtype => undef, rules => { - holdallowed => 3, + holdallowed => 'from_local_hold_group', hold_fulfillment_policy => 'any', returnbranch => 'any' } @@ -944,7 +944,7 @@ subtest 'CanItemBeReserved / branch_not_in_hold_group' => sub { branchcode => $library2->branchcode, itemtype => $itemtype2->itemtype, rules => { - holdallowed => 2, + holdallowed => 'from_any_library', hold_fulfillment_policy => 'any', returnbranch => 'any' } @@ -964,7 +964,7 @@ subtest 'CanItemBeReserved / branch_not_in_hold_group' => sub { branchcode => $library2->branchcode, itemtype => $itemtype2->itemtype, rules => { - holdallowed => 3, + holdallowed => 'from_local_hold_group', hold_fulfillment_policy => 'any', returnbranch => 'any' } @@ -984,7 +984,7 @@ subtest 'CanItemBeReserved / branch_not_in_hold_group' => sub { branchcode => $library2->branchcode, itemtype => $itemtype2->itemtype, rules => { - holdallowed => 2, + holdallowed => 'from_any_library', hold_fulfillment_policy => 'any', returnbranch => 'any' } @@ -1004,7 +1004,7 @@ subtest 'CanItemBeReserved / branch_not_in_hold_group' => sub { branchcode => $library2->branchcode, itemtype => $itemtype2->itemtype, rules => { - holdallowed => 3, + holdallowed => 'from_local_hold_group', hold_fulfillment_policy => 'any', returnbranch => 'any' } @@ -1091,7 +1091,7 @@ subtest 'CanItemBeReserved / pickup_not_in_hold_group' => sub { branchcode => undef, itemtype => undef, rules => { - holdallowed => 2, + holdallowed => 'from_any_library', hold_fulfillment_policy => 'holdgroup', returnbranch => 'any' } @@ -1118,7 +1118,7 @@ subtest 'CanItemBeReserved / pickup_not_in_hold_group' => sub { branchcode => $library2->branchcode, itemtype => undef, rules => { - holdallowed => 2, + holdallowed => 'from_any_library', hold_fulfillment_policy => 'any', returnbranch => 'any' } @@ -1138,7 +1138,7 @@ subtest 'CanItemBeReserved / pickup_not_in_hold_group' => sub { branchcode => $library2->branchcode, itemtype => undef, rules => { - holdallowed => 2, + holdallowed => 'from_any_library', hold_fulfillment_policy => 'holdgroup', returnbranch => 'any' } @@ -1158,7 +1158,7 @@ subtest 'CanItemBeReserved / pickup_not_in_hold_group' => sub { branchcode => $library2->branchcode, itemtype => $itemtype2->itemtype, rules => { - holdallowed => 2, + holdallowed => 'from_any_library', hold_fulfillment_policy => 'any', returnbranch => 'any' } @@ -1178,7 +1178,7 @@ subtest 'CanItemBeReserved / pickup_not_in_hold_group' => sub { branchcode => $library2->branchcode, itemtype => $itemtype2->itemtype, rules => { - holdallowed => 2, + holdallowed => 'from_any_library', hold_fulfillment_policy => 'holdgroup', returnbranch => 'any' } @@ -1198,7 +1198,7 @@ subtest 'CanItemBeReserved / pickup_not_in_hold_group' => sub { branchcode => $library2->branchcode, itemtype => $itemtype2->itemtype, rules => { - holdallowed => 2, + holdallowed => 'from_any_library', hold_fulfillment_policy => 'any', returnbranch => 'any' } @@ -1218,7 +1218,7 @@ subtest 'CanItemBeReserved / pickup_not_in_hold_group' => sub { branchcode => $library2->branchcode, itemtype => $itemtype2->itemtype, rules => { - holdallowed => 2, + holdallowed => 'from_any_library', hold_fulfillment_policy => 'holdgroup', returnbranch => 'any' } diff --git a/t/db_dependent/Holds/DisallowHoldIfItemsAvailable.t b/t/db_dependent/Holds/DisallowHoldIfItemsAvailable.t index 8fd6b2cb1b..bc2633a208 100755 --- a/t/db_dependent/Holds/DisallowHoldIfItemsAvailable.t +++ b/t/db_dependent/Holds/DisallowHoldIfItemsAvailable.t @@ -126,8 +126,8 @@ AddReturn( $item1->barcode ); subtest 'IsAvailableForItemLevelRequest behaviours depending on ReservesControlBranch + holdallowed' => sub { plan tests => 2; - my $hold_allowed_from_home_library = 1; - my $hold_allowed_from_any_libraries = 2; + my $hold_allowed_from_home_library = 'from_home_library'; + my $hold_allowed_from_any_libraries = 'from_any_library'; subtest 'Item is available at a different library' => sub { plan tests => 13; diff --git a/t/db_dependent/Holds/HoldFulfillmentPolicy.t b/t/db_dependent/Holds/HoldFulfillmentPolicy.t index de6b5bf594..daf527d622 100755 --- a/t/db_dependent/Holds/HoldFulfillmentPolicy.t +++ b/t/db_dependent/Holds/HoldFulfillmentPolicy.t @@ -78,7 +78,7 @@ Koha::CirculationRules->set_rules( branchcode => undef, itemtype => undef, rules => { - holdallowed => 2, + holdallowed => 'from_any_library', hold_fulfillment_policy => 'homebranch', } } @@ -130,7 +130,7 @@ Koha::CirculationRules->set_rules( branchcode => undef, itemtype => undef, rules => { - holdallowed => 2, + holdallowed => 'from_any_library', hold_fulfillment_policy => 'holdingbranch', } } @@ -182,7 +182,7 @@ Koha::CirculationRules->set_rules( branchcode => undef, itemtype => undef, rules => { - holdallowed => 2, + holdallowed => 'from_any_library', hold_fulfillment_policy => 'any', } } diff --git a/t/db_dependent/HoldsQueue.t b/t/db_dependent/HoldsQueue.t index 358555e94b..eb5e9028b6 100755 --- a/t/db_dependent/HoldsQueue.t +++ b/t/db_dependent/HoldsQueue.t @@ -309,7 +309,7 @@ $dbh->do("DELETE FROM circulation_rules"); Koha::CirculationRules->set_rule( { rule_name => 'holdallowed', - rule_value => 1, + rule_value => 'from_home_library', branchcode => undef, itemtype => undef, } @@ -346,7 +346,7 @@ $dbh->do("DELETE FROM circulation_rules"); Koha::CirculationRules->set_rule( { rule_name => 'holdallowed', - rule_value => 2, + rule_value => 'from_any_library', branchcode => undef, itemtype => undef, } @@ -373,7 +373,7 @@ $dbh->do("DELETE FROM circulation_rules"); Koha::CirculationRules->set_rule( { rule_name => 'holdallowed', - rule_value => 2, + rule_value => 'from_any_library', branchcode => undef, itemtype => undef, } @@ -538,7 +538,7 @@ Koha::CirculationRules->set_rules( branchcode => $library_A, itemtype => $itemtype, rules => { - holdallowed => 2, + holdallowed => 'from_any_library', returnbranch => 'homebranch', } } @@ -651,7 +651,7 @@ Koha::CirculationRules->set_rules( branchcode => undef, itemtype => undef, rules => { - holdallowed => 2, + holdallowed => 'from_any_library', hold_fulfillment_policy => 'homebranch', } } @@ -712,7 +712,7 @@ Koha::CirculationRules->set_rules( branchcode => undef, itemtype => undef, rules => { - holdallowed => 2, + holdallowed => 'from_any_library', hold_fulfillment_policy => 'holdingbranch', } } @@ -770,7 +770,7 @@ Koha::CirculationRules->set_rules( branchcode => undef, itemtype => undef, rules => { - holdallowed => 2, + holdallowed => 'from_any_library', hold_fulfillment_policy => 'any', } } @@ -861,7 +861,7 @@ Koha::CirculationRules->set_rules( branchcode => undef, itemtype => undef, rules => { - holdallowed => 2, + holdallowed => 'from_any_library', hold_fulfillment_policy => 'any', } } @@ -1572,7 +1572,7 @@ subtest "Test _checkHoldPolicy" => sub { ok( $hold, "Found hold" ); my $item = { - holdallowed => 1, + holdallowed => 'from_home_library', homebranch => $request->{borrowerbranch}, # library1 hold_fulfillment_policy => 'any' }; @@ -1580,31 +1580,31 @@ subtest "Test _checkHoldPolicy" => sub { # Base case should work is( C4::HoldsQueue::_checkHoldPolicy( $item, $request ), 1, "_checkHoldPolicy returns true" ); - # Test holdallowed = 0 - $item->{holdallowed} = 0; - is( C4::HoldsQueue::_checkHoldPolicy( $item, $request ), 0, "_checkHoldPolicy returns false if holdallowed = 0" ); + # Test holdallowed = 'not_allowed' + $item->{holdallowed} = 'not_allowed'; + is( C4::HoldsQueue::_checkHoldPolicy( $item, $request ), 0, "_checkHoldPolicy returns false if holdallowed = not_allowed" ); - # Test holdallowed = 1 - $item->{holdallowed} = 1; + # Test holdallowed = 'from_home_library' + $item->{holdallowed} = 'from_home_library'; $item->{homebranch} = $library_nongroup->id; - is( C4::HoldsQueue::_checkHoldPolicy( $item, $request ), 0, "_checkHoldPolicy returns false if holdallowed = 1 and branches do not match" ); + is( C4::HoldsQueue::_checkHoldPolicy( $item, $request ), 0, "_checkHoldPolicy returns false if holdallowed = from_home_library and branches do not match" ); $item->{homebranch} = $request->{borrowerbranch}; - is( C4::HoldsQueue::_checkHoldPolicy( $item, $request ), 1, "_checkHoldPolicy returns true if holdallowed = 1 and branches do match" ); + is( C4::HoldsQueue::_checkHoldPolicy( $item, $request ), 1, "_checkHoldPolicy returns true if holdallowed = from_home_library and branches do match" ); # Test holdallowed = 3 - $item->{holdallowed} = 3; + $item->{holdallowed} = 'from_local_hold_group'; $item->{homebranch} = $library_nongroup->id; - is( C4::HoldsQueue::_checkHoldPolicy( $item, $request ), 0, "_checkHoldPolicy returns false if branchode doesn't match, holdallowed = 3 and no group branches exist" ); + is( C4::HoldsQueue::_checkHoldPolicy( $item, $request ), 0, "_checkHoldPolicy returns false if branchode doesn't match, holdallowed = from_local_hold_group and no group branches exist" ); $item->{homebranch} = $request->{borrowerbranch}; - is( C4::HoldsQueue::_checkHoldPolicy( $item, $request ), 1, "_checkHoldPolicy returns true if branchode matches, holdallowed = 3 and no group branches exist" ); + is( C4::HoldsQueue::_checkHoldPolicy( $item, $request ), 1, "_checkHoldPolicy returns true if branchode matches, holdallowed = from_local_hold_group and no group branches exist" ); # Create library groups hierarchy my $rootgroup = $builder->build_object( { class => 'Koha::Library::Groups', value => {ft_local_hold_group => 1} } ); my $group1 = $builder->build_object( { class => 'Koha::Library::Groups', value => {parent_id => $rootgroup->id, branchcode => $library1->branchcode}} ); my $group2 = $builder->build_object( { class => 'Koha::Library::Groups', value => {parent_id => $rootgroup->id, branchcode => $library2->branchcode}} ); - is( C4::HoldsQueue::_checkHoldPolicy( $item, $request ), 1, "_checkHoldPolicy returns true if holdallowed = 3 and no group branches exist" ); + is( C4::HoldsQueue::_checkHoldPolicy( $item, $request ), 1, "_checkHoldPolicy returns true if holdallowed = from_local_hold_group and no group branches exist" ); $group1->delete; diff --git a/t/db_dependent/Koha/Biblio.t b/t/db_dependent/Koha/Biblio.t index c96f5c2d41..c396bd8824 100755 --- a/t/db_dependent/Koha/Biblio.t +++ b/t/db_dependent/Koha/Biblio.t @@ -221,7 +221,7 @@ subtest 'pickup_locations' => sub { branchcode => $library1->branchcode, itemtype => undef, rules => { - holdallowed => 1, + holdallowed => 'from_home_library', hold_fulfillment_policy => 'any', returnbranch => 'any' } @@ -233,7 +233,7 @@ subtest 'pickup_locations' => sub { branchcode => $library2->branchcode, itemtype => undef, rules => { - holdallowed => 3, + holdallowed => 'from_local_hold_group', hold_fulfillment_policy => 'holdgroup', returnbranch => 'any' } @@ -245,7 +245,7 @@ subtest 'pickup_locations' => sub { branchcode => $library3->branchcode, itemtype => undef, rules => { - holdallowed => 3, + holdallowed => 'from_local_hold_group', hold_fulfillment_policy => 'patrongroup', returnbranch => 'any' } @@ -257,7 +257,7 @@ subtest 'pickup_locations' => sub { branchcode => $library4->branchcode, itemtype => undef, rules => { - holdallowed => 2, + holdallowed => 'from_any_library', hold_fulfillment_policy => 'holdingbranch', returnbranch => 'any' } @@ -269,7 +269,7 @@ subtest 'pickup_locations' => sub { branchcode => $library5->branchcode, itemtype => undef, rules => { - holdallowed => 2, + holdallowed => 'from_any_library', hold_fulfillment_policy => 'homebranch', returnbranch => 'any' } @@ -281,7 +281,7 @@ subtest 'pickup_locations' => sub { branchcode => $library6->branchcode, itemtype => undef, rules => { - holdallowed => 1, + holdallowed => 'from_home_library', hold_fulfillment_policy => 'holdgroup', returnbranch => 'any' } @@ -293,7 +293,7 @@ subtest 'pickup_locations' => sub { branchcode => $library7->branchcode, itemtype => undef, rules => { - holdallowed => 3, + holdallowed => 'from_local_hold_group', hold_fulfillment_policy => 'holdingbranch', returnbranch => 'any' } @@ -306,7 +306,7 @@ subtest 'pickup_locations' => sub { branchcode => $library8->branchcode, itemtype => undef, rules => { - holdallowed => 2, + holdallowed => 'from_any_library', hold_fulfillment_policy => 'patrongroup', returnbranch => 'any' } diff --git a/t/db_dependent/Koha/Holds.t b/t/db_dependent/Koha/Holds.t index 948a9311c4..7d19a132f1 100755 --- a/t/db_dependent/Koha/Holds.t +++ b/t/db_dependent/Koha/Holds.t @@ -490,7 +490,7 @@ subtest 'get_items_that_can_fill' => sub { Koha::CirculationRule->new( { rule_name => 'holdallowed', - rule_value => 0, + rule_value => 'not_allowed', itemtype => $item_5->itype } )->store; diff --git a/t/db_dependent/Koha/Item.t b/t/db_dependent/Koha/Item.t index 06a9a6ef52..ed95c54683 100755 --- a/t/db_dependent/Koha/Item.t +++ b/t/db_dependent/Koha/Item.t @@ -215,66 +215,66 @@ subtest 'pickup_locations' => sub { my $patron4 = $builder->build_object( { class => 'Koha::Patrons', value => { branchcode => $library4->branchcode, firstname => '4' } } ); my $results = { - "1-1-1-any" => 3, - "1-1-1-holdgroup" => 2, - "1-1-1-patrongroup" => 2, - "1-1-1-homebranch" => 1, - "1-1-1-holdingbranch" => 1, - "1-1-2-any" => 3, - "1-1-2-holdgroup" => 2, - "1-1-2-patrongroup" => 2, - "1-1-2-homebranch" => 1, - "1-1-2-holdingbranch" => 1, - "1-1-3-any" => 3, - "1-1-3-holdgroup" => 2, - "1-1-3-patrongroup" => 2, - "1-1-3-homebranch" => 1, - "1-1-3-holdingbranch" => 1, - "1-4-1-any" => 0, - "1-4-1-holdgroup" => 0, - "1-4-1-patrongroup" => 0, - "1-4-1-homebranch" => 0, - "1-4-1-holdingbranch" => 0, - "1-4-2-any" => 3, - "1-4-2-holdgroup" => 2, - "1-4-2-patrongroup" => 1, - "1-4-2-homebranch" => 1, - "1-4-2-holdingbranch" => 1, - "1-4-3-any" => 0, - "1-4-3-holdgroup" => 0, - "1-4-3-patrongroup" => 0, - "1-4-3-homebranch" => 0, - "1-4-3-holdingbranch" => 0, - "3-1-1-any" => 0, - "3-1-1-holdgroup" => 0, - "3-1-1-patrongroup" => 0, - "3-1-1-homebranch" => 0, - "3-1-1-holdingbranch" => 0, - "3-1-2-any" => 3, - "3-1-2-holdgroup" => 1, - "3-1-2-patrongroup" => 2, - "3-1-2-homebranch" => 0, - "3-1-2-holdingbranch" => 1, - "3-1-3-any" => 0, - "3-1-3-holdgroup" => 0, - "3-1-3-patrongroup" => 0, - "3-1-3-homebranch" => 0, - "3-1-3-holdingbranch" => 0, - "3-4-1-any" => 0, - "3-4-1-holdgroup" => 0, - "3-4-1-patrongroup" => 0, - "3-4-1-homebranch" => 0, - "3-4-1-holdingbranch" => 0, - "3-4-2-any" => 3, - "3-4-2-holdgroup" => 1, - "3-4-2-patrongroup" => 1, - "3-4-2-homebranch" => 0, - "3-4-2-holdingbranch" => 1, - "3-4-3-any" => 3, - "3-4-3-holdgroup" => 1, - "3-4-3-patrongroup" => 1, - "3-4-3-homebranch" => 0, - "3-4-3-holdingbranch" => 1 + "1-1-from_home_library-any" => 3, + "1-1-from_home_library-holdgroup" => 2, + "1-1-from_home_library-patrongroup" => 2, + "1-1-from_home_library-homebranch" => 1, + "1-1-from_home_library-holdingbranch" => 1, + "1-1-from_any_library-any" => 3, + "1-1-from_any_library-holdgroup" => 2, + "1-1-from_any_library-patrongroup" => 2, + "1-1-from_any_library-homebranch" => 1, + "1-1-from_any_library-holdingbranch" => 1, + "1-1-from_local_hold_group-any" => 3, + "1-1-from_local_hold_group-holdgroup" => 2, + "1-1-from_local_hold_group-patrongroup" => 2, + "1-1-from_local_hold_group-homebranch" => 1, + "1-1-from_local_hold_group-holdingbranch" => 1, + "1-4-from_home_library-any" => 0, + "1-4-from_home_library-holdgroup" => 0, + "1-4-from_home_library-patrongroup" => 0, + "1-4-from_home_library-homebranch" => 0, + "1-4-from_home_library-holdingbranch" => 0, + "1-4-from_any_library-any" => 3, + "1-4-from_any_library-holdgroup" => 2, + "1-4-from_any_library-patrongroup" => 1, + "1-4-from_any_library-homebranch" => 1, + "1-4-from_any_library-holdingbranch" => 1, + "1-4-from_local_hold_group-any" => 0, + "1-4-from_local_hold_group-holdgroup" => 0, + "1-4-from_local_hold_group-patrongroup" => 0, + "1-4-from_local_hold_group-homebranch" => 0, + "1-4-from_local_hold_group-holdingbranch" => 0, + "3-1-from_home_library-any" => 0, + "3-1-from_home_library-holdgroup" => 0, + "3-1-from_home_library-patrongroup" => 0, + "3-1-from_home_library-homebranch" => 0, + "3-1-from_home_library-holdingbranch" => 0, + "3-1-from_any_library-any" => 3, + "3-1-from_any_library-holdgroup" => 1, + "3-1-from_any_library-patrongroup" => 2, + "3-1-from_any_library-homebranch" => 0, + "3-1-from_any_library-holdingbranch" => 1, + "3-1-from_local_hold_group-any" => 0, + "3-1-from_local_hold_group-holdgroup" => 0, + "3-1-from_local_hold_group-patrongroup" => 0, + "3-1-from_local_hold_group-homebranch" => 0, + "3-1-from_local_hold_group-holdingbranch" => 0, + "3-4-from_home_library-any" => 0, + "3-4-from_home_library-holdgroup" => 0, + "3-4-from_home_library-patrongroup" => 0, + "3-4-from_home_library-homebranch" => 0, + "3-4-from_home_library-holdingbranch" => 0, + "3-4-from_any_library-any" => 3, + "3-4-from_any_library-holdgroup" => 1, + "3-4-from_any_library-patrongroup" => 1, + "3-4-from_any_library-homebranch" => 0, + "3-4-from_any_library-holdingbranch" => 1, + "3-4-from_local_hold_group-any" => 3, + "3-4-from_local_hold_group-holdgroup" => 1, + "3-4-from_local_hold_group-patrongroup" => 1, + "3-4-from_local_hold_group-homebranch" => 0, + "3-4-from_local_hold_group-holdingbranch" => 1 }; sub _doTest { @@ -291,7 +291,12 @@ subtest 'pickup_locations' => sub { } } ); - my $ha_value=$ha==3?'holdgroup':($ha==2?'any':'homebranch'); + my $ha_value = + $ha eq 'from_local_hold_group' ? 'holdgroup' + : ( + $ha eq 'from_any_library' ? 'any' + : 'homebranch' + ); my @pl = map { my $pickup_location = $_; @@ -299,7 +304,7 @@ subtest 'pickup_locations' => sub { } $item->pickup_locations( { patron => $patron } )->as_list; ok( - scalar(@pl) == $results->{ + scalar(@pl) eq $results->{ $item->copynumber . '-' . $patron->firstname . '-' . $ha . '-' @@ -330,7 +335,7 @@ subtest 'pickup_locations' => sub { foreach my $item ($item1, $item3) { foreach my $patron ($patron1, $patron4) { #holdallowed 1: homebranch, 2: any, 3: holdgroup - foreach my $ha (1, 2, 3) { + foreach my $ha ('from_home_library', 'from_any_library', 'from_local_hold_group') { foreach my $hfp ('any', 'holdgroup', 'patrongroup', 'homebranch', 'holdingbranch') { _doTest($item, $patron, $ha, $hfp, $results); } @@ -355,7 +360,7 @@ subtest 'pickup_locations' => sub { branchcode => undef, itemtype => $item1->itype, rules => { - holdallowed => 1, + holdallowed => 'from_home_library', hold_fulfillment_policy => 1, returnbranch => 'any' } diff --git a/t/db_dependent/Reserves.t b/t/db_dependent/Reserves.t index 0f2bec8b61..5d661ee97f 100755 --- a/t/db_dependent/Reserves.t +++ b/t/db_dependent/Reserves.t @@ -198,7 +198,7 @@ Koha::CirculationRules->set_rules( branchcode => $branch_1, itemtype => undef, rules => { - holdallowed => 1, + holdallowed => 'from_home_library', returnbranch => 'homebranch', } } @@ -210,7 +210,7 @@ Koha::CirculationRules->set_rules( branchcode => $branch_2, itemtype => undef, rules => { - holdallowed => 2, + holdallowed => 'from_any_library', returnbranch => 'homebranch', } } diff --git a/t/db_dependent/api/v1/holds.t b/t/db_dependent/api/v1/holds.t index 41cf559ca9..793791874b 100755 --- a/t/db_dependent/api/v1/holds.t +++ b/t/db_dependent/api/v1/holds.t @@ -365,7 +365,7 @@ subtest 'test AllowHoldPolicyOverride' => sub { itemtype => undef, branchcode => undef, rules => { - holdallowed => 1 + holdallowed => 'from_home_library' } } ); -- 2.24.3 (Apple Git-128)