Bug 18936: (follow-up) Adjust circ rule related tests so that they pass

Bunch of tests broke after moving from issuingrules to
circulation_rules. This accomodates the tests for this refactoring and
DB change.

The itemtype did not exist in the DB. We create it at the beginning of
the tests. Ideally we would like to create it filling the form.

Signed-off-by: Minna Kivinen <minna.kivinen@hamk.fi>
Signed-off-by: Joonas Kylmälä <joonas.kylmala@helsinki.fi>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
Joonas Kylmälä 2020-01-29 11:09:17 +00:00 committed by Martin Renvoize
parent b0ccaaf8ef
commit d3d6df99b8
No known key found for this signature in database
GPG Key ID: 422B469130441A0F
4 changed files with 28 additions and 29 deletions

View File

@ -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();

View File

@ -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',

View File

@ -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,

View File

@ -72,7 +72,7 @@ our $sample_data = {
issuingrule => {
categorycode => 'test_cat',
itemtype => 'IT4test',
branchcode => '*',
branchcode => undef,
maxissueqty => '5',
issuelength => '5',
lengthunit => 'days',
@ -81,6 +81,8 @@ our $sample_data = {
};
our ( $borrowernumber, $start, $prev_time, $cleanup_needed );
$dbh->do(q|INSERT INTO itemtypes(itemtype) VALUES (?)|, undef, $sample_data->{itemtype}{itemtype});
SKIP: {
eval { require Selenium::Remote::Driver; };
skip "Selenium::Remote::Driver is needed for selenium tests.", 20 if $@;
@ -146,17 +148,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 +248,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 {