Bug 11580: Add one more test and clear the cache
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Wed, 6 Sep 2017 15:52:46 +0000 (12:52 -0300)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Wed, 6 Sep 2017 15:52:48 +0000 (12:52 -0300)
Make sure we are not just returning J-1 and clear the cache before and
after the tests.

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
t/db_dependent/Circulation/CalcDateDue.t

index 98efd48..c6b6b52 100644 (file)
@@ -2,7 +2,7 @@
 
 use Modern::Perl;
 
-use Test::More tests => 6;
+use Test::More tests => 7;
 use Test::MockModule;
 use DBI;
 use DateTime;
@@ -36,6 +36,9 @@ Koha::Database->schema->resultset('Issuingrule')->create({
 t::lib::Mocks::mock_preference('ReturnBeforeExpiry', 1);
 t::lib::Mocks::mock_preference('useDaysMode', 'Days');
 
+my $cache           = Koha::Caches->get_instance();
+$cache->clear_from_cache('single_holidays');
+
 my $dateexpiry = '2013-01-01';
 
 my $borrower = {categorycode => 'B', dateexpiry => $dateexpiry};
@@ -66,6 +69,15 @@ $calendar->insert_single_holiday(
 );
 $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');
+$calendar->insert_single_holiday(
+    day             => 31,
+    month           => 12,
+    year            => 2012,
+    title           =>'holidayTest',
+    description     => 'holidayDesc'
+);
+$date = C4::Circulation::CalcDateDue( $start_date, $itemtype, $branchcode, $borrower );
+is($date, '2012-12-30T23:59:00', 'date expiry should be 2013-01-01 -2 day');
 
 
 $date = C4::Circulation::CalcDateDue( $start_date, $itemtype, $branchcode, $borrower, 1 );
@@ -83,4 +95,5 @@ is($date, '2013-02-' . (9 + $issuelength) . 'T23:59:00', "date expiry ( 9 + $iss
 $date = C4::Circulation::CalcDateDue( $start_date, $itemtype, $branchcode, $borrower, 1 );
 is($date, '2013-02-' . (9 + $renewalperiod) . 'T23:59:00', "date expiry ( 9 + $renewalperiod )");
 
+$cache->clear_from_cache('single_holidays');
 $schema->storage->txn_rollback;