Bugzilla – Attachment 66886 Details for
Bug 11580
If returnBeforeExpiry is on, holidays are not taken into account to calculate the due date
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 11580 - Fix expiry calculation and rewrite tests
Bug-11580---Fix-expiry-calculation-and-rewrite-tes.patch (text/plain), 4.77 KB, created by
Alex Arnaud
on 2017-09-06 15:38:18 UTC
(
hide
)
Description:
Bug 11580 - Fix expiry calculation and rewrite tests
Filename:
MIME Type:
Creator:
Alex Arnaud
Created:
2017-09-06 15:38:18 UTC
Size:
4.77 KB
patch
obsolete
>From abf3fc453b6629359262ca398bcca3976824e754 Mon Sep 17 00:00:00 2001 >From: Alex Arnaud <alex.arnaud@biblibre.com> >Date: Wed, 6 Sep 2017 15:36:15 +0000 >Subject: [PATCH] Bug 11580 - Fix expiry calculation and rewrite tests > >--- > C4/Circulation.pm | 6 ++++-- > t/db_dependent/Circulation/CalcDateDue.t | 19 +++++++++++++++++-- > t/db_dependent/Circulation/dateexpiry.t | 22 +--------------------- > 3 files changed, 22 insertions(+), 25 deletions(-) > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index 75c3814..e4fee8f 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -3511,9 +3511,11 @@ sub CalcDateDue { > } > } > if ( C4::Context->preference('useDaysMode') ne 'Days' ) { >- # Don't return on a closed day > my $calendar = Koha::Calendar->new( branchcode => $branch ); >- $datedue = $calendar->prev_open_day( $datedue ); >+ if ( $calendar->is_holiday($datedue) ) { >+ # Don't return on a closed day >+ $datedue = $calendar->prev_open_day( $datedue ); >+ } > } > } > >diff --git a/t/db_dependent/Circulation/CalcDateDue.t b/t/db_dependent/Circulation/CalcDateDue.t >index e533806..98efd48 100644 >--- a/t/db_dependent/Circulation/CalcDateDue.t >+++ b/t/db_dependent/Circulation/CalcDateDue.t >@@ -2,12 +2,13 @@ > > use Modern::Perl; > >-use Test::More tests => 5; >+use Test::More tests => 6; > use Test::MockModule; > use DBI; > use DateTime; > use t::lib::Mocks; > use t::lib::TestBuilder; >+use C4::Calendar; > > use_ok('C4::Circulation'); > >@@ -51,7 +52,21 @@ t::lib::Mocks::mock_preference('useDaysMode', 'noDays'); > $borrower = {categorycode => 'B', dateexpiry => $dateexpiry}; > $start_date = DateTime->new({year => 2013, month => 2, day => 9}); > $date = C4::Circulation::CalcDateDue( $start_date, $itemtype, $branchcode, $borrower ); >-is($date, $dateexpiry . 'T23:59:00', 'date expiry'); >+is($date, $dateexpiry . 'T23:59:00', 'date expiry with useDaysMode to noDays'); >+ >+# Let's add a special holiday on 2013-01-01. With ReturnBeforeExpiry and >+# useDaysMode different from 'Days', return should forward the dateexpiry. >+my $calendar = C4::Calendar->new(branchcode => $branchcode); >+$calendar->insert_single_holiday( >+ day => 1, >+ month => 1, >+ year => 2013, >+ title =>'holidayTest', >+ description => 'holidayDesc' >+); >+$date = C4::Circulation::CalcDateDue( $start_date, $itemtype, $branchcode, $borrower ); >+is($date, '2012-12-31T23:59:00', 'date expiry should be 2013-01-01 -1 day'); >+ > > $date = C4::Circulation::CalcDateDue( $start_date, $itemtype, $branchcode, $borrower, 1 ); > >diff --git a/t/db_dependent/Circulation/dateexpiry.t b/t/db_dependent/Circulation/dateexpiry.t >index 4ed3505..dbb7e0b 100644 >--- a/t/db_dependent/Circulation/dateexpiry.t >+++ b/t/db_dependent/Circulation/dateexpiry.t >@@ -23,7 +23,6 @@ use Test::More tests => 2; > use C4::Members; > use Koha::DateUtils; > use Koha::Database; >-use C4::Calendar; > > use t::lib::TestBuilder; > use t::lib::Mocks qw( mock_preference ); >@@ -40,7 +39,7 @@ subtest 'Tests for CanBookBeIssued related to dateexpiry' => sub { > can_book_be_issued(); > }; > subtest 'Tests for CalcDateDue related to dateexpiry' => sub { >- plan tests => 5; >+ plan tests => 4; > calc_date_due(); > }; > >@@ -83,7 +82,6 @@ sub can_book_be_issued { > > sub calc_date_due { > t::lib::Mocks::mock_preference( 'ReturnBeforeExpiry', 1 ); >- t::lib::Mocks::mock_preference( 'useDaysMode', 'Days' ); > > # this triggers the compare between expiry and due date > >@@ -118,24 +116,6 @@ sub calc_date_due { > $d = C4::Circulation::CalcDateDue( $today, $item->{itype}, $branch->{branchcode}, $patron ); > my $t2 = time; > is( ref $d eq "DateTime" && $t2 - $t1 < 1, 1, "CalcDateDue with expiry in year 9876 in " . sprintf( "%6.4f", $t2 - $t1 ) . " seconds." ); >- >- # fifth test takes account of closed days >- $d = C4::Circulation::CalcDateDue( $today, $item->{itype}, $branch->{branchcode}, $patron ); >- t::lib::Mocks::mock_preference( 'useDaysMode', 'Datedue' ); >- my $calendar = C4::Calendar->new(branchcode => $branch->{branchcode}); >- $calendar->insert_single_holiday( >- day => $d->day(), >- month => $d->month(), >- year => $d->year(), >- title =>'holidayTest', >- description => 'holidayDesc' >- ); >- $calendar->delete_holiday(weekday => $d->day_of_week() - 1, day => $d->day()-1, month =>$d->month(), year=>$d->year() ); >- $d2 = C4::Circulation::CalcDateDue( $today, $item->{itype}, $branch->{branchcode}, $patron ); >- $d2->add(days => 1); >- $d->truncate( to => 'day' ); >- $d2->truncate( to => 'day' ); >- is ( DateTime->compare( $d, $d2) == 0, 1, "no problem with closed days"); > } > > $schema->storage->txn_rollback; >-- >2.7.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 11580
:
57562
|
58740
|
60621
|
64681
|
65779
|
65780
|
66705
|
66706
|
66707
| 66886 |
66888