|
Lines 5-11
use DateTime;
Link Here
|
| 5 |
use DateTime::TimeZone; |
5 |
use DateTime::TimeZone; |
| 6 |
|
6 |
|
| 7 |
use C4::Context; |
7 |
use C4::Context; |
| 8 |
use Test::More tests => 8; |
8 |
use Test::More tests => 11; |
| 9 |
|
9 |
|
| 10 |
BEGIN { use_ok('Koha::Calendar'); } |
10 |
BEGIN { use_ok('Koha::Calendar'); } |
| 11 |
BEGIN { use_ok('C4::Calendar'); } |
11 |
BEGIN { use_ok('C4::Calendar'); } |
|
Lines 39-45
my $newyear = DateTime->new(
Link Here
|
| 39 |
day => 1, |
39 |
day => 1, |
| 40 |
); |
40 |
); |
| 41 |
|
41 |
|
|
|
42 |
my $special_holiday = DateTime->new( |
| 43 |
year => 2012, |
| 44 |
month => 11, |
| 45 |
day => 16 |
| 46 |
); |
| 47 |
|
| 48 |
my $exception_sunday = DateTime->new( |
| 49 |
year => 2012, |
| 50 |
month => 11, |
| 51 |
day => 11 |
| 52 |
); |
| 53 |
|
| 42 |
is( $koha_calendar->is_holiday($sunday), 1, 'Sunday is a closed day' ); |
54 |
is( $koha_calendar->is_holiday($sunday), 1, 'Sunday is a closed day' ); |
| 43 |
is( $koha_calendar->is_holiday($monday), 0, 'Monday is not a closed day' ); |
55 |
is( $koha_calendar->is_holiday($monday), 0, 'Monday is not a closed day' ); |
| 44 |
is( $koha_calendar->is_holiday($christmas), 1, 'Christmas is a closed day' ); |
56 |
is( $koha_calendar->is_holiday($christmas), 1, 'Christmas is a closed day' ); |
| 45 |
is( $koha_calendar->is_holiday($newyear), 1, 'New Years day is a closed day' ); |
57 |
is( $koha_calendar->is_holiday($newyear), 1, 'New Years day is a closed day' ); |
| 46 |
- |
58 |
is( $koha_calendar->is_holiday($special_holiday), 1, 'Sample single holiday is a closed day' ); |
|
|
59 |
is( $koha_calendar->is_holiday($exception_sunday), 0, 'Sample sunday exception is not a closed day' ); |
| 60 |
|
| 61 |
|
| 62 |
# is_holiday truncates the date to day as that's |
| 63 |
# how they are stored/retreived from db. This is a |
| 64 |
# regression test for a bug introduced by 8966, fixed in 8800 |
| 65 |
my $special_holiday_time = DateTime->new( |
| 66 |
year => 2012, |
| 67 |
month => 11, |
| 68 |
day => 16, |
| 69 |
hour => 11, |
| 70 |
minute => 2 |
| 71 |
); |
| 72 |
|
| 73 |
is( $koha_calendar->is_holiday($special_holiday_time), |
| 74 |
$koha_calendar->is_holiday($special_holiday) , |
| 75 |
'is_holiday should truncate the date for holiday validation' ); |
| 76 |
|