Bug 5549 : Make Koha::Calendar testable
[koha.git] / t / Kalendar.t
1 use strict;
2 use warnings;
3 use 5.010;
4 use DateTime;
5 use DateTime::TimeZone;
6
7 use C4::Context;
8 use Test::More tests => 7;    # last test to print
9
10 BEGIN { use_ok('Koha::Calendar'); }
11
12 my $cal = Koha::Calendar->new( TEST_MODE => 1);
13
14 isa_ok( $cal, 'Koha::Calendar', 'Calendar class returned');
15
16 my $sunday = DateTime->new(
17     year => 2011,
18     month => 6,
19     day  => 26,
20     time_zone => 'Europe/London',
21 );
22 my $monday = DateTime->new(
23     year => 2011,
24     month => 6,
25     day  => 27,
26     time_zone => 'Europe/London',
27 );
28 my $bloomsday = DateTime->new(
29     year => 2011,
30     month => 6,
31     day  => 16,
32     time_zone => 'Europe/London',
33 ); # should be a holiday
34 my $special = DateTime->new(
35     year => 2011,
36     month => 6,
37     day  => 1,
38     time_zone => 'Europe/London',
39 ); # should be a holiday
40 my $notspecial = DateTime->new(
41     year => 2011,
42     month => 6,
43     day  => 2,
44     time_zone => 'Europe/London',
45 ); # should NOT be a holiday
46 is ( $cal->is_holiday($sunday), 1, 'Sunday is a closed day');# wee free test;
47 is ( $cal->is_holiday($monday), 0, 'Monday is not a closed day');# alas
48 is ( $cal->is_holiday($bloomsday), 1, 'month/day closed day test');
49 is ( $cal->is_holiday($special), 1, 'special closed day test');
50 is ( $cal->is_holiday($notspecial), 0, 'open day test');