Koha/t/db_dependent/Reserves.t
Srdjan Jankovic 6e07fd7b00 bug_2830: Remove reserve when checking out if the borrower is not the first one in the reserve queue
To test:
Create 4 holds on a bib, for patrons A, B, C, and D,

Check in the item to mark hold as waiting for patron A
Check out the item to patron B -> reserve for patron B should be removed
Check in the item to mark hold as waiting for patron A
Check out the item to Patron A, hold should complete normally
Check in the item to mark hold as waiting for patron C
Check out the item to patron D -> reserve for patron D should be removed.
Check in the item to mark hold as waiting for patron C
Check out the item to patron C, hold should complete normally
Check in the item -> there should be no more reserves.

We also tested:
Created 4 holds on a bib with two items, for patrons A, B, C, and D

All worked as expected.

Signed-off-by: Liz Rea <wizzyrea@gmail.com>
Signed-off-by: Paul Poulain <paul.poulain@biblibre.com>
2011-12-16 16:21:38 +01:00

62 lines
1.6 KiB
Perl
Executable file

#!/usr/bin/perl
use strict;
use warnings;
use C4::Branch;
use Test::More tests => 4;
BEGIN {
use FindBin;
use lib $FindBin::Bin;
use_ok('C4::Reserves');
}
my $dbh = C4::Context->dbh;
my $query = qq/SELECT borrowernumber
FROM borrowers
LIMIT 1/;
my $sth = $dbh->prepare($query);
$sth->execute;
my $borrower = $sth->fetchrow_hashref;
$query = qq/SELECT biblionumber, title, itemnumber, barcode
FROM biblio
LEFT JOIN items USING (biblionumber)
WHERE barcode <> ""
AND barcode IS NOT NULL
LIMIT 1/;
$sth = $dbh->prepare($query);
$sth->execute;
my $biblio = $sth->fetchrow_hashref;
my $borrowernumber = $borrower->{'borrowernumber'};
my $biblionumber = $biblio->{'biblionumber'};
my $itemnumber = $biblio->{'itemnumber'};
my $barcode = $biblio->{'barcode'};
my $constraint = 'a';
my $bibitems = '';
my $priority = '1';
my $notes = '';
my $title = $biblio->{'title'};
my $checkitem = undef;
my $found = undef;
my @branches = GetBranchesLoop();
my $branch = $branches[0][0]{value};
AddReserve($branch, $borrowernumber, $biblionumber,
$constraint, $bibitems, $priority, $notes,
$title, $checkitem, $found);
my ($status, $reserve, $all_reserves) = CheckReserves($itemnumber, $barcode);
ok($status eq "Reserved", "CheckReserves Test 1");
($status, $reserve, $all_reserves) = CheckReserves($itemnumber);
ok($status eq "Reserved", "CheckReserves Test 2");
($status, $reserve, $all_reserves) = CheckReserves(undef, $barcode);
ok($status eq "Reserved", "CheckReserves Test 3");