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 <martin.renvoize@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
Martin Renvoize 2019-11-08 13:37:17 +00:00
parent a4f8daacb9
commit b6872ccbd5
Signed by: martin.renvoize
GPG key ID: 422B469130441A0F

View file

@ -150,12 +150,18 @@ 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;
$diff_hours = $calendar->hours_between( $now, $nov_6->clone->subtract(hours => 3) )->hours;
is( $diff_hours, 1 * 24 - 3, '' );
my $diff_days = $calendar->days_between( $now, $nov_6->clone->subtract(hours => 3) )->delta_days;
$diff_days = $calendar->days_between( $now, $nov_6->clone->subtract(hours => 3) )->delta_days;
is( $diff_days, 1, '' );
# Between 5th and 7th
@ -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