From 125e518f42fa5e231402ab6e23ad70c86eab1b33 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 31 Jul 2017 11:18:23 -0300 Subject: [PATCH] [SIGNED-OFF] Bug 19009: Fix random failures from Circulation.t 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 --- 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 9319924..4e8da01 100755 --- a/t/db_dependent/Circulation.t +++ b/t/db_dependent/Circulation.t @@ -1285,7 +1285,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( @@ -1296,6 +1296,7 @@ subtest 'CanBookBeIssued + Koha::Patron->is_debarred|has_overdues' => sub { notforloan => 0, itemlost => 0, withdrawn => 0, + restricted => 0, biblionumber => $biblioitem_1->{biblionumber} } } @@ -1309,6 +1310,7 @@ subtest 'CanBookBeIssued + Koha::Patron->is_debarred|has_overdues' => sub { notforloan => 0, itemlost => 0, withdrawn => 0, + restricted => 0, biblionumber => $biblioitem_2->{biblionumber} } } @@ -1322,25 +1324,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