@@ -, +, @@ --- t/db_dependent/Circulation/Branch.t | 6 ----- t/db_dependent/Circulation/SwitchOnSiteCheckouts.t | 4 --- t/db_dependent/Circulation/TooMany.t | 4 --- .../Holds/DisallowHoldIfItemsAvailable.t | 30 ++++++++++++++-------- 4 files changed, 20 insertions(+), 24 deletions(-) --- a/t/db_dependent/Circulation/Branch.t +++ a/t/db_dependent/Circulation/Branch.t @@ -176,12 +176,6 @@ Koha::CirculationRules->set_rules( } ); -$query = q| - INSERT INTO default_circ_rules - (singleton, holdallowed, returnbranch) - VALUES( ?, ?, ? ) -|; -$dbh->do( $query, {}, 'singleton', 3, 'homebranch' ); Koha::CirculationRules->set_rules( { branchcode => undef, --- a/t/db_dependent/Circulation/SwitchOnSiteCheckouts.t +++ a/t/db_dependent/Circulation/SwitchOnSiteCheckouts.t @@ -37,11 +37,7 @@ $schema->storage->txn_begin; our $dbh = C4::Context->dbh; -$dbh->do(q|DELETE FROM branch_item_rules|); $dbh->do(q|DELETE FROM issues|); -$dbh->do(q|DELETE FROM default_branch_circ_rules|); -$dbh->do(q|DELETE FROM default_circ_rules|); -$dbh->do(q|DELETE FROM default_branch_item_rules|); $dbh->do(q|DELETE FROM issuingrules|); my $builder = t::lib::TestBuilder->new(); --- a/t/db_dependent/Circulation/TooMany.t +++ a/t/db_dependent/Circulation/TooMany.t @@ -43,10 +43,6 @@ $dbh->do(q|DELETE FROM branches|); $dbh->do(q|DELETE FROM categories|); $dbh->do(q|DELETE FROM accountlines|); $dbh->do(q|DELETE FROM itemtypes|); -$dbh->do(q|DELETE FROM branch_item_rules|); -$dbh->do(q|DELETE FROM default_branch_circ_rules|); -$dbh->do(q|DELETE FROM default_circ_rules|); -$dbh->do(q|DELETE FROM default_branch_item_rules|); $dbh->do(q|DELETE FROM issuingrules|); Koha::CirculationRules->search()->delete(); --- a/t/db_dependent/Holds/DisallowHoldIfItemsAvailable.t +++ a/t/db_dependent/Holds/DisallowHoldIfItemsAvailable.t @@ -125,8 +125,6 @@ AddReturn( $item1->{barcode} ); my $hold_allowed_from_home_library = 1; my $hold_allowed_from_any_libraries = 2; - my $sth_delete_rules = $dbh->prepare(q|DELETE FROM default_circ_rules|); - my $sth_insert_rule = $dbh->prepare(q|INSERT INTO default_circ_rules(singleton, holdallowed, hold_fulfillment_policy, returnbranch) VALUES ('singleton', ?, 'any', 'homebranch');|); subtest 'Item is available at a different library' => sub { plan tests => 4; @@ -142,8 +140,7 @@ AddReturn( $item1->{barcode} ); #FIXME: ReservesControlBranch is not checked in these subs we are testing { - $sth_delete_rules->execute; - $sth_insert_rule->execute( $hold_allowed_from_home_library ); + set_holdallowed_rule( $hold_allowed_from_home_library ); t::lib::Mocks::mock_preference('ReservesControlBranch', 'ItemHomeLibrary'); $is = IsAvailableForItemLevelRequest( $item1, $borrower1); @@ -155,8 +152,7 @@ AddReturn( $item1->{barcode} ); } { - $sth_delete_rules->execute; - $sth_insert_rule->execute( $hold_allowed_from_any_libraries ); + set_holdallowed_rule( $hold_allowed_from_any_libraries ); t::lib::Mocks::mock_preference('ReservesControlBranch', 'ItemHomeLibrary'); $is = IsAvailableForItemLevelRequest( $item1, $borrower1); @@ -182,8 +178,7 @@ AddReturn( $item1->{barcode} ); #ReservesControlBranch is not checked in these subs we are testing? { - $sth_delete_rules->execute; - $sth_insert_rule->execute( $hold_allowed_from_home_library ); + set_holdallowed_rule( $hold_allowed_from_home_library ); t::lib::Mocks::mock_preference('ReservesControlBranch', 'ItemHomeLibrary'); $is = IsAvailableForItemLevelRequest( $item1, $borrower1); @@ -195,8 +190,7 @@ AddReturn( $item1->{barcode} ); } { - $sth_delete_rules->execute; - $sth_insert_rule->execute( $hold_allowed_from_any_libraries ); + set_holdallowed_rule( $hold_allowed_from_any_libraries ); t::lib::Mocks::mock_preference('ReservesControlBranch', 'ItemHomeLibrary'); $is = IsAvailableForItemLevelRequest( $item1, $borrower1); @@ -253,3 +247,19 @@ is( $is, 1, "Item can be held, items in transit are not available" ); # Cleanup $schema->storage->txn_rollback; + +sub set_holdallowed_rule { + my ( $holdallowed ) = @_; + Koha::CirculationRules->set_rules( + { + branchcode => undef, + categorycode => undef, + itemtype => undef, + rules => { + holdallowed => $holdallowed, + hold_fulfillment_policy => 'any', + returnbranch => 'homebranch', + } + } + ); +} --