View | Details | Raw Unified | Return to bug 10336
Collapse All | Expand All

(-)a/t/db_dependent/HoldsQueue.t (-20 / +25 lines)
Lines 6-19 Link Here
6
# MySQL WARNING: This makes sense only if your tables are InnoDB, otherwise
6
# MySQL WARNING: This makes sense only if your tables are InnoDB, otherwise
7
# transactions are not supported and mess is left behind
7
# transactions are not supported and mess is left behind
8
8
9
use strict;
9
use Modern::Perl;
10
use warnings;
10
11
use C4::Context;
11
use C4::Context;
12
12
13
use Data::Dumper;
13
use Data::Dumper;
14
14
15
use Test::More tests => 18;
15
use Test::More tests => 18;
16
16
17
use C4::Branch;
18
use C4::ItemType;
19
use C4::Members;
20
17
BEGIN {
21
BEGIN {
18
    use FindBin;
22
    use FindBin;
19
    use lib $FindBin::Bin;
23
    use lib $FindBin::Bin;
Lines 21-48 BEGIN { Link Here
21
    use_ok('C4::HoldsQueue');
25
    use_ok('C4::HoldsQueue');
22
}
26
}
23
27
24
my $TITLE = "Test Holds Queue XXX";
28
# Start transaction
25
# Pick a plausible borrower. Easier than creating one.
26
my $BORROWER_QRY = <<EOQ;
27
select *
28
from borrowers
29
where borrowernumber = (select max(borrowernumber) from issues)
30
EOQ
31
my $dbh = C4::Context->dbh;
29
my $dbh = C4::Context->dbh;
32
my $borrower = $dbh->selectrow_hashref($BORROWER_QRY);
30
$dbh->{AutoCommit} = 0;
33
my $borrowernumber = $borrower->{borrowernumber};
31
$dbh->{RaiseError} = 1;
32
33
my $TITLE = "Test Holds Queue XXX";
34
35
my %data = (
36
    cardnumber => 'CARDNUMBER42',
37
    firstname =>  'my firstname',
38
    surname => 'my surname',
39
    categorycode => 'S',
40
    branchcode => 'CPL',
41
);
42
43
my $borrowernumber = AddMember(%data);
44
my $borrower = GetMember( borrowernumber => $borrowernumber );
34
# Set special (for this test) branches
45
# Set special (for this test) branches
35
my $borrower_branchcode = $borrower->{branchcode};
46
my $borrower_branchcode = $borrower->{branchcode};
36
my @other_branches = grep { $_ ne $borrower_branchcode } @{ $dbh->selectcol_arrayref("SELECT branchcode FROM branches") };
47
my @other_branches = grep { $_ ne $borrower_branchcode } keys GetBranches;
37
my $least_cost_branch_code = pop @other_branches
48
my $least_cost_branch_code = pop @other_branches
38
  or BAIL_OUT("No point testing only one branch...");
49
  or BAIL_OUT("No point testing only one branch...");
39
my $itemtype = $dbh->selectrow_array("SELECT min(itemtype) FROM itemtypes WHERE notforloan = 0")
50
my @item_types = C4::ItemType->all;
51
my $itemtype = grep { $_->{notforloan} == 1 } @item_types
40
  or BAIL_OUT("No adequate itemtype");
52
  or BAIL_OUT("No adequate itemtype");
41
53
42
# Start transaction
43
$dbh->{AutoCommit} = 0;
44
$dbh->{RaiseError} = 1;
45
46
#Set up the stage
54
#Set up the stage
47
# Sysprefs and cost matrix
55
# Sysprefs and cost matrix
48
$dbh->do("UPDATE systempreferences SET value = ? WHERE variable = 'StaticHoldsQueueWeight'", undef,
56
$dbh->do("UPDATE systempreferences SET value = ? WHERE variable = 'StaticHoldsQueueWeight'", undef,
Lines 144-151 ok( $queue_item Link Here
144
# Cleanup
152
# Cleanup
145
$dbh->rollback;
153
$dbh->rollback;
146
154
147
exit;
148
149
sub test_queue {
155
sub test_queue {
150
    my ($test_name, $use_cost_matrix, $pick_branch, $hold_branch) = @_;
156
    my ($test_name, $use_cost_matrix, $pick_branch, $hold_branch) = @_;
151
157
152
- 

Return to bug 10336