From 32eca336a5cea11e0a921bc98a674cb0f6dcf1ee Mon Sep 17 00:00:00 2001 From: Maryse Simard Date: Sun, 12 Jul 2020 23:58:30 -0400 Subject: [PATCH] Bug 14784: Add tests This patch adds tests for PrevDebarred message of AddReturn when finesdays = 0. To test: 1. Apply patches 2. prove -v t/db_dependent/Circulation.t When applying only this patch, one test should fail. --- t/db_dependent/Circulation.t | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t index e9f28b55d9..bdd6153f94 100755 --- a/t/db_dependent/Circulation.t +++ b/t/db_dependent/Circulation.t @@ -2102,7 +2102,7 @@ subtest 'AddReturn + CumulativeRestrictionPeriods' => sub { }; subtest 'AddReturn + suspension_chargeperiod' => sub { - plan tests => 24; + plan tests => 26; my $library = $builder->build( { source => 'Branch' } ); my $patron = $builder->build( { source => 'Borrower', value => { categorycode => $patron_category->{categorycode} } } ); @@ -2300,6 +2300,35 @@ subtest 'AddReturn + suspension_chargeperiod' => sub { } ); + # Debarred message when finesdays = 0 + + Koha::CirculationRules->set_rules( + { + categorycode => undef, + branchcode => undef, + itemtype => undef, + rules => { + finedays => 0, + suspension_chargeperiod => 1, + } + } + ); + + Koha::Patron::Debarments::AddDebarment( { borrowernumber => $patron->{borrowernumber}, type => 'MANUAL', expiration => $now->clone->add(days => 10) } ); + + AddIssue( $patron, $item_1->{barcode}, $now->clone->add(days => 1) ); + + my ( undef, $message ) = AddReturn( $item_1->{barcode}, $library->{branchcode}, undef, $now->clone->subtract(days => 1) ); + is( $message->{WasReturned} && exists $message->{PrevDebarred}, 1, 'Previously debarred message for AddReturn when not overdue' ); + + AddIssue( $patron, $item_1->{barcode}, $now->clone->add(days => 1) ); + + ( undef, $message ) = AddReturn( $item_1->{barcode}, $library->{branchcode}, undef, $now->clone->add(days => 5) ); + is( $message->{WasReturned} && exists $message->{PrevDebarred}, 1, 'Previously debarred message for AddReturn when overdue' ); + + Koha::Patron::Debarments::DelUniqueDebarment( + { borrowernumber => $patron->{borrowernumber}, type => 'MANUAL' } ); + }; subtest 'CanBookBeIssued + AutoReturnCheckedOutItems' => sub { -- 2.17.1