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 <martin.renvoize@openfifth.co.uk>
Signed-off-by: Andrew Fuerste Henry <andrew@bywatersolutions.com>
Signed-off-by: Pedro Amorim <pedro.amorim@openfifth.co.uk>
This commit is contained in:
Martin Renvoize 2026-09-17 16:38:22 +01:00 committed by Pedro Amorim
parent 58d41bfedf
commit 3b24981b89
No known key found for this signature in database
GPG Key ID: 06B75BA7F3894D55
2 changed files with 24 additions and 28 deletions

View File

@ -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)'

View File

@ -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' );