From 7958198894d79e5caa403be83c9034d044564a6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joonas=20Kylm=C3=A4l=C3=A4?= Date: Wed, 29 Jan 2020 11:09:17 +0000 Subject: [PATCH] Bug 18936: (follow-up) Adjust circ rule related tests so that they pass MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bunch of tests broke after moving from issuingrules to circulation_rules. This accomodates the tests for this refactoring and DB change. Signed-off-by: Minna Kivinen Signed-off-by: Joonas Kylmälä --- t/db_dependent/HoldsQueue.t | 1 - t/db_dependent/Koha/Biblio.t | 25 ++++++++++--------------- t/db_dependent/Koha/Item.t | 18 ++++++++++-------- t/db_dependent/selenium/basic_workflow.t | 11 ++++++----- 4 files changed, 26 insertions(+), 29 deletions(-) diff --git a/t/db_dependent/HoldsQueue.t b/t/db_dependent/HoldsQueue.t index 2c52c87ca4..f70e61f617 100755 --- a/t/db_dependent/HoldsQueue.t +++ b/t/db_dependent/HoldsQueue.t @@ -950,7 +950,6 @@ subtest "Test Local Holds Priority - Ensure no duplicate requests in holds queue $dbh->do("DELETE FROM tmp_holdsqueue"); $dbh->do("DELETE FROM hold_fill_targets"); $dbh->do("DELETE FROM reserves"); - $dbh->do("DELETE FROM issuingrules"); $dbh->do("DELETE FROM circulation_rules"); Koha::Biblios->delete(); diff --git a/t/db_dependent/Koha/Biblio.t b/t/db_dependent/Koha/Biblio.t index 2abacff51a..790b623aad 100644 --- a/t/db_dependent/Koha/Biblio.t +++ b/t/db_dependent/Koha/Biblio.t @@ -187,15 +187,18 @@ subtest 'pickup_locations' => sub { Koha::Patrons->search->delete; Koha::Items->search->delete; Koha::Libraries->search->delete; + Koha::CirculationRules->search->delete; $dbh->do('DELETE FROM issues'); - $dbh->do('DELETE FROM issuingrules'); - $dbh->do( - q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed) - VALUES (?, ?, ?, ?)}, - {}, - '*', '*', '*', 25 + Koha::CirculationRules->set_rules( + { + categorycode => undef, + itemtype => undef, + branchcode => undef, + rules => { + reservesallowed => 25, + } + } ); - $dbh->do('DELETE FROM circulation_rules'); my $root1 = $builder->build_object( { class => 'Koha::Library::Groups', value => { ft_local_hold_group => 1 } } ); my $root2 = $builder->build_object( { class => 'Koha::Library::Groups', value => { ft_local_hold_group => 1 } } ); @@ -214,7 +217,6 @@ subtest 'pickup_locations' => sub { { branchcode => $library1->branchcode, itemtype => undef, - categorycode => undef, rules => { holdallowed => 1, hold_fulfillment_policy => 'any', @@ -227,7 +229,6 @@ subtest 'pickup_locations' => sub { { branchcode => $library2->branchcode, itemtype => undef, - categorycode => undef, rules => { holdallowed => 3, hold_fulfillment_policy => 'holdgroup', @@ -240,7 +241,6 @@ subtest 'pickup_locations' => sub { { branchcode => $library3->branchcode, itemtype => undef, - categorycode => undef, rules => { holdallowed => 3, hold_fulfillment_policy => 'patrongroup', @@ -253,7 +253,6 @@ subtest 'pickup_locations' => sub { { branchcode => $library4->branchcode, itemtype => undef, - categorycode => undef, rules => { holdallowed => 2, hold_fulfillment_policy => 'holdingbranch', @@ -266,7 +265,6 @@ subtest 'pickup_locations' => sub { { branchcode => $library5->branchcode, itemtype => undef, - categorycode => undef, rules => { holdallowed => 2, hold_fulfillment_policy => 'homebranch', @@ -279,7 +277,6 @@ subtest 'pickup_locations' => sub { { branchcode => $library6->branchcode, itemtype => undef, - categorycode => undef, rules => { holdallowed => 1, hold_fulfillment_policy => 'holdgroup', @@ -292,7 +289,6 @@ subtest 'pickup_locations' => sub { { branchcode => $library7->branchcode, itemtype => undef, - categorycode => undef, rules => { holdallowed => 3, hold_fulfillment_policy => 'holdingbranch', @@ -306,7 +302,6 @@ subtest 'pickup_locations' => sub { { branchcode => $library8->branchcode, itemtype => undef, - categorycode => undef, rules => { holdallowed => 2, hold_fulfillment_policy => 'patrongroup', diff --git a/t/db_dependent/Koha/Item.t b/t/db_dependent/Koha/Item.t index 459c59fc3a..f4484caceb 100644 --- a/t/db_dependent/Koha/Item.t +++ b/t/db_dependent/Koha/Item.t @@ -157,14 +157,17 @@ subtest 'pickup_locations' => sub { Koha::Items->search->delete; Koha::Libraries->search->delete; $dbh->do('DELETE FROM issues'); - $dbh->do('DELETE FROM issuingrules'); - $dbh->do( - q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed) - VALUES (?, ?, ?, ?)}, - {}, - '*', '*', '*', 25 + Koha::CirculationRules->search->delete; + Koha::CirculationRules->set_rules( + { + categorycode => undef, + itemtype => undef, + branchcode => undef, + rules => { + reservesallowed => 25, + } + } ); - $dbh->do('DELETE FROM circulation_rules'); my $root1 = $builder->build_object( { class => 'Koha::Library::Groups', value => { ft_local_hold_group => 1 } } ); my $root2 = $builder->build_object( { class => 'Koha::Library::Groups', value => { ft_local_hold_group => 1 } } ); @@ -273,7 +276,6 @@ subtest 'pickup_locations' => sub { { branchcode => undef, itemtype => undef, - categorycode => undef, rules => { holdallowed => $ha, hold_fulfillment_policy => $hfp, diff --git a/t/db_dependent/selenium/basic_workflow.t b/t/db_dependent/selenium/basic_workflow.t index 5f785d21df..044fdeb5b6 100644 --- a/t/db_dependent/selenium/basic_workflow.t +++ b/t/db_dependent/selenium/basic_workflow.t @@ -72,7 +72,7 @@ our $sample_data = { issuingrule => { categorycode => 'test_cat', itemtype => 'IT4test', - branchcode => '*', + branchcode => undef, maxissueqty => '5', issuelength => '5', lengthunit => 'days', @@ -146,17 +146,18 @@ SKIP: { time_diff("add biblio"); my $itemtype = $sample_data->{itemtype}; - $dbh->do(q|INSERT INTO itemtypes (itemtype, description, rentalcharge, notforloan) VALUES (?, ?, ?, ?)|, undef, $itemtype->{itemtype}, $itemtype->{description}, $itemtype->{rentalcharge}, $itemtype->{notforloan}); my $issuing_rules = $sample_data->{issuingrule}; - $dbh->do(q|INSERT INTO issuingrules (categorycode, itemtype, branchcode, issuelength, lengthunit, renewalperiod) VALUES (?, ?, ?, ?, ?, ?)|, undef, $issuing_rules->{categorycode}, $issuing_rules->{itemtype}, $issuing_rules->{branchcode}, $issuing_rules->{issuelength}, $issuing_rules->{lengthunit}, $issuing_rules->{renewalperiod}); Koha::CirculationRules->set_rules( { categorycode => $issuing_rules->{categorycode}, itemtype => $issuing_rules->{itemtype}, branchcode => $issuing_rules->{branchcode}, rules => { - maxissueqty => $issuing_rules->{maxissueqty} + maxissueqty => $issuing_rules->{maxissueqty}, + issuelength => $issuing_rules->{issuelength}, + lengthunit => $issuing_rules->{lengthunit}, + renewalperiod => $issuing_rules->{renewalperiod}, } } ); @@ -245,7 +246,7 @@ sub cleanup { $dbh->do(qq|DELETE FROM biblio WHERE title = "test biblio $i"|); }; $dbh->do(q|DELETE FROM itemtypes WHERE itemtype=?|, undef, $sample_data->{itemtype}{itemtype}); - $dbh->do(q|DELETE FROM issuingrules WHERE categorycode=? AND itemtype=? AND branchcode=?|, undef, $sample_data->{issuingrule}{categorycode}, $sample_data->{issuingrule}{itemtype}, $sample_data->{issuingrule}{branchcode}); + $dbh->do(q|DELETE FROM circulation_rules WHERE categorycode=? AND itemtype=? AND branchcode=?|, undef, $sample_data->{issuingrule}{categorycode}, $sample_data->{issuingrule}{itemtype}, $sample_data->{issuingrule}{branchcode}); } sub time_diff { -- 2.11.0