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 $branches = C4::Branch::GetBranches; |
|
|
48 |
my @other_branches = grep { $_ ne $borrower_branchcode } keys %$branches; |
37 |
my $least_cost_branch_code = pop @other_branches |
49 |
my $least_cost_branch_code = pop @other_branches |
38 |
or BAIL_OUT("No point testing only one branch..."); |
50 |
or BAIL_OUT("No point testing only one branch..."); |
39 |
my $itemtype = $dbh->selectrow_array("SELECT min(itemtype) FROM itemtypes WHERE notforloan = 0") |
51 |
my @item_types = C4::ItemType->all; |
|
|
52 |
my $itemtype = grep { $_->{notforloan} == 1 } @item_types |
40 |
or BAIL_OUT("No adequate itemtype"); |
53 |
or BAIL_OUT("No adequate itemtype"); |
41 |
|
54 |
|
42 |
# Start transaction |
|
|
43 |
$dbh->{AutoCommit} = 0; |
44 |
$dbh->{RaiseError} = 1; |
45 |
|
46 |
#Set up the stage |
55 |
#Set up the stage |
47 |
# Sysprefs and cost matrix |
56 |
# Sysprefs and cost matrix |
48 |
$dbh->do("UPDATE systempreferences SET value = ? WHERE variable = 'StaticHoldsQueueWeight'", undef, |
57 |
$dbh->do("UPDATE systempreferences SET value = ? WHERE variable = 'StaticHoldsQueueWeight'", undef, |
Lines 145-152
ok( $queue_item
Link Here
|
145 |
# Cleanup |
154 |
# Cleanup |
146 |
$dbh->rollback; |
155 |
$dbh->rollback; |
147 |
|
156 |
|
148 |
exit; |
|
|
149 |
|
150 |
sub test_queue { |
157 |
sub test_queue { |
151 |
my ($test_name, $use_cost_matrix, $pick_branch, $hold_branch) = @_; |
158 |
my ($test_name, $use_cost_matrix, $pick_branch, $hold_branch) = @_; |
152 |
|
159 |
|
153 |
- |
|
|