Bug 12230: (follow-up) improve unit tests
authorGalen Charlton <gmc@esilibrary.com>
Mon, 26 May 2014 02:01:51 +0000 (02:01 +0000)
committerGalen Charlton <gmc@esilibrary.com>
Mon, 26 May 2014 02:01:51 +0000 (02:01 +0000)
[1] Clear holidays first to avoid throwing off the
    calculations
[2] Add descriptions for the tests

Signed-off-by: Galen Charlton <gmc@esilibrary.com>

t/db_dependent/Circulation/IssuingRules/maxsuspensiondays.t

index 8c7085a..d2cf9c4 100644 (file)
@@ -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} );