Koha/t/db_dependent/Holidays.t
Galen Charlton 08c47cbfe2 Bug 11112: (follow-up) repair Koha::Calendar->add_holiday()
This patch ensures that the package-level cache is updated
when add_holiday() is used.  Note that except for the test
case added by this patch, there doesn't seem to be anything
that actually calls ->add_holiday(); it may be better to remove it.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
2013-12-10 18:19:15 +00:00

55 lines
1.5 KiB
Perl
Executable file

use strict;
use warnings;
use 5.010;
use DateTime;
use DateTime::TimeZone;
use C4::Context;
use Test::More tests => 10;
BEGIN { use_ok('Koha::Calendar'); }
BEGIN { use_ok('C4::Calendar'); }
my $branchcode = 'MPL';
my $koha_calendar = Koha::Calendar->new( branchcode => $branchcode );
my $c4_calendar = C4::Calendar->new( branchcode => $branchcode );
isa_ok( $koha_calendar, 'Koha::Calendar', 'Koha::Calendar class returned' );
isa_ok( $c4_calendar, 'C4::Calendar', 'C4::Calendar class returned' );
my $sunday = DateTime->new(
year => 2011,
month => 6,
day => 26,
);
my $monday = DateTime->new(
year => 2011,
month => 6,
day => 27,
);
my $christmas = DateTime->new(
year => 2032,
month => 12,
day => 25,
);
my $newyear = DateTime->new(
year => 2035,
month => 1,
day => 1,
);
is( $koha_calendar->is_holiday($sunday), 1, 'Sunday is a closed day' );
is( $koha_calendar->is_holiday($monday), 0, 'Monday is not a closed day' );
is( $koha_calendar->is_holiday($christmas), 1, 'Christmas is a closed day' );
is( $koha_calendar->is_holiday($newyear), 1, 'New Years day is a closed day' );
my $custom_holiday = DateTime->new(
year => 2013,
month => 11,
day => 12,
);
is( $koha_calendar->is_holiday($custom_holiday), 0, '2013-11-10 does not start off as a holiday' );
$koha_calendar->add_holiday($custom_holiday);
is( $koha_calendar->is_holiday($custom_holiday), 1, 'able to add holiday for testing' );