From 3b24981b898c6cef9c7f10e67f135dc77a083ac1 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Thu, 17 Sep 2026 16:38:22 +0100 Subject: [PATCH] Bug 42608: (follow-up) Adapt tests to Bug 42310 calendar schema Bug 42310 landed on main after this patch's tests were written. It renamed Koha::Calendar to Koha::Library::Calendar and normalized the legacy repeatable_holidays/special_holidays tables into library_weekly_closures/library_single_closures (plus repeating closures and exceptions), managed via Koha::Library::Calendar::* DBIC-backed classes. The new subtests added for this bug still referenced the old class name and the dropped DBIC sources (RepeatableHoliday, SpecialHoliday), so t/db_dependent/Calendar.t and t/db_dependent/Hold.t failed after rebasing onto current main. Update both to build closures via Koha::Library::Calendar::WeeklyClosures/SingleClosures and to instantiate Koha::Library::Calendar, matching the convention already used elsewhere in these files since the Bug 42310 follow-up. No production code changes; test-only fix. Signed-off-by: Martin Renvoize Signed-off-by: Andrew Fuerste Henry Signed-off-by: Pedro Amorim --- t/db_dependent/Calendar.t | 28 +++++++++++++--------------- t/db_dependent/Hold.t | 24 +++++++++++------------- 2 files changed, 24 insertions(+), 28 deletions(-) diff --git a/t/db_dependent/Calendar.t b/t/db_dependent/Calendar.t index 66ac490298..aabde5a006 100755 --- a/t/db_dependent/Calendar.t +++ b/t/db_dependent/Calendar.t @@ -457,27 +457,25 @@ subtest 'days_forward' => sub { my $dayweek_branch = $dayweek_library->branchcode; # Sundays are the only weekly closure. - $schema->resultset('RepeatableHoliday')->create( + $builder->build_object( { - branchcode => $dayweek_branch, - weekday => 0, - description => q{Sunday}, - title => q{Sunday}, + class => 'Koha::Library::Calendar::WeeklyClosures', + value => { library_id => $dayweek_branch, weekday => 0, title => q{Sunday}, description => q{Sunday} } } ); # Single (one-off) holiday on a Monday 2 weeks out from a known Tuesday. my $tuesday = dt_from_string('2026-04-28'); # Tuesday my $bh = dt_from_string('2026-05-04'); # Monday Bank Holiday - $schema->resultset('SpecialHoliday')->create( + $builder->build_object( { - branchcode => $dayweek_branch, - day => $bh->day, - month => $bh->month, - year => $bh->year, - isexception => 0, - title => q{May Bank Holiday}, - description => q{May Bank Holiday}, + class => 'Koha::Library::Calendar::SingleClosures', + value => { + library_id => $dayweek_branch, + date => $bh->ymd, + title => q{May Bank Holiday}, + description => q{May Bank Holiday}, + } } ); @@ -485,7 +483,7 @@ subtest 'days_forward' => sub { $cache->clear_from_cache( $dayweek_branch . '_holidays' ); for my $mode (qw(Calendar Datedue Dayweek Days)) { - my $dw_cal = Koha::Calendar->new( + my $dw_cal = Koha::Library::Calendar->new( branchcode => $dayweek_branch, days_mode => $mode, ); @@ -502,7 +500,7 @@ subtest 'days_forward' => sub { # Confirm same behaviour over the BH from Monday (final day lands past # the closures): Mon 27 Apr + 6 open days = Tue 5 May. my $monday = dt_from_string('2026-04-27'); - my $dw_cal = Koha::Calendar->new( branchcode => $dayweek_branch, days_mode => 'Dayweek' ); + my $dw_cal = Koha::Library::Calendar->new( branchcode => $dayweek_branch, days_mode => 'Dayweek' ); is( $dw_cal->days_forward( $monday, 6 )->ymd, '2026-05-05', 'days_forward(+6) from Mon over Sun + Mon BH lands on Tue (no week-jump in Dayweek)' diff --git a/t/db_dependent/Hold.t b/t/db_dependent/Hold.t index 786ce02c04..b3726010f7 100755 --- a/t/db_dependent/Hold.t +++ b/t/db_dependent/Hold.t @@ -349,23 +349,21 @@ subtest "set_waiting() tests" => sub { my $branch = $library->branchcode; # Sundays weekly closed, single holiday on Mon 4 May 2026. - $schema->resultset('RepeatableHoliday')->create( + $builder->build_object( { - branchcode => $branch, - weekday => 0, - description => q{Sunday}, - title => q{Sunday}, + class => 'Koha::Library::Calendar::WeeklyClosures', + value => { library_id => $branch, weekday => 0, title => q{Sunday}, description => q{Sunday} } } ); - $schema->resultset('SpecialHoliday')->create( + $builder->build_object( { - branchcode => $branch, - day => 4, - month => 5, - year => 2026, - isexception => 0, - title => q{May Bank Holiday}, - description => q{May Bank Holiday}, + class => 'Koha::Library::Calendar::SingleClosures', + value => { + library_id => $branch, + date => '2026-05-04', + title => q{May Bank Holiday}, + description => q{May Bank Holiday}, + } } ); Koha::Caches->get_instance->clear_from_cache( $branch . '_holidays' );