From 63e6f07394e6739cd5d5cd294475eb302e63faf9 Mon Sep 17 00:00:00 2001 From: Shi Yao Wang Date: Thu, 14 Jul 2022 10:41:27 -0400 Subject: [PATCH] Bug 14784: (follow-up) Unit tests --- t/db_dependent/Circulation.t | 43 +++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t index 84444a3bd0..c6b9fec85c 100755 --- a/t/db_dependent/Circulation.t +++ b/t/db_dependent/Circulation.t @@ -2598,7 +2598,7 @@ subtest 'AddReturn + CumulativeRestrictionPeriods' => sub { }; subtest 'AddReturn + suspension_chargeperiod' => sub { - plan tests => 27; + plan tests => 29; my $library = $builder->build( { source => 'Branch' } ); my $patron = $builder->build( { source => 'Borrower', value => { categorycode => $patron_category->{categorycode} } } ); @@ -2828,6 +2828,47 @@ subtest 'AddReturn + suspension_chargeperiod' => sub { } ); + Koha::CirculationRules->search->delete; + Koha::CirculationRules->set_rules( + { + categorycode => undef, + itemtype => undef, + branchcode => undef, + rules => { + finedays => 0, + } + } + ); + + Koha::Patron::Debarments::AddDebarment( + { + borrowernumber => $patron->{borrowernumber}, + expiration => '9999-12-31', + type => 'MANUAL', + } + ); + + AddIssue( $patron, $item_1->barcode, $now->clone->subtract( days => 1 ) ); + my ( undef, $message ) = AddReturn( $item_1->barcode, $library->{branchcode}, undef, $now ); + is( $message->{WasReturned} && exists $message->{ForeverDebarred}, 1, 'Forever debarred message for Addreturn when overdue'); + + Koha::Patron::Debarments::DelUniqueDebarment( + { + borrowernumber => $patron->{borrowernumber}, + type => 'MANUAL', + } + ); + Koha::Patron::Debarments::AddDebarment( + { + borrowernumber => $patron->{borrowernumber}, + expiration => $now->clone->add( days => 10 ), + type => 'MANUAL', + } + ); + + AddIssue( $patron, $item_1->barcode, $now->clone->subtract( days => 1 ) ); + (undef, $message) = AddReturn( $item_1->barcode, $library->{branchcode}, undef, $now ); + is( $message->{WasReturned} && exists $message->{PrevDebarred}, 1, 'Previously debarred message for Addreturn when overdue'); }; subtest 'CanBookBeIssued + AutoReturnCheckedOutItems' => sub { -- 2.25.1