|
Lines 17-23
Link Here
|
| 17 |
|
17 |
|
| 18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
| 19 |
|
19 |
|
| 20 |
use Test::More tests => 15; |
20 |
use Test::More tests => 16; |
|
|
21 |
|
| 21 |
use DateTime; |
22 |
use DateTime; |
| 22 |
use DateTime::TimeZone; |
23 |
use DateTime::TimeZone; |
| 23 |
|
24 |
|
|
Lines 33-43
BEGIN {
Link Here
|
| 33 |
} |
34 |
} |
| 34 |
|
35 |
|
| 35 |
my $schema = Koha::Database->new->schema; |
36 |
my $schema = Koha::Database->new->schema; |
| 36 |
$schema->storage->txn_begin; |
37 |
my $dbh = C4::Context->dbh; |
|
|
38 |
my $builder = t::lib::TestBuilder->new; |
| 39 |
|
| 40 |
subtest 'exception_holidays() tests' => sub { |
| 41 |
|
| 42 |
plan tests => 1; |
| 43 |
|
| 44 |
$schema->storage->txn_begin; |
| 45 |
|
| 46 |
$dbh->do("DELETE FROM special_holidays"); |
| 47 |
# Clear cache |
| 48 |
Koha::Caches->get_instance->flush_all; |
| 49 |
|
| 50 |
# Artificially set timezone |
| 51 |
my $timezone = 'America/Santiago'; |
| 52 |
$ENV{TZ} = $timezone; |
| 53 |
use POSIX qw(tzset); |
| 54 |
tzset; |
| 55 |
|
| 56 |
my $branch = $builder->build( { source => 'Branch' } )->{branchcode}; |
| 57 |
my $calendar = Koha::Calendar->new( branchcode => $branch ); |
| 37 |
|
58 |
|
| 38 |
my $dbh = C4::Context->dbh(); |
59 |
C4::Calendar->new( branchcode => $branch )->insert_exception_holiday( |
|
|
60 |
day => 6, |
| 61 |
month => 9, |
| 62 |
year => 2015, |
| 63 |
title => 'Invalid date', |
| 64 |
description => 'Invalid date description', |
| 65 |
); |
| 66 |
|
| 67 |
my $exception_holiday = $calendar->exception_holidays->iterator->next; |
| 68 |
my $now_dt = DateTime->now; |
| 69 |
|
| 70 |
my $diff; |
| 71 |
eval { $diff = $calendar->days_between( $now_dt, $exception_holiday ) }; |
| 72 |
unlike( |
| 73 |
$@, |
| 74 |
qr/Invalid local time for date in time zone: America\/Santiago/, |
| 75 |
'Avoid invalid datetime due to DST' |
| 76 |
); |
| 77 |
|
| 78 |
$schema->storage->txn_rollback; |
| 79 |
}; |
| 80 |
|
| 81 |
$schema->storage->txn_begin; |
| 39 |
|
82 |
|
| 40 |
my $builder = t::lib::TestBuilder->new(); |
|
|
| 41 |
# Create two fresh branches for the tests |
83 |
# Create two fresh branches for the tests |
| 42 |
my $branch_1 = $builder->build({ source => 'Branch' })->{ branchcode }; |
84 |
my $branch_1 = $builder->build({ source => 'Branch' })->{ branchcode }; |
| 43 |
my $branch_2 = $builder->build({ source => 'Branch' })->{ branchcode }; |
85 |
my $branch_2 = $builder->build({ source => 'Branch' })->{ branchcode }; |
| 44 |
- |
|
|