Bug 10272: (follow-up) add regression test
This patch adds a regression test for this bug, effectively implementing the manual test plan in the previous patch. To test: [1] Verify that prove -v t/db_dependent/Reserves.t passes. Signed-off-by: Galen Charlton <gmc@esilibrary.com>
This commit is contained in:
parent
78eba2f974
commit
e831a7eb3f
1 changed files with 107 additions and 1 deletions
|
@ -2,13 +2,14 @@
|
|||
|
||||
use Modern::Perl;
|
||||
|
||||
use Test::More tests => 6;
|
||||
use Test::More tests => 8;
|
||||
use MARC::Record;
|
||||
|
||||
use C4::Branch;
|
||||
use C4::Biblio;
|
||||
use C4::Items;
|
||||
use C4::Members;
|
||||
use C4::Circulation;
|
||||
|
||||
BEGIN {
|
||||
use_ok('C4::Reserves');
|
||||
|
@ -93,3 +94,108 @@ ok(
|
|||
), "GetReservesControlBranch returns patron home branch when set to PatronLibrary"
|
||||
);
|
||||
C4::Context->set_preference( 'ReservesControlBranch', $ReservesControlBranch );
|
||||
|
||||
###
|
||||
### Regression test for bug 10272
|
||||
###
|
||||
my %requesters = ();
|
||||
$requesters{'CPL'} = AddMember(
|
||||
branchcode => 'CPL',
|
||||
categorycode => 'PT',
|
||||
surname => 'borrower from CPL',
|
||||
);
|
||||
$requesters{'FPL'} = AddMember(
|
||||
branchcode => 'FPL',
|
||||
categorycode => 'PT',
|
||||
surname => 'borrower from FPL',
|
||||
);
|
||||
$requesters{'RPL'} = AddMember(
|
||||
branchcode => 'RPL',
|
||||
categorycode => 'PT',
|
||||
surname => 'borrower from RPL',
|
||||
);
|
||||
|
||||
# Configure rules so that CPL allows only CPL patrons
|
||||
# to request its items, while FPL will allow its items
|
||||
# to fill holds from anywhere.
|
||||
|
||||
$dbh->do('DELETE FROM issuingrules');
|
||||
$dbh->do('DELETE FROM branch_item_rules');
|
||||
$dbh->do('DELETE FROM branch_borrower_circ_rules');
|
||||
$dbh->do('DELETE FROM default_borrower_circ_rules');
|
||||
$dbh->do('DELETE FROM default_branch_item_rules');
|
||||
$dbh->do('DELETE FROM default_branch_circ_rules');
|
||||
$dbh->do('DELETE FROM default_circ_rules');
|
||||
$dbh->do(
|
||||
q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed)
|
||||
VALUES (?, ?, ?, ?)},
|
||||
{},
|
||||
'*', '*', '*', 25
|
||||
);
|
||||
|
||||
# CPL allows only its own patrons to request its items
|
||||
$dbh->do(
|
||||
q{INSERT INTO default_branch_circ_rules (branchcode, maxissueqty, holdallowed, returnbranch)
|
||||
VALUES (?, ?, ?, ?)},
|
||||
{},
|
||||
'CPL', 10, 1, 'homebranch',
|
||||
);
|
||||
|
||||
# ... while FPL allows anybody to request its items
|
||||
$dbh->do(
|
||||
q{INSERT INTO default_branch_circ_rules (branchcode, maxissueqty, holdallowed, returnbranch)
|
||||
VALUES (?, ?, ?, ?)},
|
||||
{},
|
||||
'FPL', 10, 2, 'homebranch',
|
||||
);
|
||||
|
||||
# helper biblio for the bug 10272 regression test
|
||||
my $bib2 = MARC::Record->new();
|
||||
$bib2->append_fields(
|
||||
MARC::Field->new('100', ' ', ' ', a => 'Moffat, Steven'),
|
||||
MARC::Field->new('245', ' ', ' ', a => $title),
|
||||
);
|
||||
|
||||
# create one item belonging to FPL and one belonging to CPL
|
||||
my ($bibnum2, $bibitemnum2) = AddBiblio($bib, '');
|
||||
my ($itemnum_cpl, $itemnum_fpl);
|
||||
(undef, undef, $itemnum_cpl) = AddItem({
|
||||
homebranch => 'CPL',
|
||||
holdingbranch => 'CPL',
|
||||
barcode => 'bug10272_CPL'
|
||||
} , $bibnum2);
|
||||
(undef, undef, $itemnum_fpl) = AddItem({
|
||||
homebranch => 'FPL',
|
||||
holdingbranch => 'FPL',
|
||||
barcode => 'bug10272_FPL'
|
||||
} , $bibnum2);
|
||||
|
||||
AddReserve('RPL', $requesters{'RPL'}, $bibnum2,
|
||||
$constraint, $bibitems, 1, $resdate, $expdate, $notes,
|
||||
$title, $checkitem, $found);
|
||||
AddReserve('FPL', $requesters{'FPL'}, $bibnum2,
|
||||
$constraint, $bibitems, 2, $resdate, $expdate, $notes,
|
||||
$title, $checkitem, $found);
|
||||
AddReserve('CPL', $requesters{'CPL'}, $bibnum2,
|
||||
$constraint, $bibitems, 3, $resdate, $expdate, $notes,
|
||||
$title, $checkitem, $found);
|
||||
|
||||
# Ensure that the item's home library controls hold policy lookup
|
||||
C4::Context->set_preference( 'ReservesControlBranch', 'ItemHomeLibrary' );
|
||||
|
||||
my $messages;
|
||||
# Return the CPL item at FPL. The hold that should be triggered is
|
||||
# the one placed by the CPL patron, as the other two patron's hold
|
||||
# requests cannot be filled by that item per policy.
|
||||
(undef, $messages, undef, undef) = AddReturn('bug10272_CPL', 'FPL');
|
||||
is( $messages->{ResFound}->{borrowernumber},
|
||||
$requesters{'CPL'},
|
||||
'restrictive library\'s items only fill requests by own patrons (bug 10272)');
|
||||
|
||||
# Return the FPL item at FPL. The hold that should be triggered is
|
||||
# the one placed by the RPL patron, as that patron is first in line
|
||||
# and RPL imposes no restrictions on whose holds its items can fill.
|
||||
(undef, $messages, undef, undef) = AddReturn('bug10272_FPL', 'FPL');
|
||||
is( $messages->{ResFound}->{borrowernumber},
|
||||
$requesters{'RPL'},
|
||||
'for generous library, its items fill first hold request in line (bug 10272)');
|
||||
|
|
Loading…
Reference in a new issue