@@ -, +, @@ --- t/db_dependent/Koha/Item.t | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) --- a/t/db_dependent/Koha/Item.t +++ a/t/db_dependent/Koha/Item.t @@ -156,18 +156,13 @@ subtest "as_marc_field() tests" => sub { }; subtest 'pickup_locations' => sub { - plan tests => 114; + plan tests => 60; $schema->storage->txn_begin; my $dbh = C4::Context->dbh; - # Cleanup database - Koha::Holds->search->delete; - $dbh->do('DELETE FROM issues'); - Koha::Patrons->search->delete; - Koha::Items->search->delete; - Koha::Libraries->search->delete; + my $nb_libraries = Koha::Libraries->count; Koha::CirculationRules->search->delete; Koha::CirculationRules->set_rules( { @@ -192,6 +187,11 @@ subtest 'pickup_locations' => sub { my $group2_1 = $builder->build_object( { class => 'Koha::Library::Groups', value => { parent_id => $root2->id, branchcode => $library3->branchcode } } ); my $group2_2 = $builder->build_object( { class => 'Koha::Library::Groups', value => { parent_id => $root2->id, branchcode => $library4->branchcode } } ); + our @branchcodes = ( + $library1->branchcode, $library2->branchcode, + $library3->branchcode, $library4->branchcode + ); + my $item1 = $builder->build_sample_item( { homebranch => $library1->branchcode, @@ -214,17 +214,17 @@ 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-any" => 3 + $nb_libraries, "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-any" => 3 + $nb_libraries, "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-any" => 3 + $nb_libraries, "1-1-3-holdgroup" => 2, "1-1-3-patrongroup" => 2, "1-1-3-homebranch" => 1, @@ -234,7 +234,7 @@ subtest 'pickup_locations' => sub { "1-4-1-patrongroup" => 0, "1-4-1-homebranch" => 0, "1-4-1-holdingbranch" => 0, - "1-4-2-any" => 3, + "1-4-2-any" => 3 + $nb_libraries, "1-4-2-holdgroup" => 2, "1-4-2-patrongroup" => 1, "1-4-2-homebranch" => 1, @@ -249,7 +249,7 @@ subtest 'pickup_locations' => sub { "3-1-1-patrongroup" => 0, "3-1-1-homebranch" => 0, "3-1-1-holdingbranch" => 0, - "3-1-2-any" => 3, + "3-1-2-any" => 3 + $nb_libraries, "3-1-2-holdgroup" => 1, "3-1-2-patrongroup" => 2, "3-1-2-homebranch" => 0, @@ -264,12 +264,12 @@ subtest 'pickup_locations' => sub { "3-4-1-patrongroup" => 0, "3-4-1-homebranch" => 0, "3-4-1-holdingbranch" => 0, - "3-4-2-any" => 3, + "3-4-2-any" => 3 + $nb_libraries, "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-any" => 3 + $nb_libraries, "3-4-3-holdgroup" => 1, "3-4-3-patrongroup" => 1, "3-4-3-homebranch" => 0, @@ -294,6 +294,8 @@ subtest 'pickup_locations' => sub { my $ha_value=$ha==3?'holdgroup':($ha==2?'any':'homebranch'); foreach my $pickup_location (@pl) { + next + unless grep { $pickup_location eq $_ } @branchcodes; is( ref($pickup_location), 'Koha::Library', 'Object type is correct' ); } ok( --