From 8e338c3ae1d1f69210c9b9a2209db1c7afc1e44a Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Tue, 19 Jan 2016 17:49:44 +0000 Subject: [PATCH] Bug 14695 [QA Followup] - Make existing unit tests pass * Removes tests no longer needed * Updates rules to work with existing tests * Fixes code issues revealed by unit tests Signed-off-by: Nick Clemens Signed-off-by: Jason M. Burds Signed-off-by: Benjamin Rokseth --- C4/Reserves.pm | 6 +++--- t/db_dependent/Holds.t | 24 ++++++++++++------------ t/db_dependent/Reserves.t | 10 +--------- 3 files changed, 16 insertions(+), 24 deletions(-) diff --git a/C4/Reserves.pm b/C4/Reserves.pm index c717af6d14..3fa5192e19 100644 --- a/C4/Reserves.pm +++ b/C4/Reserves.pm @@ -562,16 +562,16 @@ sub CanItemBeReserved { } my $circ_control_branch = - C4::Circulation::_GetCircControlBranch( $item, $borrower ); + C4::Circulation::_GetCircControlBranch( $item->unblessed(), $borrower ); my $branchitemrule = - C4::Circulation::GetBranchItemRule( $circ_control_branch, $item->{itype} ); + C4::Circulation::GetBranchItemRule( $circ_control_branch, $item->itype ); if ( $branchitemrule->{holdallowed} == 0 ) { return 'notReservable'; } if ( $branchitemrule->{holdallowed} == 1 - && $borrower->{branchcode} ne $item->{homebranch} ) + && $borrower->{branchcode} ne $item->homebranch ) { return 'cannotReserveFromOtherBranches'; } diff --git a/t/db_dependent/Holds.t b/t/db_dependent/Holds.t index f9ddc46875..da67f51f0b 100755 --- a/t/db_dependent/Holds.t +++ b/t/db_dependent/Holds.t @@ -237,16 +237,16 @@ my ($foreign_item_bibnum, $foreign_item_bibitemnum, $foreign_itemnumber) = AddItem({ homebranch => $branch_2, holdingbranch => $branch_2 } , $foreign_bibnum); $dbh->do('DELETE FROM issuingrules'); $dbh->do( - q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed) - VALUES (?, ?, ?, ?)}, + q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed, holds_per_record) + VALUES (?, ?, ?, ?, ?)}, {}, - '*', '*', '*', 25 + '*', '*', '*', 25, 99 ); $dbh->do( - q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed) - VALUES (?, ?, ?, ?)}, + q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed, holds_per_record) + VALUES (?, ?, ?, ?, ?)}, {}, - '*', '*', 'CANNOT', 0 + '*', '*', 'CANNOT', 0, 99 ); # make sure some basic sysprefs are set @@ -337,7 +337,7 @@ is( $reserve3->{priority}, 1, "After ModReserve, the 3rd reserve becomes the fir ModItem({ damaged => 1 }, $item_bibnum, $itemnumber); t::lib::Mocks::mock_preference( 'AllowHoldsOnDamagedItems', 1 ); -ok( CanItemBeReserved( $borrowernumbers[0], $itemnumber) eq 'OK', "Patron can reserve damaged item with AllowHoldsOnDamagedItems enabled" ); +is( CanItemBeReserved( $borrowernumbers[0], $itemnumber), 'OK', "Patron can reserve damaged item with AllowHoldsOnDamagedItems enabled" ); ok( defined( ( CheckReserves($itemnumber) )[1] ), "Hold can be trapped for damaged item with AllowHoldsOnDamagedItems enabled" ); t::lib::Mocks::mock_preference( 'AllowHoldsOnDamagedItems', 0 ); ok( CanItemBeReserved( $borrowernumbers[0], $itemnumber) eq 'damaged', "Patron cannot reserve damaged item with AllowHoldsOnDamagedItems disabled" ); @@ -353,8 +353,8 @@ AddReserve( '', 1, ); -ok( - CanItemBeReserved( $borrowernumbers[0], $itemnumber) eq 'tooManyReserves', +is( + CanItemBeReserved( $borrowernumbers[0], $itemnumber), 'tooManyReserves', "cannot request item if policy that matches on item-level item type forbids it" ); ModItem({ itype => 'CAN' }, $item_bibnum, $itemnumber); @@ -460,10 +460,10 @@ $dbh->do('DELETE FROM biblio'); = AddItem( { homebranch => $branch_1, holdingbranch => $branch_1 }, $bibnum ); $dbh->do( - q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed) - VALUES (?, ?, ?, ?)}, + q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed, holds_per_record) + VALUES (?, ?, ?, ?, ?)}, {}, - '*', '*', 'ONLY1', 1 + '*', '*', 'ONLY1', 1, 99 ); is( CanItemBeReserved( $borrowernumbers[0], $itemnumber ), 'OK', 'Patron can reserve item with hold limit of 1, no holds placed' ); diff --git a/t/db_dependent/Reserves.t b/t/db_dependent/Reserves.t index ea3f700bd4..e9f1e6b81c 100755 --- a/t/db_dependent/Reserves.t +++ b/t/db_dependent/Reserves.t @@ -17,7 +17,7 @@ use Modern::Perl; -use Test::More tests => 74; +use Test::More tests => 72; use Test::MockModule; use Test::Warn; @@ -450,14 +450,6 @@ $p = C4::Reserves::CalculatePriority($bibnum, $resdate); is($p, 3, 'CalculatePriority should now return priority 3'); # End of tests for bug 8918 -# Test for bug 5144 -warning_is { - $reserve_id = AddReserve('CPL', $requesters{'CPL3'}, $bibnum, - $bibitems, $p, output_pref($resdate), $expdate, $notes, - $title, $checkitem, $found) -} "AddReserve: borrower $requesters{CPL3} already has a hold for biblionumber $bibnum"; -is( $reserve_id, undef, 'Attempt to add a second reserve on a given record for the same patron fails.' ); - # Tests for cancel reserves by users from OPAC. $dbh->do('DELETE FROM reserves', undef, ($bibnum)); AddReserve('CPL', $requesters{'CPL'}, $item_bibnum, -- 2.39.5