From 5ca6b710b285e2c5f273449eb0a84ceabe11b49c Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Fri, 8 Nov 2019 13:37:17 +0000 Subject: [PATCH] Bug 23974: (follow-up) Add same day loan tests Hourly loans can be short enough to not cross a day boundary and as such we should test for that scenario in the hour_between tests too. Signed-off-by: Martin Renvoize --- t/db_dependent/Calendar.t | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Calendar.t b/t/db_dependent/Calendar.t index e3e82b5e1f..3e4eced459 100644 --- a/t/db_dependent/Calendar.t +++ b/t/db_dependent/Calendar.t @@ -150,7 +150,13 @@ subtest 'hours_between | days_between' => sub { subtest 'Different hours' => sub { - plan tests => 8; + plan tests => 10; + + # Between 5th and 5th (Same day short hours loan) + my $diff_hours = $calendar->hours_between( $now, $now->clone->add(hours => 3) )->hours; + is( $diff_hours, 3, '' ); + my $diff_days = $calendar->days_between( $now, $now->clone->add(hours => 3) )->delta_days; + is( $diff_days, 0, '' ); # Between 5th and 6th my $diff_hours = $calendar->hours_between( $now, $nov_6->clone->subtract(hours => 3) )->hours; @@ -233,6 +239,9 @@ subtest 'hours_between | days_between' => sub { my ( $diff_hours, $diff_days ); + # Between 5th and 5th (Same day short hours loan) + # No test - one cannot issue on a holiday and we do not yet record opening hours to take those into account + # Between 5th and 6th my $duration = $calendar->hours_between( $now, $nov_6->clone->subtract(hours => 3) ); is( $duration->hours, abs(0 * 24 - 3), '' ); # FIXME $duration->hours always return a abs -- 2.20.1