|
Lines 201-209
subtest 'AutoRemoveOverduesRestrictions' => sub {
Link Here
|
| 201 |
my $item_1 = $builder->build_sample_item; |
201 |
my $item_1 = $builder->build_sample_item; |
| 202 |
my $item_2 = $builder->build_sample_item; |
202 |
my $item_2 = $builder->build_sample_item; |
| 203 |
my $item_3 = $builder->build_sample_item; |
203 |
my $item_3 = $builder->build_sample_item; |
| 204 |
my $five_days_ago = dt_from_string->subtract( days => 5 ); |
204 |
my $nine_days_ago = dt_from_string->subtract( days => 9 ); #->set_hour(23)->set_minute(59); |
| 205 |
my $checkout_1 = AddIssue( $patron, $item_1->barcode, $five_days_ago ); # overdue, but would not trigger debarment |
205 |
my $checkout_1 = AddIssue( $patron, $item_1->barcode, $nine_days_ago ); # overdue, but would not trigger debarment |
| 206 |
my $checkout_2 = AddIssue( $patron, $item_2->barcode, $five_days_ago ); # overdue, but would not trigger debarment |
206 |
my $checkout_2 = AddIssue( $patron, $item_2->barcode, $nine_days_ago ); # overdue, but would not trigger debarment |
| 207 |
my $checkout_3 = AddIssue( $patron, $item_3->barcode ); # not overdue |
207 |
my $checkout_3 = AddIssue( $patron, $item_3->barcode ); # not overdue |
| 208 |
|
208 |
|
| 209 |
Koha::Patron::Debarments::AddUniqueDebarment( |
209 |
Koha::Patron::Debarments::AddUniqueDebarment( |
|
Lines 227-236
subtest 'AutoRemoveOverduesRestrictions' => sub {
Link Here
|
| 227 |
|
227 |
|
| 228 |
t::lib::Mocks::mock_preference('AutoRemoveOverduesRestrictions', 'when_no_overdue_causing_debarment'); |
228 |
t::lib::Mocks::mock_preference('AutoRemoveOverduesRestrictions', 'when_no_overdue_causing_debarment'); |
| 229 |
|
229 |
|
| 230 |
my $eleven_days_ago = dt_from_string->subtract( days => 11 ); |
230 |
my $ten_days_ago = dt_from_string->subtract( days => 10 ); |
|
|
231 |
|
| 232 |
$checkout_1 = AddIssue( $patron->unblessed, $item_1->barcode, $ten_days_ago ); # overdue and would trigger debarment |
| 233 |
$checkout_2 = AddIssue( $patron->unblessed, $item_2->barcode, $nine_days_ago ); # overdue, but would not trigger debarment |
| 231 |
|
234 |
|
| 232 |
$checkout_1 = AddIssue( $patron->unblessed, $item_1->barcode, $eleven_days_ago ); # overdue and would trigger debarment |
235 |
print STDERR "DUEDATE: " . $nine_days_ago->stringify . "\n"; |
| 233 |
$checkout_2 = AddIssue( $patron->unblessed, $item_2->barcode, $five_days_ago ); # overdue, but would not trigger debarment |
|
|
| 234 |
|
236 |
|
| 235 |
Koha::Patron::Debarments::AddUniqueDebarment( |
237 |
Koha::Patron::Debarments::AddUniqueDebarment( |
| 236 |
{ |
238 |
{ |
|
Lines 245-251
subtest 'AutoRemoveOverduesRestrictions' => sub {
Link Here
|
| 245 |
$debarments = Koha::Patron::Debarments::GetDebarments({ borrowernumber => $patron->borrowernumber }); |
247 |
$debarments = Koha::Patron::Debarments::GetDebarments({ borrowernumber => $patron->borrowernumber }); |
| 246 |
is( scalar @$debarments, 0, 'OVERDUES debarment is removed if remaning items would not result in patron debarment' ); |
248 |
is( scalar @$debarments, 0, 'OVERDUES debarment is removed if remaning items would not result in patron debarment' ); |
| 247 |
|
249 |
|
| 248 |
$checkout_1 = AddIssue( $patron->unblessed, $item_1->barcode, $eleven_days_ago ); # overdue and would trigger debarment |
250 |
$checkout_1 = AddIssue( $patron->unblessed, $item_1->barcode, $ten_days_ago ); # overdue and would trigger debarment |
| 249 |
|
251 |
|
| 250 |
Koha::Patron::Debarments::AddUniqueDebarment( |
252 |
Koha::Patron::Debarments::AddUniqueDebarment( |
| 251 |
{ |
253 |
{ |
|
Lines 260-271
subtest 'AutoRemoveOverduesRestrictions' => sub {
Link Here
|
| 260 |
$debarments = Koha::Patron::Debarments::GetDebarments({ borrowernumber => $patron->borrowernumber }); |
262 |
$debarments = Koha::Patron::Debarments::GetDebarments({ borrowernumber => $patron->borrowernumber }); |
| 261 |
is( $debarments->[0]->{type}, 'OVERDUES', 'OVERDUES debarment is not removed if patron still has overdues that would trigger debarment' ); |
263 |
is( $debarments->[0]->{type}, 'OVERDUES', 'OVERDUES debarment is not removed if patron still has overdues that would trigger debarment' ); |
| 262 |
|
264 |
|
| 263 |
my $thirteen_days_ago = dt_from_string->subtract( days => 13 ); |
265 |
my $eleven_days_ago = dt_from_string->subtract( days => 11 ); |
| 264 |
|
266 |
|
| 265 |
# overdue and would trigger debarment |
267 |
# overdue and would trigger debarment |
| 266 |
$checkout_2 = AddIssue( $patron->unblessed, $item_2->barcode, $thirteen_days_ago ); |
268 |
$checkout_2 = AddIssue( $patron->unblessed, $item_2->barcode, $eleven_days_ago ); |
| 267 |
|
269 |
|
| 268 |
# $chechout_1 should now not trigger debarment with this new rule for specific branchcode |
270 |
# $checkout_1 should now not trigger debarment with this new rule for specific branchcode |
| 269 |
$dbh->do(qq{ |
271 |
$dbh->do(qq{ |
| 270 |
INSERT INTO `overduerules` ( |
272 |
INSERT INTO `overduerules` ( |
| 271 |
`branchcode`, |
273 |
`branchcode`, |
|
Lines 277-283
subtest 'AutoRemoveOverduesRestrictions' => sub {
Link Here
|
| 277 |
`letter2`, |
279 |
`letter2`, |
| 278 |
`debarred2` |
280 |
`debarred2` |
| 279 |
) |
281 |
) |
| 280 |
VALUES ('$branchcode', '$categorycode', 6, 'ODUE', 0, 12, 'ODUE2', 1) |
282 |
VALUES ('$branchcode', '$categorycode', 6, 'ODUE', 0, 11, 'ODUE2', 1) |
| 281 |
}); |
283 |
}); |
| 282 |
|
284 |
|
| 283 |
C4::Circulation::MarkIssueReturned( $patron->borrowernumber, $item_2->itemnumber ); |
285 |
C4::Circulation::MarkIssueReturned( $patron->borrowernumber, $item_2->itemnumber ); |
| 284 |
- |
|
|