Bugzilla – Attachment 61535 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.02 KB, created by
Marcel de Rooy
on 2017-03-23 13:23:19 UTC
(
hide
)
Description:
Bug 14146: Add tests for AddReturn + CumulativeRestrictionPeriods
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2017-03-23 13:23:19 UTC
Size:
6.02 KB
patch
obsolete
>From 7af4def8d4c376de13191f5f5ae252980d910497 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 >Content-Type: text/plain; charset=utf-8 > >Sponsored-by: Orex Digital > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > t/db_dependent/Circulation.t | 128 +++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 128 insertions(+) > >diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t >index 352abf8..43f6dd6 100755 >--- a/t/db_dependent/Circulation.t >+++ b/t/db_dependent/Circulation.t >@@ -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; >@@ -1414,6 +1415,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