Lines 6-16
use t::lib::Mocks;
Link Here
|
6 |
use C4::Context; |
6 |
use C4::Context; |
7 |
use C4::Branch; |
7 |
use C4::Branch; |
8 |
|
8 |
|
9 |
use Test::More tests => 32; |
9 |
use Test::More tests => 35; |
10 |
use MARC::Record; |
10 |
use MARC::Record; |
11 |
use C4::Biblio; |
11 |
use C4::Biblio; |
12 |
use C4::Items; |
12 |
use C4::Items; |
13 |
use C4::Members; |
13 |
use C4::Members; |
|
|
14 |
use C4::Calendar; |
14 |
|
15 |
|
15 |
BEGIN { |
16 |
BEGIN { |
16 |
use FindBin; |
17 |
use FindBin; |
Lines 324-329
ok(
Link Here
|
324 |
"cannot request item if policy that matches on bib-level item type forbids it (bug 9532)" |
325 |
"cannot request item if policy that matches on bib-level item type forbids it (bug 9532)" |
325 |
); |
326 |
); |
326 |
|
327 |
|
|
|
328 |
# Test CancelExpiredReserves |
329 |
C4::Context->set_preference('ExpireReservesMaxPickUpDelay', 1); |
330 |
C4::Context->set_preference('ReservesMaxPickUpDelay', 1); |
331 |
|
332 |
my ( $sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst ) = localtime(time); |
333 |
$year += 1900; |
334 |
$mon += 1; |
335 |
$reserves = $dbh->selectall_arrayref('SELECT * FROM reserves', { Slice => {} }); |
336 |
$reserve = $reserves->[0]; |
337 |
my $calendar = C4::Calendar->new(branchcode => $reserve->{branchcode}); |
338 |
$calendar->insert_single_holiday( |
339 |
day => $mday, |
340 |
month => $mon, |
341 |
year => $year, |
342 |
title => 'Test', |
343 |
description => 'Test', |
344 |
); |
345 |
$reserve_id = $reserve->{reserve_id}; |
346 |
$dbh->do("UPDATE reserves SET waitingdate = DATE_SUB( NOW(), INTERVAL 5 DAY ), found = 'W', priority = 0 WHERE reserve_id = ?", undef, $reserve_id ); |
347 |
C4::Context->set_preference('ExpireReservesOnHolidays', 0); |
348 |
CancelExpiredReserves(); |
349 |
my $count = $dbh->selectrow_array("SELECT COUNT(*) FROM reserves WHERE reserve_id = ?", undef, $reserve_id ); |
350 |
is( $count, 1, "Waiting reserve beyond max pickup delay *not* canceled on holiday" ); |
351 |
C4::Context->set_preference('ExpireReservesOnHolidays', 1); |
352 |
CancelExpiredReserves(); |
353 |
$count = $dbh->selectrow_array("SELECT COUNT(*) FROM reserves WHERE reserve_id = ?", undef, $reserve_id ); |
354 |
is( $count, 0, "Waiting reserve beyond max pickup delay canceled on holiday" ); |
355 |
|
356 |
# Test expirationdate |
357 |
$reserve = $reserves->[1]; |
358 |
$reserve_id = $reserve->{reserve_id}; |
359 |
$dbh->do("UPDATE reserves SET expirationdate = DATE_SUB( NOW(), INTERVAL 1 DAY ) WHERE reserve_id = ?", undef, $reserve_id ); |
360 |
CancelExpiredReserves(); |
361 |
$count = $dbh->selectrow_array("SELECT COUNT(*) FROM reserves WHERE reserve_id = ?", undef, $reserve_id ); |
362 |
is( $count, 0, "Reserve with manual expiration date canceled correctly" ); |
363 |
|
327 |
# Helper method to set up a Biblio. |
364 |
# Helper method to set up a Biblio. |
328 |
sub create_helper_biblio { |
365 |
sub create_helper_biblio { |
329 |
my $itemtype = shift; |
366 |
my $itemtype = shift; |
330 |
- |
|
|