From ac6f945f428419e4059ac8647466d054ffd4ab6e Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 8 Jun 2017 11:54:18 -0300 Subject: [PATCH] Bug 18759: Try to fix random failure from Circulation.t Circulation.t is failing randomly on our CI https://jenkins.koha-community.org/job/Koha_Master_D8/192/console # Failed test at t/db_dependent/Circulation.t line 1147. # got: '1' # expected: '0' # Failed test at t/db_dependent/Circulation.t line 1152. # got: '1' # expected: '0' # Failed test at t/db_dependent/Circulation.t line 1156. # got: '1' # expected: '0' # Failed test at t/db_dependent/Circulation.t line 1170. # got: '1' # expected: '0' # Failed test at t/db_dependent/Circulation.t line 1184. # got: '1' # expected: '0' # Looks like you failed 5 tests of 23. Sometimes one of the alert or impossible flags is set. This patch guesses that it's because of the 'restricted' value of the item that is evaluated to 1. If it is not fixed by this patch, we will have more info next time (at least know if alert or impossible is set). Signed-off-by: Tomas Cohen Arazi The fix is trivial. Using random data will lead to this situations. The good thing is that it lets us spot places in which tests need more fine-grained data. (cherry picked from commit 9a55f5783c91b92cb8518f423ab23bd9727051ee) Signed-off-by: Fridolin Somers (cherry picked from commit 178ecea26000f6c3b8b16630ac6f13277d828d68) Signed-off-by: Katrin Fischer --- t/db_dependent/Circulation.t | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t index f29dcd0bed..089c951672 100755 --- a/t/db_dependent/Circulation.t +++ b/t/db_dependent/Circulation.t @@ -1024,7 +1024,7 @@ C4::Context->dbh->do("DELETE FROM accountlines"); } subtest 'CanBookBeIssued & AllowReturnToBranch' => sub { - plan tests => 23; + plan tests => 26; my $homebranch = $builder->build( { source => 'Branch' } ); my $holdingbranch = $builder->build( { source => 'Branch' } ); @@ -1041,6 +1041,7 @@ subtest 'CanBookBeIssued & AllowReturnToBranch' => sub { notforloan => 0, itemlost => 0, withdrawn => 0, + restricted => 0, biblionumber => $biblioitem->{biblionumber} } } @@ -1058,16 +1059,19 @@ subtest 'CanBookBeIssued & AllowReturnToBranch' => sub { ## Can be issued from homebranch set_userenv($homebranch); ( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->{barcode} ); - is( keys(%$error) + keys(%$alerts), 0 ); + is( keys(%$error), 0, 'There should not be any errors (impossible)' ); + is( keys(%$alerts), 0, 'There should not be any alerts' ); is( exists $question->{ISSUED_TO_ANOTHER}, 1 ); ## Can be issued from holdingbranch set_userenv($holdingbranch); ( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->{barcode} ); - is( keys(%$error) + keys(%$alerts), 0 ); + is( keys(%$error), 0, 'There should not be any errors (impossible)' ); + is( keys(%$alerts), 0, 'There should not be any alerts' ); is( exists $question->{ISSUED_TO_ANOTHER}, 1 ); ## Can be issued from another branch ( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->{barcode} ); - is( keys(%$error) + keys(%$alerts), 0 ); + is( keys(%$error), 0, 'There should not be any errors (impossible)' ); + is( keys(%$alerts), 0, 'There should not be any alerts' ); is( exists $question->{ISSUED_TO_ANOTHER}, 1 ); # AllowReturnToBranch == holdingbranch -- 2.39.5