From 6ca7c1118beac573e5ed37dfb64161835e0cf41f Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Mon, 18 May 2026 18:16:51 +0100 Subject: [PATCH] Bug 42545: (QA follow-up) Add POD for _init and _holidays and fix incorrect test expectation The existing 'days: 289 hours, 2 holidays' test asserted 8-1=7 but its own description named 2 holidays. The expected value matched the buggy behaviour (loop exiting before the holiday end date) rather than the correct result. Update to 8-2=6 to reflect the fix. Signed-off-by: Lucas Gass --- Koha/Calendar.pm | 14 ++++++++++++++ t/db_dependent/Calendar.t | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Koha/Calendar.pm b/Koha/Calendar.pm index 354ed3c307..cc71b3926a 100644 --- a/Koha/Calendar.pm +++ b/Koha/Calendar.pm @@ -449,6 +449,20 @@ Koha::Calendar - Object containing a branches calendar =head1 METHODS +=head2 _init + + $calendar->_init(); + +Populates the object with repeatable closed days (weekly and day/month) for the +branch. Called automatically by C. + +=head2 _holidays + + my $holidays = $calendar->_holidays(); + +Returns a hashref of special (one-off) holidays for the branch, keyed by +C date strings. Results are cached. + =head2 new : Create a calendar object my $calendar = Koha::Calendar->new( branchcode => 'MAIN' ); diff --git a/t/db_dependent/Calendar.t b/t/db_dependent/Calendar.t index 0b1c479c3f..0c2ca52165 100755 --- a/t/db_dependent/Calendar.t +++ b/t/db_dependent/Calendar.t @@ -612,7 +612,7 @@ subtest 'hours_between | days_between' => sub { $diff_hours = $calendar->hours_between( $now, $nov_13->clone->subtract( hours => 3 ) )->hours; is( $diff_hours, 8 * 24 - 2 * 24 - 3, 'hours: 289 hours, 2 holidays ' ); $diff_days = $calendar->days_between( $now, $nov_13->clone->subtract( hours => 3 ) )->delta_days; - is( $diff_days, 8 - 1, 'days: 289 hours, 2 holidays' ); + is( $diff_days, 8 - 2, 'days: 289 hours, 2 holidays' ); # Between 5th and 15th $diff_hours = $calendar->hours_between( $now, $nov_15->clone->subtract( hours => 3 ) )->hours;