Bug 8735 [QA Followup] - Add Unit Tests
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
This commit is contained in:
parent
3c1f7dae0a
commit
e0e66612cc
1 changed files with 38 additions and 1 deletions
|
@ -6,11 +6,12 @@ use t::lib::Mocks;
|
|||
use C4::Context;
|
||||
use C4::Branch;
|
||||
|
||||
use Test::More tests => 32;
|
||||
use Test::More tests => 35;
|
||||
use MARC::Record;
|
||||
use C4::Biblio;
|
||||
use C4::Items;
|
||||
use C4::Members;
|
||||
use C4::Calendar;
|
||||
|
||||
BEGIN {
|
||||
use FindBin;
|
||||
|
@ -324,6 +325,42 @@ ok(
|
|||
"cannot request item if policy that matches on bib-level item type forbids it (bug 9532)"
|
||||
);
|
||||
|
||||
# Test CancelExpiredReserves
|
||||
C4::Context->set_preference('ExpireReservesMaxPickUpDelay', 1);
|
||||
C4::Context->set_preference('ReservesMaxPickUpDelay', 1);
|
||||
|
||||
my ( $sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst ) = localtime(time);
|
||||
$year += 1900;
|
||||
$mon += 1;
|
||||
$reserves = $dbh->selectall_arrayref('SELECT * FROM reserves', { Slice => {} });
|
||||
$reserve = $reserves->[0];
|
||||
my $calendar = C4::Calendar->new(branchcode => $reserve->{branchcode});
|
||||
$calendar->insert_single_holiday(
|
||||
day => $mday,
|
||||
month => $mon,
|
||||
year => $year,
|
||||
title => 'Test',
|
||||
description => 'Test',
|
||||
);
|
||||
$reserve_id = $reserve->{reserve_id};
|
||||
$dbh->do("UPDATE reserves SET waitingdate = DATE_SUB( NOW(), INTERVAL 5 DAY ), found = 'W', priority = 0 WHERE reserve_id = ?", undef, $reserve_id );
|
||||
C4::Context->set_preference('ExpireReservesOnHolidays', 0);
|
||||
CancelExpiredReserves();
|
||||
my $count = $dbh->selectrow_array("SELECT COUNT(*) FROM reserves WHERE reserve_id = ?", undef, $reserve_id );
|
||||
is( $count, 1, "Waiting reserve beyond max pickup delay *not* canceled on holiday" );
|
||||
C4::Context->set_preference('ExpireReservesOnHolidays', 1);
|
||||
CancelExpiredReserves();
|
||||
$count = $dbh->selectrow_array("SELECT COUNT(*) FROM reserves WHERE reserve_id = ?", undef, $reserve_id );
|
||||
is( $count, 0, "Waiting reserve beyond max pickup delay canceled on holiday" );
|
||||
|
||||
# Test expirationdate
|
||||
$reserve = $reserves->[1];
|
||||
$reserve_id = $reserve->{reserve_id};
|
||||
$dbh->do("UPDATE reserves SET expirationdate = DATE_SUB( NOW(), INTERVAL 1 DAY ) WHERE reserve_id = ?", undef, $reserve_id );
|
||||
CancelExpiredReserves();
|
||||
$count = $dbh->selectrow_array("SELECT COUNT(*) FROM reserves WHERE reserve_id = ?", undef, $reserve_id );
|
||||
is( $count, 0, "Reserve with manual expiration date canceled correctly" );
|
||||
|
||||
# Helper method to set up a Biblio.
|
||||
sub create_helper_biblio {
|
||||
my $itemtype = shift;
|
||||
|
|
Loading…
Reference in a new issue