5 use DateTime::TimeZone;
9 use Test::More tests => 12;
11 BEGIN { use_ok('Koha::Calendar'); }
12 BEGIN { use_ok('C4::Calendar'); }
14 my $branchcode = 'MPL';
16 my $koha_calendar = Koha::Calendar->new( branchcode => $branchcode );
17 my $c4_calendar = C4::Calendar->new( branchcode => $branchcode );
19 isa_ok( $koha_calendar, 'Koha::Calendar', 'Koha::Calendar class returned' );
20 isa_ok( $c4_calendar, 'C4::Calendar', 'C4::Calendar class returned' );
22 my $sunday = DateTime->new(
27 my $monday = DateTime->new(
32 my $christmas = DateTime->new(
37 my $newyear = DateTime->new(
43 is( $koha_calendar->is_holiday($sunday), 1, 'Sunday is a closed day' );
44 is( $koha_calendar->is_holiday($monday), 0, 'Monday is not a closed day' );
45 is( $koha_calendar->is_holiday($christmas), 1, 'Christmas is a closed day' );
46 is( $koha_calendar->is_holiday($newyear), 1, 'New Years day is a closed day' );
48 my $custom_holiday = DateTime->new(
53 is( $koha_calendar->is_holiday($custom_holiday), 0, '2013-11-10 does not start off as a holiday' );
54 $koha_calendar->add_holiday($custom_holiday);
55 is( $koha_calendar->is_holiday($custom_holiday), 1, 'able to add holiday for testing' );
57 my $today = dt_from_string();
58 C4::Calendar->new( branchcode => 'CPL' )->insert_single_holiday(
60 month => $today->month(),
61 year => $today->year(),
63 description => "$today",
65 is( Koha::Calendar->new( branchcode => 'CPL' )->is_holiday( $today ), 1, "Today is a holiday for CPL" );
66 is( Koha::Calendar->new( branchcode => 'MPL' )->is_holiday( $today ), 0, "Today is not a holiday for MPL");