5 use DateTime::TimeZone;
8 use Test::More tests => 9;
10 BEGIN { use_ok('Koha::Calendar'); }
12 my $cal = Koha::Calendar->new( TEST_MODE => 1 );
14 isa_ok( $cal, 'Koha::Calendar', 'Calendar class returned' );
16 my $saturday = DateTime->new(
20 time_zone => 'Europe/London',
22 my $sunday = DateTime->new(
26 time_zone => 'Europe/London',
28 my $monday = DateTime->new(
32 time_zone => 'Europe/London',
34 my $bloomsday = DateTime->new(
38 time_zone => 'Europe/London',
39 ); # should be a holiday
40 my $special = DateTime->new(
44 time_zone => 'Europe/London',
45 ); # should be a holiday
46 my $notspecial = DateTime->new(
50 time_zone => 'Europe/London',
51 ); # should NOT be a holiday
52 is( $cal->is_holiday($sunday), 1, 'Sunday is a closed day' ); # wee free test;
53 is( $cal->is_holiday($monday), 0, 'Monday is not a closed day' ); # alas
54 is( $cal->is_holiday($bloomsday), 1, 'month/day closed day test' );
55 is( $cal->is_holiday($special), 1, 'special closed day test' );
56 is( $cal->is_holiday($notspecial), 0, 'open day test' );
58 my $dt = $cal->addDate( $saturday, 1, 'days' );
59 is( $dt->day_of_week, 1, 'addDate skips closed Sunday' );
61 $dt = $cal->addDate( $bloomsday, -1 );
62 cmp_ok( $dt->ymd(), 'cmp', '2011-06-15', 'Negative call to addDate' );