Bugzilla – Attachment 64681 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 : Added unit test
BUG-11580--Added-unit-test.patch (text/plain), 2.67 KB, created by
Baptiste Wojtkowski (bwoj)
on 2017-06-27 15:30:36 UTC
(
hide
)
Description:
BUG 11580 : Added unit test
Filename:
MIME Type:
Creator:
Baptiste Wojtkowski (bwoj)
Created:
2017-06-27 15:30:36 UTC
Size:
2.67 KB
patch
obsolete
>From 2e2a645578d54759295ac4280abad6527edc09aa Mon Sep 17 00:00:00 2001 >From: Baptiste Wojtkowski <baptiste.wojtkowski@biblibre.com> >Date: Thu, 23 Feb 2017 16:21:05 +0000 >Subject: [PATCH] BUG 11580 : Added unit test > >Added one unit test when the syspref useDaysMode is active. >This does not move code anymore >--- > t/db_dependent/Circulation/dateexpiry.t | 24 +++++++++++++++++++++++- > 1 file changed, 23 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Circulation/dateexpiry.t b/t/db_dependent/Circulation/dateexpiry.t >index 57f306e..6f231be 100644 >--- a/t/db_dependent/Circulation/dateexpiry.t >+++ b/t/db_dependent/Circulation/dateexpiry.t >@@ -23,6 +23,7 @@ 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 ); >@@ -39,7 +40,7 @@ subtest 'Tests for CanBookBeIssued related to dateexpiry' => sub { > can_book_be_issued(); > }; > subtest 'Tests for CalcDateDue related to dateexpiry' => sub { >- plan tests => 4; >+ plan tests => 5; > calc_date_due(); > }; > >@@ -82,6 +83,7 @@ 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 > >@@ -116,6 +118,26 @@ 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' ); >+ warn Data::Dumper::Dumper($d->datetime()); >+ warn Data::Dumper::Dumper($d2->datetime()); >+ 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