Bugzilla – Attachment 60406 Details for
Bug 14146
Add option to add restriction period when checking-in several overdues for same patron
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 14146: Add tests for AddReturn + CumulativeRestrictionPeriods
Bug-14146-Add-tests-for-AddReturn--CumulativeRestr.patch (text/plain), 6.08 KB, created by
Jonathan Druart
on 2017-02-17 11:55:52 UTC
(
hide
)
Description:
Bug 14146: Add tests for AddReturn + CumulativeRestrictionPeriods
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2017-02-17 11:55:52 UTC
Size:
6.08 KB
patch
obsolete
>From 2f88ce336c53dc585cc619c6b28de1f48f524383 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Mon, 12 Dec 2016 16:04:42 +0100 >Subject: [PATCH] Bug 14146: Add tests for AddReturn + > CumulativeRestrictionPeriods > >Sponsored-by: Orex Digital >--- > t/db_dependent/Circulation.t | 130 ++++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 129 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t >index e3d4c8d..6a0ef95 100755 >--- a/t/db_dependent/Circulation.t >+++ b/t/db_dependent/Circulation.t >@@ -17,7 +17,7 @@ > > use Modern::Perl; > >-use Test::More tests => 91; >+use Test::More tests => 92; > > BEGIN { > require_ok('C4::Circulation'); >@@ -36,6 +36,7 @@ use C4::Reserves; > use C4::Overdues qw(UpdateFine CalcFine); > use Koha::DateUtils; > use Koha::Database; >+use Koha::IssuingRules; > use Koha::Subscriptions; > > my $schema = Koha::Database->schema; >@@ -1306,6 +1307,133 @@ subtest 'CanBookBeIssued + AllowMultipleIssuesOnABiblio' => sub { > is( keys(%$error) + keys(%$question) + keys(%$alerts), 0, 'No BIBLIO_ALREADY_ISSUED flag should be set if it is a subscription' ); > }; > >+subtest 'AddReturn + CumulativeRestrictionPeriods' => sub { >+ plan tests => 8; >+ >+ my $library = $builder->build( { source => 'Branch' } ); >+ my $patron = $builder->build( { source => 'Borrower' } ); >+ >+ # Add 2 items >+ my $biblioitem_1 = $builder->build( { source => 'Biblioitem' } ); >+ my $item_1 = $builder->build( >+ { >+ source => 'Item', >+ value => { >+ homebranch => $library->{branchcode}, >+ holdingbranch => $library->{branchcode}, >+ notforloan => 0, >+ itemlost => 0, >+ withdrawn => 0, >+ biblionumber => $biblioitem_1->{biblionumber} >+ } >+ } >+ ); >+ my $biblioitem_2 = $builder->build( { source => 'Biblioitem' } ); >+ my $item_2 = $builder->build( >+ { >+ source => 'Item', >+ value => { >+ homebranch => $library->{branchcode}, >+ holdingbranch => $library->{branchcode}, >+ notforloan => 0, >+ itemlost => 0, >+ withdrawn => 0, >+ biblionumber => $biblioitem_2->{biblionumber} >+ } >+ } >+ ); >+ >+ # And the issuing rule >+ Koha::IssuingRules->search->delete; >+ my $rule = Koha::IssuingRule->new( >+ { >+ categorycode => '*', >+ itemtype => '*', >+ branchcode => '*', >+ maxissueqty => 99, >+ issuelength => 1, >+ firstremind => 1, # 1 day of grace >+ finedays => 2, # 2 days of fine per day of overdue >+ lengthunit => 'days', >+ } >+ ); >+ $rule->store(); >+ >+ # Patron cannot issue item_1, he has overdues >+ my $five_days_ago = dt_from_string->subtract( days => 5 ); >+ my $ten_days_ago = dt_from_string->subtract( days => 10 ); >+ AddIssue( $patron, $item_1->{barcode}, $five_days_ago ); # Add an overdue >+ AddIssue( $patron, $item_2->{barcode}, $ten_days_ago ) >+ ; # Add another overdue >+ >+ t::lib::Mocks::mock_preference( 'CumulativeRestrictionPeriods', '0' ); >+ AddReturn( $item_1->{barcode}, $library->{branchcode}, >+ undef, undef, dt_from_string ); >+ my $debarments = Koha::Patron::Debarments::GetDebarments( >+ { borrowernumber => $patron->{borrowernumber}, type => 'SUSPENSION' } ); >+ is( scalar(@$debarments), 1 ); >+ >+ # FIXME Is it right? I'd have expected 5 * 2 - 1 instead >+ # Same for the others >+ my $expected_expiration = output_pref( >+ { >+ dt => dt_from_string->add( days => ( 5 - 1 ) * 2 ), >+ dateformat => 'sql', >+ dateonly => 1 >+ } >+ ); >+ is( $debarments->[0]->{expiration}, $expected_expiration ); >+ >+ AddReturn( $item_2->{barcode}, $library->{branchcode}, >+ undef, undef, dt_from_string ); >+ $debarments = Koha::Patron::Debarments::GetDebarments( >+ { borrowernumber => $patron->{borrowernumber}, type => 'SUSPENSION' } ); >+ is( scalar(@$debarments), 1 ); >+ $expected_expiration = output_pref( >+ { >+ dt => dt_from_string->add( days => ( 10 - 1 ) * 2 ), >+ dateformat => 'sql', >+ dateonly => 1 >+ } >+ ); >+ is( $debarments->[0]->{expiration}, $expected_expiration ); >+ >+ Koha::Patron::Debarments::DelUniqueDebarment( >+ { borrowernumber => $patron->{borrowernumber}, type => 'SUSPENSION' } ); >+ >+ t::lib::Mocks::mock_preference( 'CumulativeRestrictionPeriods', '1' ); >+ AddIssue( $patron, $item_1->{barcode}, $five_days_ago ); # Add an overdue >+ AddIssue( $patron, $item_2->{barcode}, $ten_days_ago ) >+ ; # Add another overdue >+ AddReturn( $item_1->{barcode}, $library->{branchcode}, >+ undef, undef, dt_from_string ); >+ $debarments = Koha::Patron::Debarments::GetDebarments( >+ { borrowernumber => $patron->{borrowernumber}, type => 'SUSPENSION' } ); >+ is( scalar(@$debarments), 1 ); >+ $expected_expiration = output_pref( >+ { >+ dt => dt_from_string->add( days => ( 5 - 1 ) * 2 ), >+ dateformat => 'sql', >+ dateonly => 1 >+ } >+ ); >+ is( $debarments->[0]->{expiration}, $expected_expiration ); >+ >+ AddReturn( $item_2->{barcode}, $library->{branchcode}, >+ undef, undef, dt_from_string ); >+ $debarments = Koha::Patron::Debarments::GetDebarments( >+ { borrowernumber => $patron->{borrowernumber}, type => 'SUSPENSION' } ); >+ is( scalar(@$debarments), 1 ); >+ $expected_expiration = output_pref( >+ { >+ dt => dt_from_string->add( days => ( 5 - 1 ) * 2 + ( 10 - 1 ) * 2 ), >+ dateformat => 'sql', >+ dateonly => 1 >+ } >+ ); >+ is( $debarments->[0]->{expiration}, $expected_expiration ); >+}; >+ > sub set_userenv { > my ( $library ) = @_; > C4::Context->set_userenv(0,0,0,'firstname','surname', $library->{branchcode}, $library->{branchname}, '', '', ''); >-- >2.1.4
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 14146
:
58128
|
58129
|
58130
|
58131
|
58149
|
60406
|
60407
|
60408
|
60409
|
61535
|
61536
|
61537
|
61538