From 6db14e6f975e55f71be833c53380fce6ded5dc5c Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 31 Jul 2017 11:18:23 -0300 Subject: [PATCH] Bug 19009: Fix random failures from Circulation.t Content-Type: text/plain; charset=utf-8 From jenkins output: Subtest: CanBookBeIssued + Koha::Patron->is_debarred<7c>has_overdues 1..8 not ok 1 [SKIP] I executed it several times and display the different $error, $alerts and question keys. GNA and RESTRICTED were sometimes set, which block the issue. Reading the code it seems that some patron's attributes must be removed to avoid the checkin rejection. Test plan: Execute the tests several times and notice that it fails randomly With this patch they should always pass. Signed-off-by: Owen Leonard Signed-off-by: Marcel de Rooy --- t/db_dependent/Circulation.t | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t index 6252567..f6cd91c 100755 --- a/t/db_dependent/Circulation.t +++ b/t/db_dependent/Circulation.t @@ -1287,7 +1287,7 @@ subtest 'CanBookBeIssued + Koha::Patron->is_debarred|has_overdues' => sub { plan tests => 8; my $library = $builder->build( { source => 'Branch' } ); - my $patron = $builder->build( { source => 'Borrower' } ); + my $patron = $builder->build( { source => 'Borrower', value => { gonenoaddress => undef, lost => undef, debarred => undef, borrowernotes => "" } } ); my $biblioitem_1 = $builder->build( { source => 'Biblioitem' } ); my $item_1 = $builder->build( @@ -1298,6 +1298,7 @@ subtest 'CanBookBeIssued + Koha::Patron->is_debarred|has_overdues' => sub { notforloan => 0, itemlost => 0, withdrawn => 0, + restricted => 0, biblionumber => $biblioitem_1->{biblionumber} } } @@ -1311,6 +1312,7 @@ subtest 'CanBookBeIssued + Koha::Patron->is_debarred|has_overdues' => sub { notforloan => 0, itemlost => 0, withdrawn => 0, + restricted => 0, biblionumber => $biblioitem_2->{biblionumber} } } @@ -1324,25 +1326,25 @@ subtest 'CanBookBeIssued + Koha::Patron->is_debarred|has_overdues' => sub { t::lib::Mocks::mock_preference( 'OverduesBlockCirc', 'confirmation' ); ( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_2->{barcode} ); - is( keys(%$error) + keys(%$alerts), 0 ); - is( $question->{USERBLOCKEDOVERDUE}, 1 ); + is( keys(%$error) + keys(%$alerts), 0, 'No key for error and alert ' . keys(%$error) . ' ' . keys(%$alerts) ); + is( $question->{USERBLOCKEDOVERDUE}, 1, 'OverduesBlockCirc=confirmation, USERBLOCKEDOVERDUE should be set for question' ); t::lib::Mocks::mock_preference( 'OverduesBlockCirc', 'block' ); ( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_2->{barcode} ); - is( keys(%$question) + keys(%$alerts), 0 ); - is( $error->{USERBLOCKEDOVERDUE}, 1 ); + is( keys(%$question) + keys(%$alerts), 0, 'No key for question and alert ' . keys(%$question) . ' ' . keys(%$alerts) ); + is( $error->{USERBLOCKEDOVERDUE}, 1, 'OverduesBlockCirc=block, USERBLOCKEDOVERDUE should be set for error' ); # Patron cannot issue item_1, they are debarred my $tomorrow = DateTime->today( time_zone => C4::Context->tz() )->add( days => 1 ); Koha::Patron::Debarments::AddDebarment( { borrowernumber => $patron->{borrowernumber}, expiration => $tomorrow } ); ( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_2->{barcode} ); - is( keys(%$question) + keys(%$alerts), 0 ); - is( $error->{USERBLOCKEDWITHENDDATE}, output_pref( { dt => $tomorrow, dateformat => 'sql', dateonly => 1 } ) ); + is( keys(%$question) + keys(%$alerts), 0, 'No key for question and alert ' . keys(%$question) . ' ' . keys(%$alerts) ); + is( $error->{USERBLOCKEDWITHENDDATE}, output_pref( { dt => $tomorrow, dateformat => 'sql', dateonly => 1 } ), 'USERBLOCKEDWITHENDDATE should be tomorrow' ); Koha::Patron::Debarments::AddDebarment( { borrowernumber => $patron->{borrowernumber} } ); ( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_2->{barcode} ); - is( keys(%$question) + keys(%$alerts), 0 ); - is( $error->{USERBLOCKEDNOENDDATE}, '9999-12-31' ); + is( keys(%$question) + keys(%$alerts), 0, 'No key for question and alert ' . keys(%$question) . ' ' . keys(%$alerts) ); + is( $error->{USERBLOCKEDNOENDDATE}, '9999-12-31', 'USERBLOCKEDNOENDDATE should be 9999-12-31 for unlimited debarments' ); }; subtest 'MultipleReserves' => sub { -- 2.1.4