Bugzilla – Attachment 64807 Details for
Bug 17680
C4::Circulation - Replace GetItemIssue with Koha::Checkouts
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17680: Add few tests for AddReturn when overdue
Bug-17680-Add-few-tests-for-AddReturn-when-overdue.patch (text/plain), 4.79 KB, created by
Jonathan Druart
on 2017-07-05 16:15:17 UTC
(
hide
)
Description:
Bug 17680: Add few tests for AddReturn when overdue
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2017-07-05 16:15:17 UTC
Size:
4.79 KB
patch
obsolete
>From 551db3f50d2b0c8ae5ad36626ccf5939db7240d3 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 15 Jun 2017 12:18:49 -0300 >Subject: [PATCH] Bug 17680: Add few tests for AddReturn when overdue > >To make sure the last patch fixes the issue >--- > t/db_dependent/Circulation.t | 79 +++++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 78 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t >index 7bbb25bf93..d1cbc36200 100755 >--- a/t/db_dependent/Circulation.t >+++ b/t/db_dependent/Circulation.t >@@ -17,7 +17,7 @@ > > use Modern::Perl; > >-use Test::More tests => 95; >+use Test::More tests => 96; > > use DateTime; > >@@ -1632,6 +1632,83 @@ subtest 'AddReturn + CumulativeRestrictionPeriods' => sub { > is( $debarments->[0]->{expiration}, $expected_expiration ); > }; > >+subtest 'AddReturn | is_overdue' => sub { >+ plan tests => 5; >+ >+ t::lib::Mocks::mock_preference('CalculateFinesOnReturn', 1); >+ t::lib::Mocks::mock_preference('finesMode', 'production'); >+ t::lib::Mocks::mock_preference('MaxFine', '100'); >+ >+ my $library = $builder->build( { source => 'Branch' } ); >+ my $patron = $builder->build( { source => 'Borrower' } ); >+ >+ my $biblioitem = $builder->build( { source => 'Biblioitem' } ); >+ my $item = $builder->build( >+ { >+ source => 'Item', >+ value => { >+ homebranch => $library->{branchcode}, >+ holdingbranch => $library->{branchcode}, >+ notforloan => 0, >+ itemlost => 0, >+ withdrawn => 0, >+ biblionumber => $biblioitem->{biblionumber}, >+ } >+ } >+ ); >+ >+ Koha::IssuingRules->search->delete; >+ my $rule = Koha::IssuingRule->new( >+ { >+ categorycode => '*', >+ itemtype => '*', >+ branchcode => '*', >+ maxissueqty => 99, >+ issuelength => 6, >+ lengthunit => 'days', >+ fine => 1, # Charge 1 every day of overdue >+ chargeperiod => 1, >+ } >+ ); >+ $rule->store(); >+ >+ my $one_day_ago = dt_from_string->subtract( days => 1 ); >+ my $five_days_ago = dt_from_string->subtract( days => 5 ); >+ my $ten_days_ago = dt_from_string->subtract( days => 10 ); >+ $patron = Koha::Patrons->find( $patron->{borrowernumber} ); >+ >+ # No date specify, today will be used >+ AddIssue( $patron->unblessed, $item->{barcode}, $ten_days_ago ); # date due was 10d ago >+ AddReturn( $item->{barcode}, $library->{branchcode} ); >+ is( int($patron->account->balance()), 10, 'Patron should have a charge of 10 (10 days x 1)' ); >+ Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber })->delete; >+ >+ # specify return date 5 days before => no overdue >+ AddIssue( $patron->unblessed, $item->{barcode}, $five_days_ago ); # date due was 5d ago >+ AddReturn( $item->{barcode}, $library->{branchcode}, undef, undef, $ten_days_ago ); >+ is( int($patron->account->balance()), 0, 'AddReturn: pass return_date => no overdue' ); >+ Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber })->delete; >+ >+ # specify return date 5 days later => overdue >+ AddIssue( $patron->unblessed, $item->{barcode}, $ten_days_ago ); # date due was 10d ago >+ AddReturn( $item->{barcode}, $library->{branchcode}, undef, undef, $five_days_ago ); >+ is( int($patron->account->balance()), 5, 'AddReturn: pass return_date => overdue' ); >+ Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber })->delete; >+ >+ # specify dropbox date 5 days before => no overdue >+ AddIssue( $patron->unblessed, $item->{barcode}, $five_days_ago ); # date due was 5d ago >+ AddReturn( $item->{barcode}, $library->{branchcode}, undef, 1, undef, $ten_days_ago ); >+ is( int($patron->account->balance()), 0, 'AddReturn: pass return_date => no overdue' ); >+ Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber })->delete; >+ >+ # specify dropbox date 5 days later => overdue, or... not >+ AddIssue( $patron->unblessed, $item->{barcode}, $ten_days_ago ); # date due was 10d ago >+ AddReturn( $item->{barcode}, $library->{branchcode}, undef, 1, undef, $five_days_ago ); >+ is( int($patron->account->balance()), 0, 'AddReturn: pass return_date => no overdue in dropbox mode' ); # FIXME? This is weird, the FU fine is created ( _CalculateAndUpdateFine > C4::Overdues::UpdateFine ) then remove later (in _FixOverduesOnReturn). Looks like it is a feature >+ Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber })->delete; >+ >+}; >+ > sub set_userenv { > my ( $library ) = @_; > C4::Context->set_userenv(0,0,0,'firstname','surname', $library->{branchcode}, $library->{branchname}, '', '', ''); >-- >2.11.0
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 17680
:
57787
|
57788
|
57789
|
57847
|
58431
|
58432
|
58433
|
58501
|
58918
|
58919
|
58920
|
61761
|
61762
|
61763
|
62034
|
62086
|
62102
|
62103
|
62104
|
64257
|
64258
|
64259
|
64284
|
64337
|
64805
|
64806
|
64807
|
64833
|
64866
|
64867
|
64868
|
64869
|
64870
|
64871
|
64925
|
64926
|
64927
|
64928
|
64929
|
64930
|
64931
|
65302
|
65310