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 <gmc@esilibrary.com>
This commit is contained in:
parent
66ee141fd0
commit
6f23ccf1cc
|
|
@ -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} );
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue