Bug 10336: HoldsQueue.t needs to create its own data
After applying this patch and the patch submitted in bug 10495, you can run prove t/db_dependent/HoldsQueue.t and admire that all tests pass. This patch creates a borrower and uses Koha routines instead of directly updating the database. Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz> Signed-off-by: Galen Charlton <gmc@esilibrary.com>
This commit is contained in:
parent
4e51ec5aae
commit
bfbc646fdd
1 changed files with 29 additions and 22 deletions
|
@ -6,14 +6,18 @@
|
|||
# MySQL WARNING: This makes sense only if your tables are InnoDB, otherwise
|
||||
# transactions are not supported and mess is left behind
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use Modern::Perl;
|
||||
|
||||
use C4::Context;
|
||||
|
||||
use Data::Dumper;
|
||||
|
||||
use Test::More tests => 18;
|
||||
|
||||
use C4::Branch;
|
||||
use C4::ItemType;
|
||||
use C4::Members;
|
||||
|
||||
BEGIN {
|
||||
use FindBin;
|
||||
use lib $FindBin::Bin;
|
||||
|
@ -21,28 +25,33 @@ BEGIN {
|
|||
use_ok('C4::HoldsQueue');
|
||||
}
|
||||
|
||||
my $TITLE = "Test Holds Queue XXX";
|
||||
# Pick a plausible borrower. Easier than creating one.
|
||||
my $BORROWER_QRY = <<EOQ;
|
||||
select *
|
||||
from borrowers
|
||||
where borrowernumber = (select max(borrowernumber) from issues)
|
||||
EOQ
|
||||
my $dbh = C4::Context->dbh;
|
||||
my $borrower = $dbh->selectrow_hashref($BORROWER_QRY);
|
||||
my $borrowernumber = $borrower->{borrowernumber};
|
||||
# Set special (for this test) branches
|
||||
my $borrower_branchcode = $borrower->{branchcode};
|
||||
my @other_branches = grep { $_ ne $borrower_branchcode } @{ $dbh->selectcol_arrayref("SELECT branchcode FROM branches") };
|
||||
my $least_cost_branch_code = pop @other_branches
|
||||
or BAIL_OUT("No point testing only one branch...");
|
||||
my $itemtype = $dbh->selectrow_array("SELECT min(itemtype) FROM itemtypes WHERE notforloan = 0")
|
||||
or BAIL_OUT("No adequate itemtype");
|
||||
|
||||
# Start transaction
|
||||
my $dbh = C4::Context->dbh;
|
||||
$dbh->{AutoCommit} = 0;
|
||||
$dbh->{RaiseError} = 1;
|
||||
|
||||
my $TITLE = "Test Holds Queue XXX";
|
||||
|
||||
my %data = (
|
||||
cardnumber => 'CARDNUMBER42',
|
||||
firstname => 'my firstname',
|
||||
surname => 'my surname',
|
||||
categorycode => 'S',
|
||||
branchcode => 'CPL',
|
||||
);
|
||||
|
||||
my $borrowernumber = AddMember(%data);
|
||||
my $borrower = GetMember( borrowernumber => $borrowernumber );
|
||||
# Set special (for this test) branches
|
||||
my $borrower_branchcode = $borrower->{branchcode};
|
||||
my $branches = C4::Branch::GetBranches;
|
||||
my @other_branches = grep { $_ ne $borrower_branchcode } keys %$branches;
|
||||
my $least_cost_branch_code = pop @other_branches
|
||||
or BAIL_OUT("No point testing only one branch...");
|
||||
my @item_types = C4::ItemType->all;
|
||||
my $itemtype = grep { $_->{notforloan} == 1 } @item_types
|
||||
or BAIL_OUT("No adequate itemtype");
|
||||
|
||||
#Set up the stage
|
||||
# Sysprefs and cost matrix
|
||||
$dbh->do("UPDATE systempreferences SET value = ? WHERE variable = 'StaticHoldsQueueWeight'", undef,
|
||||
|
@ -145,8 +154,6 @@ ok( $queue_item
|
|||
# Cleanup
|
||||
$dbh->rollback;
|
||||
|
||||
exit;
|
||||
|
||||
sub test_queue {
|
||||
my ($test_name, $use_cost_matrix, $pick_branch, $hold_branch) = @_;
|
||||
|
||||
|
|
Loading…
Reference in a new issue