From 08c47cbfe2517ef36b15a16a94227b854be5eeb9 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Tue, 10 Dec 2013 18:11:37 +0000 Subject: [PATCH] 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 --- Koha/Calendar.pm | 1 + t/db_dependent/Holidays.t | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Koha/Calendar.pm b/Koha/Calendar.pm index 4e799e5ace..293ba88c90 100644 --- a/Koha/Calendar.pm +++ b/Koha/Calendar.pm @@ -341,6 +341,7 @@ sub add_holiday { push @dt, $new_dt; $self->{single_holidays} = DateTime::Set->from_datetimes( dates => \@dt ); + $single_holidays = $self->{single_holidays}; return; } diff --git a/t/db_dependent/Holidays.t b/t/db_dependent/Holidays.t index 5c4da1be5a..9d4110540b 100755 --- a/t/db_dependent/Holidays.t +++ b/t/db_dependent/Holidays.t @@ -5,7 +5,7 @@ use DateTime; use DateTime::TimeZone; use C4::Context; -use Test::More tests => 8; +use Test::More tests => 10; BEGIN { use_ok('Koha::Calendar'); } BEGIN { use_ok('C4::Calendar'); } @@ -43,3 +43,13 @@ 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' ); + -- 2.39.5