From 6b27cd94f2a46e79ae11889eb62010608c2bd602 Mon Sep 17 00:00:00 2001 From: Agustin Moyano Date: Thu, 13 Feb 2020 14:16:20 -0300 Subject: [PATCH] Bug 24657: Fix t/db_dependent/Koha/Item.t and t/db_dependent/Holds.t on t/db_dependent/Koha/Item.t on line 172 I created 2 Koha::Library::Groups like this 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 } } ); I didn't realize this was creating 2 new libraries that sometimes messed up with tests, so I changed it to this my $root1 = $builder->build_object( { class => 'Koha::Library::Groups', value => { ft_local_hold_group => 1, branchcode => undef } } ); my $root2 = $builder->build_object( { class => 'Koha::Library::Groups', value => { ft_local_hold_group => 1, branchcode => undef } } ); on t/db_dependent/Holds.t on line 1058 I created 3 libraries like this my $library1 = $builder->build_object( { class => 'Koha::Libraries' } ); my $library2 = $builder->build_object( { class => 'Koha::Libraries' } ); my $library3 = $builder->build_object( { class => 'Koha::Libraries' } ); but they needed to be pickup_locations, and sometimes they wheren't set as such, so I changed it to this my $library1 = $builder->build_object( { class => 'Koha::Libraries', value => {pickup_location => 1} } ); my $library2 = $builder->build_object( { class => 'Koha::Libraries', value => {pickup_location => 1} } ); my $library3 = $builder->build_object( { class => 'Koha::Libraries', value => {pickup_location => 1} } ); To test: 1. do not apply this patch 2. in bash: for i in {1..300}; do echo "loop $i"; prove t/db_dependent/Koha/Item.t t/db_dependent/Holds.t; if [ "$?" = "1" ]; then break; fi; done 3. Grab a cup of coffee (or tea if you are healthy) and wait for a while 4. Whithin 300 iterations there should be an error in any of both scripts and for loop should exit 5. Apply this patch 6. repeat step 2 and 3 (decaff this time!) 7. All 300 loops should pass 8. Sign off --- t/db_dependent/Holds.t | 6 +++--- t/db_dependent/Koha/Item.t | 15 ++++++--------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/t/db_dependent/Holds.t b/t/db_dependent/Holds.t index a84eba8a0e..b648db8f4a 100755 --- a/t/db_dependent/Holds.t +++ b/t/db_dependent/Holds.t @@ -1055,9 +1055,9 @@ subtest 'CanItemBeReserved / pickup_not_in_hold_group' => sub { my $itemtype2 = $builder->build_object( { class => 'Koha::ItemTypes' } ); # Create libraries - my $library1 = $builder->build_object( { class => 'Koha::Libraries' } ); - my $library2 = $builder->build_object( { class => 'Koha::Libraries' } ); - my $library3 = $builder->build_object( { class => 'Koha::Libraries' } ); + my $library1 = $builder->build_object( { class => 'Koha::Libraries', value => {pickup_location => 1} } ); + my $library2 = $builder->build_object( { class => 'Koha::Libraries', value => {pickup_location => 1} } ); + my $library3 = $builder->build_object( { class => 'Koha::Libraries', value => {pickup_location => 1} } ); # Create library groups hierarchy my $rootgroup = $builder->build_object( { class => 'Koha::Library::Groups', value => {ft_local_hold_group => 1} } ); diff --git a/t/db_dependent/Koha/Item.t b/t/db_dependent/Koha/Item.t index f4484caceb..e70d39ea04 100644 --- a/t/db_dependent/Koha/Item.t +++ b/t/db_dependent/Koha/Item.t @@ -169,14 +169,12 @@ subtest 'pickup_locations' => sub { } ); - 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 } } ); - - my $library1 = $builder->build_object( { class => 'Koha::Libraries', value => { pickup_location => 1 } } ); - my $library2 = $builder->build_object( { class => 'Koha::Libraries', value => { pickup_location => 1 } } ); - my $library3 = $builder->build_object( { class => 'Koha::Libraries', value => { pickup_location => 0 } } ); - my $library4 = $builder->build_object( { class => 'Koha::Libraries', value => { pickup_location => 1 } } ); - + my $root1 = $builder->build_object( { class => 'Koha::Library::Groups', value => { ft_local_hold_group => 1, branchcode => undef } } ); + my $root2 = $builder->build_object( { class => 'Koha::Library::Groups', value => { ft_local_hold_group => 1, branchcode => undef } } ); + my $library1 = $builder->build_object( { class => 'Koha::Libraries', value => { pickup_location => 1, branchcode => 'TEST1' } } ); + my $library2 = $builder->build_object( { class => 'Koha::Libraries', value => { pickup_location => 1, branchcode => 'TEST2' } } ); + my $library3 = $builder->build_object( { class => 'Koha::Libraries', value => { pickup_location => 0, branchcode => 'TEST3' } } ); + my $library4 = $builder->build_object( { class => 'Koha::Libraries', value => { pickup_location => 1, branchcode => 'TEST4' } } ); my $group1_1 = $builder->build_object( { class => 'Koha::Library::Groups', value => { parent_id => $root1->id, branchcode => $library1->branchcode } } ); my $group1_2 = $builder->build_object( { class => 'Koha::Library::Groups', value => { parent_id => $root1->id, branchcode => $library2->branchcode } } ); @@ -289,7 +287,6 @@ subtest 'pickup_locations' => sub { foreach my $pickup_location (@pl) { is( ref($pickup_location), 'Koha::Library', 'Object type is correct' ); } - ok( scalar(@pl) == $results->{ $item->barcode . '-' -- 2.17.1