5 use DateTime::TimeZone;
9 use Test::More tests => 12;
11 BEGIN { use_ok('Koha::Calendar'); }
12 BEGIN { use_ok('C4::Calendar'); }
14 my $dbh = C4::Context->dbh();
16 $dbh->{AutoCommit} = 0;
17 $dbh->{RaiseError} = 1;
19 my $branchcode = 'MPL';
21 my $koha_calendar = Koha::Calendar->new( branchcode => $branchcode );
22 my $c4_calendar = C4::Calendar->new( branchcode => $branchcode );
24 isa_ok( $koha_calendar, 'Koha::Calendar', 'Koha::Calendar class returned' );
25 isa_ok( $c4_calendar, 'C4::Calendar', 'C4::Calendar class returned' );
27 my $sunday = DateTime->new(
32 my $monday = DateTime->new(
37 my $christmas = DateTime->new(
42 my $newyear = DateTime->new(
48 is( $koha_calendar->is_holiday($sunday), 1, 'Sunday is a closed day' );
49 is( $koha_calendar->is_holiday($monday), 0, 'Monday is not a closed day' );
50 is( $koha_calendar->is_holiday($christmas), 1, 'Christmas is a closed day' );
51 is( $koha_calendar->is_holiday($newyear), 1, 'New Years day is a closed day' );
53 $dbh->do("DELETE FROM repeatable_holidays");
54 $dbh->do("DELETE FROM special_holidays");
56 my $custom_holiday = DateTime->new(
61 is( $koha_calendar->is_holiday($custom_holiday), 0, '2013-11-10 does not start off as a holiday' );
62 $koha_calendar->add_holiday($custom_holiday);
63 is( $koha_calendar->is_holiday($custom_holiday), 1, 'able to add holiday for testing' );
65 my $today = dt_from_string();
66 C4::Calendar->new( branchcode => 'CPL' )->insert_single_holiday(
68 month => $today->month(),
69 year => $today->year(),
71 description => "$today",
73 is( Koha::Calendar->new( branchcode => 'CPL' )->is_holiday( $today ), 1, "Today is a holiday for CPL" );
74 is( Koha::Calendar->new( branchcode => 'MPL' )->is_holiday( $today ), 0, "Today is not a holiday for MPL");