From dcabf5430a229f237d0250e6dd2e6c651738fe7d Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Thu, 16 Jul 2020 19:30:28 +0000 Subject: [PATCH] Bug 26000: Unit test --- t/db_dependent/Holidays.t | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/t/db_dependent/Holidays.t b/t/db_dependent/Holidays.t index 023c4a89ff..011e52400f 100755 --- a/t/db_dependent/Holidays.t +++ b/t/db_dependent/Holidays.t @@ -39,10 +39,39 @@ my $builder = t::lib::TestBuilder->new; subtest 'exception_holidays() tests' => sub { - plan tests => 1; + plan tests => 2; $schema->storage->txn_begin; + my $branch = $builder->build( { source => 'Branch' } )->{branchcode}; + my $branch2 = $builder->build( { source => 'Branch' } )->{branchcode}; + + $dbh->do("DELETE FROM special_holidays"); + # Clear cache + Koha::Caches->get_instance->flush_all; + + my $holiday2add = dt_from_string("2030-07-07"); + C4::Calendar->new( branchcode => $branch )->insert_day_month_holiday( + day => $holiday2add->day(), + month => $holiday2add->month(), + year => $holiday2add->year(), + title => 'A holiday', + description => "This is a holiday, for now", + ); + + C4::Calendar->new( branchcode => $branch )->insert_exception_holiday( + day => 7, + month => 7, + year => 2020, + title => 'Not a holiday', + description => 'This date should not be a holiday', + ); + + my $calendar = Koha::Calendar->new( branchcode => $branch2 ); + $calendar->exception_holidays(); #This sets exception holiday in cache + $calendar = Koha::Calendar->new( branchcode => $branch ); + is( $calendar->is_holiday( dt_from_string('2020-07-07') ), 0, "The date is not a holiday"); + $dbh->do("DELETE FROM special_holidays"); # Clear cache Koha::Caches->get_instance->flush_all; @@ -53,8 +82,7 @@ subtest 'exception_holidays() tests' => sub { use POSIX qw(tzset); tzset; - my $branch = $builder->build( { source => 'Branch' } )->{branchcode}; - my $calendar = Koha::Calendar->new( branchcode => $branch ); + $calendar = Koha::Calendar->new( branchcode => $branch ); C4::Calendar->new( branchcode => $branch )->insert_exception_holiday( day => 6, -- 2.11.0