From 6f23ccf1ccee919dc0d6b8efcf520bad3fa10b52 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Mon, 26 May 2014 02:01:51 +0000 Subject: [PATCH] Bug 12230: (follow-up) improve unit tests [1] Clear holidays first to avoid throwing off the calculations [2] Add descriptions for the tests Signed-off-by: Galen Charlton --- .../Circulation/IssuingRules/maxsuspensiondays.t | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/t/db_dependent/Circulation/IssuingRules/maxsuspensiondays.t b/t/db_dependent/Circulation/IssuingRules/maxsuspensiondays.t index 8c7085a0a8..d2cf9c4399 100644 --- a/t/db_dependent/Circulation/IssuingRules/maxsuspensiondays.t +++ b/t/db_dependent/Circulation/IssuingRules/maxsuspensiondays.t @@ -54,6 +54,10 @@ my (undef, undef, $itemnumber) = AddItem({ barcode => $barcode, } , $biblionumber); +# clear any holidays to avoid throwing off the suspension day +# calculations +$dbh->do('DELETE FROM special_holidays'); +$dbh->do('DELETE FROM repeatable_holidays'); my $daysago20 = dt_from_string->add_duration(DateTime::Duration->new(days => -20)); my $daysafter40 = dt_from_string->add_duration(DateTime::Duration->new(days => 40)); @@ -61,7 +65,11 @@ my $daysafter40 = dt_from_string->add_duration(DateTime::Duration->new(days => 4 AddIssue( $borrower, $barcode, $daysago20 ); AddReturn( $barcode, $branchcode ); my $debarments = GetDebarments({borrowernumber => $borrower->{borrowernumber}}); -is( $debarments->[0]->{expiration}, output_pref({ dt => $daysafter40, dateformat => 'iso', dateonly => 1 })); +is( + $debarments->[0]->{expiration}, + output_pref({ dt => $daysafter40, dateformat => 'iso', dateonly => 1 }), + 'calculate suspension with no maximum set' +); DelDebarment( $debarments->[0]->{borrower_debarment_id} ); # Test with maxsuspensiondays = 10 days @@ -77,7 +85,11 @@ my $daysafter10 = dt_from_string->add_duration(DateTime::Duration->new(days => 1 AddIssue( $borrower, $barcode, $daysago20 ); AddReturn( $barcode, $branchcode ); $debarments = GetDebarments({borrowernumber => $borrower->{borrowernumber}}); -is( $debarments->[0]->{expiration}, output_pref({ dt => $daysafter10, dateformat => 'iso', dateonly => 1 })); +is( + $debarments->[0]->{expiration}, + output_pref({ dt => $daysafter10, dateformat => 'iso', dateonly => 1 }), + 'calculate suspension with a maximum set' +); DelDebarment( $debarments->[0]->{borrower_debarment_id} ); -- 2.20.1