Bugzilla – Attachment 110764 Details for
Bug 14784
Missing checkin message for debarred patrons when issuing rules 'fine days = 0'
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 14784: Add tests
Bug-14784-Add-tests.patch (text/plain), 7.37 KB, created by
Kyle M Hall
on 2020-09-25 14:40:04 UTC
(
hide
)
Description:
Bug 14784: Add tests
Filename:
MIME Type:
Creator:
Kyle M Hall
Created:
2020-09-25 14:40:04 UTC
Size:
7.37 KB
patch
obsolete
>From c36dffd9370ff0da1ffeb2ab93d496f55303bf46 Mon Sep 17 00:00:00 2001 >From: Maryse Simard <maryse.simard@inlibro.com> >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. > >Signed-off-by: Arthur Suzuki <arthur.suzuki@biblibre.com> > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > C4/Circulation.pm | 2 +- > t/db_dependent/Circulation.t | 65 ++++++++++++++++++++++++++++++++++-- > 2 files changed, 64 insertions(+), 3 deletions(-) > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index fd59a15d19..b0a86b6938 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -2343,7 +2343,7 @@ sub _calculate_new_debar_dt { > if ( C4::Context->preference('CumulativeRestrictionPeriods') and $borrower->{debarred} ) { > my $debarment = @{ GetDebarments( { borrowernumber => $borrower->{borrowernumber}, type => 'SUSPENSION' } ) }[0]; > if ( $debarment ) { >- $return_date = dt_from_string( $debarment->{expiration}, 'sql' ); >+ $return_date = dt_from_string( $debarment->{return_date}, 'sql' ); > $has_been_extended = 1; > } > } >diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t >index f26f2f3255..ccb666fcb9 100755 >--- a/t/db_dependent/Circulation.t >+++ b/t/db_dependent/Circulation.t >@@ -2088,7 +2088,7 @@ subtest 'AddReturn + CumulativeRestrictionPeriods' => sub { > is( scalar(@$debarments), 1 ); > $expected_expiration = output_pref( > { >- dt => $now->clone->add( days => ( 5 - 1 ) * 2 + ( 10 - 1 ) * 2 ), >+ dt => $now->clone->add( days => ( 10 - 1 ) * 2 ), > dateformat => 'sql', > dateonly => 1 > } >@@ -2097,7 +2097,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} } } ); >@@ -2136,6 +2136,10 @@ subtest 'AddReturn + suspension_chargeperiod' => sub { > # We want to charge 2 days every day, without grace > # With 5 days of overdue: 5 * Z > my $expected_expiration = $now->clone->add( days => ( 5 * 2 ) / 1 ); >+ Koha::Patron::Debarments::AddUniqueDebarment( { >+ borrowernumber => $patron->{borrowernumber}, >+ type => 'SUSPENSION', >+ expiration => $expected_expiration } ); > test_debarment_on_checkout( > { > item => $item_1, >@@ -2159,6 +2163,10 @@ subtest 'AddReturn + suspension_chargeperiod' => sub { > ); > > $expected_expiration = $now->clone->add( days => floor( 5 * 2 ) / 2 ); >+ Koha::Patron::Debarments::AddUniqueDebarment( { >+ borrowernumber => $patron->{borrowernumber}, >+ type => 'SUSPENSION', >+ expiration => $expected_expiration } ); > test_debarment_on_checkout( > { > item => $item_1, >@@ -2183,6 +2191,10 @@ subtest 'AddReturn + suspension_chargeperiod' => sub { > } > ); > $expected_expiration = $now->clone->add( days => floor( ( ( 5 - 1 ) / 3 ) * 2 ) ); >+ Koha::Patron::Debarments::AddUniqueDebarment( { >+ borrowernumber => $patron->{borrowernumber}, >+ type => 'SUSPENSION', >+ expiration => $expected_expiration } ); > test_debarment_on_checkout( > { > item => $item_1, >@@ -2222,6 +2234,10 @@ subtest 'AddReturn + suspension_chargeperiod' => sub { > ); > # With 5 days of overdue, only 4 (x finedays=2) days must charged (one was an holiday) > $expected_expiration = $now->clone->add( days => floor( ( ( 5 - 0 - 1 ) / 1 ) * 2 ) ); >+ Koha::Patron::Debarments::AddUniqueDebarment( { >+ borrowernumber => $patron->{borrowernumber}, >+ type => 'SUSPENSION', >+ expiration => $expected_expiration } ); > test_debarment_on_checkout( > { > item => $item_1, >@@ -2244,6 +2260,10 @@ subtest 'AddReturn + suspension_chargeperiod' => sub { > > # Same as above, but we should skip D+2 > $expected_expiration = $now->clone->add( days => floor( ( ( 5 - 0 - 1 ) / 1 ) * 2 ) + 1 ); >+ Koha::Patron::Debarments::AddUniqueDebarment( { >+ borrowernumber => $patron->{borrowernumber}, >+ type => 'SUSPENSION', >+ expiration => $expected_expiration } ); > test_debarment_on_checkout( > { > item => $item_1, >@@ -2264,6 +2284,10 @@ subtest 'AddReturn + suspension_chargeperiod' => sub { > description => 'holidayDesc on expiration date' > ); > # Expiration date will be the day after >+ Koha::Patron::Debarments::AddUniqueDebarment( { >+ borrowernumber => $patron->{borrowernumber}, >+ type => 'SUSPENSION', >+ expiration => $expected_expiration->clone->add( days => 1 ) } ); > test_debarment_on_checkout( > { > item => $item_1, >@@ -2274,6 +2298,10 @@ subtest 'AddReturn + suspension_chargeperiod' => sub { > } > ); > >+ Koha::Patron::Debarments::AddUniqueDebarment( { >+ borrowernumber => $patron->{borrowernumber}, >+ type => 'SUSPENSION', >+ expiration => $now->clone->add(days => 5 + (5 * 2 - 1) ) } ); > test_debarment_on_checkout( > { > item => $item_1, >@@ -2284,6 +2312,10 @@ subtest 'AddReturn + suspension_chargeperiod' => sub { > } > ); > >+ Koha::Patron::Debarments::AddUniqueDebarment( { >+ borrowernumber => $patron->{borrowernumber}, >+ type => 'SUSPENSION', >+ expiration => $now->clone->add(days => 5 + (4 * 2 - 1) ) } ); > test_debarment_on_checkout( > { > item => $item_1, >@@ -2295,6 +2327,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.24.1 (Apple Git-126)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 14784
:
42354
|
49282
|
49283
|
49377
|
58227
|
67102
|
68132
|
69295
|
69296
|
77683
|
79826
|
106808
|
106809
|
107487
|
110485
|
110514
|
110763
|
110764
|
112724
|
112725
|
136040
|
136327
|
137727
|
137728
|
145320
|
145321