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 => 29; |
9 |
use Test::More tests => 32; |
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 286-291
C4::Context->set_preference( 'AllowHoldsOnDamagedItems', 0 );
Link Here
|
286 |
ok( !CanItemBeReserved( $borrowernumbers[0], $itemnumber), "Patron cannot reserve damaged item with AllowHoldsOnDamagedItems disabled" ); |
287 |
ok( !CanItemBeReserved( $borrowernumbers[0], $itemnumber), "Patron cannot reserve damaged item with AllowHoldsOnDamagedItems disabled" ); |
287 |
ok( !defined( ( CheckReserves($itemnumber) )[1] ), "Hold cannot be trapped for damaged item with AllowHoldsOnDamagedItems disabled" ); |
288 |
ok( !defined( ( CheckReserves($itemnumber) )[1] ), "Hold cannot be trapped for damaged item with AllowHoldsOnDamagedItems disabled" ); |
288 |
|
289 |
|
|
|
290 |
# Test CancelExpiredReserves |
291 |
C4::Context->set_preference('ExpireReservesMaxPickUpDelay', 1); |
292 |
C4::Context->set_preference('ReservesMaxPickUpDelay', 1); |
293 |
|
294 |
my ( $sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst ) = localtime(time); |
295 |
$year += 1900; |
296 |
$mon += 1; |
297 |
$reserves = $dbh->selectall_arrayref('SELECT * FROM reserves', { Slice => {} }); |
298 |
$reserve = $reserves->[0]; |
299 |
my $calendar = C4::Calendar->new(branchcode => $reserve->{branchcode}); |
300 |
$calendar->insert_single_holiday( |
301 |
day => $mday, |
302 |
month => $mon, |
303 |
year => $year, |
304 |
title => 'Test', |
305 |
description => 'Test', |
306 |
); |
307 |
$reserve_id = $reserve->{reserve_id}; |
308 |
$dbh->do("UPDATE reserves SET waitingdate = DATE_SUB( NOW(), INTERVAL 2 DAY ) WHERE reserve_id = ?", undef, $reserve_id ); |
309 |
C4::Context->set_preference('ExpireReservesOnHolidays', 0); |
310 |
CancelExpiredReserves(); |
311 |
my $count = $dbh->selectrow_array("SELECT COUNT(*) FROM reserves WHERE reserve_id = ?", undef, $reserve_id ); |
312 |
is( $count, 1, "Waiting reserve beyond max pickup delay *not* canceled on holiday" ); |
313 |
C4::Context->set_preference('ExpireReservesOnHolidays', 1); |
314 |
CancelExpiredReserves(); |
315 |
$count = $dbh->selectrow_array("SELECT COUNT(*) FROM reserves WHERE reserve_id = ?", undef, $reserve_id ); |
316 |
is( $count, 0, "Waiting reserve beyond max pickup delay canceled on holiday" ); |
317 |
|
318 |
# Test expirationdate |
319 |
$reserve = $reserves->[1]; |
320 |
$reserve_id = $reserve->{reserve_id}; |
321 |
$dbh->do("UPDATE reserves SET expirationdate = DATE_SUB( NOW(), INTERVAL 1 DAY ) WHERE reserve_id = ?", undef, $reserve_id ); |
322 |
CancelExpiredReserves(); |
323 |
$count = $dbh->selectrow_array("SELECT COUNT(*) FROM reserves WHERE reserve_id = ?", undef, $reserve_id ); |
324 |
is( $count, 0, "Reserve with manual expiration date canceled correctly" ); |
289 |
|
325 |
|
290 |
# Helper method to set up a Biblio. |
326 |
# Helper method to set up a Biblio. |
291 |
sub create_helper_biblio { |
327 |
sub create_helper_biblio { |
292 |
- |
|
|