|
Lines 17-24
Link Here
|
| 17 |
|
17 |
|
| 18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
| 19 |
|
19 |
|
| 20 |
use DateTime; |
|
|
| 21 |
|
| 22 |
use C4::Circulation; |
20 |
use C4::Circulation; |
| 23 |
use Koha::Database; |
21 |
use Koha::Database; |
| 24 |
use Koha::Borrower; |
22 |
use Koha::Borrower; |
|
Lines 26-36
use Koha::Biblio;
Link Here
|
| 26 |
use Koha::Item; |
24 |
use Koha::Item; |
| 27 |
use Koha::Holds; |
25 |
use Koha::Holds; |
| 28 |
use Koha::Hold; |
26 |
use Koha::Hold; |
|
|
27 |
use t::lib::TestBuilder; |
| 29 |
|
28 |
|
| 30 |
use Test::More tests => 12; |
29 |
use Test::More tests => 12; |
| 31 |
|
30 |
|
| 32 |
my $dbh = C4::Context->dbh; |
31 |
my $dbh = C4::Context->dbh; |
| 33 |
my $schema = Koha::Database->new()->schema(); |
32 |
my $schema = Koha::Database->new()->schema(); |
|
|
33 |
my $builder = t::lib::TestBuilder->new; |
| 34 |
|
34 |
|
| 35 |
# Start transaction |
35 |
# Start transaction |
| 36 |
$dbh->{RaiseError} = 1; |
36 |
$dbh->{RaiseError} = 1; |
|
Lines 41-55
$dbh->do('DELETE FROM issuingrules');
Link Here
|
| 41 |
$dbh->do('DELETE FROM borrowers'); |
41 |
$dbh->do('DELETE FROM borrowers'); |
| 42 |
$dbh->do('DELETE FROM items'); |
42 |
$dbh->do('DELETE FROM items'); |
| 43 |
|
43 |
|
|
|
44 |
my $library = $builder->build({source => 'Branch'}); |
| 45 |
my $category = $builder->build({source => 'Category'}); |
| 46 |
|
| 44 |
# Set userenv |
47 |
# Set userenv |
| 45 |
C4::Context->_new_userenv('xxx'); |
48 |
C4::Context->_new_userenv('xxx'); |
| 46 |
C4::Context->set_userenv( 0, 0, 0, 'firstname', 'surname', 'MPL', 'Midway Public Library', '', '', '' ); |
49 |
C4::Context->set_userenv( 0, 0, 0, 'firstname', 'surname', $library->{branchcode}, 'Midway Public Library', '', '', '' ); |
| 47 |
is( C4::Context->userenv->{branch}, 'MPL', 'userenv set' ); |
50 |
is( C4::Context->userenv->{branch}, $library->{branchcode}, 'userenv set' ); |
| 48 |
|
51 |
|
| 49 |
my @patrons; |
52 |
my @patrons; |
| 50 |
for my $i ( 1 .. 20 ) { |
53 |
for my $i ( 1 .. 20 ) { |
| 51 |
my $patron = Koha::Borrower->new( |
54 |
my $patron = Koha::Borrower->new( |
| 52 |
{ cardnumber => $i, firstname => 'Kyle', surname => 'Hall', categorycode => 'S', branchcode => 'MPL' } ) |
55 |
{ cardnumber => $i, firstname => 'Kyle', surname => 'Hall', categorycode => $category->{categorycode}, branchcode => $library->{branchcode} } ) |
| 53 |
->store(); |
56 |
->store(); |
| 54 |
push( @patrons, $patron ); |
57 |
push( @patrons, $patron ); |
| 55 |
} |
58 |
} |
|
Lines 70-83
for my $i ( 0 .. 5 ) {
Link Here
|
| 70 |
{ |
73 |
{ |
| 71 |
borrowernumber => $patron->id, |
74 |
borrowernumber => $patron->id, |
| 72 |
biblionumber => $biblio->id, |
75 |
biblionumber => $biblio->id, |
| 73 |
branchcode => 'MPL', |
76 |
branchcode => $library->{branchcode}, |
| 74 |
} |
77 |
} |
| 75 |
)->store(); |
78 |
)->store(); |
| 76 |
} |
79 |
} |
| 77 |
|
80 |
|
| 78 |
$schema->resultset('Issuingrule') |
81 |
$builder->build( |
| 79 |
->new( { branchcode => '*', categorycode => '*', itemtype => '*', issuelength => '14', lengthunit => 'days', reservesallowed => '99' } ) |
82 |
{ |
| 80 |
->insert(); |
83 |
source => 'Issuingrule', |
|
|
84 |
value => { |
| 85 |
branchcode => '*', |
| 86 |
categorycode => '*', |
| 87 |
itemtype => '*', |
| 88 |
issuelength => '14', |
| 89 |
lengthunit => 'days', |
| 90 |
reservesallowed => '99', |
| 91 |
} |
| 92 |
} |
| 93 |
); |
| 81 |
|
94 |
|
| 82 |
my $item = pop(@items); |
95 |
my $item = pop(@items); |
| 83 |
my $patron = pop(@patrons); |
96 |
my $patron = pop(@patrons); |
|
Lines 88-95
C4::Context->set_preference( 'decreaseLoanHighHoldsValue', 1 );
Link Here
|
| 88 |
C4::Context->set_preference( 'decreaseLoanHighHoldsControl', 'static' ); |
101 |
C4::Context->set_preference( 'decreaseLoanHighHoldsControl', 'static' ); |
| 89 |
C4::Context->set_preference( 'decreaseLoanHighHoldsIgnoreStatuses', 'damaged,itemlost,notforloan,withdrawn' ); |
102 |
C4::Context->set_preference( 'decreaseLoanHighHoldsIgnoreStatuses', 'damaged,itemlost,notforloan,withdrawn' ); |
| 90 |
|
103 |
|
| 91 |
my $item_hr = { itemnumber => $item->id, biblionumber => $biblio->id, homebranch => 'MPL', holdingbranch => 'MPL' }; |
104 |
my $item_hr = { itemnumber => $item->id, biblionumber => $biblio->id, homebranch => $library->{branchcode}, holdingbranch => $library->{branchcode} }; |
| 92 |
my $patron_hr = { borrower => $patron->id, branchcode => 'MPL' }; |
105 |
my $patron_hr = { borrower => $patron->id, branchcode => $library->{branchcode} }; |
| 93 |
|
106 |
|
| 94 |
my $data = C4::Circulation::checkHighHolds( $item_hr, $patron_hr ); |
107 |
my $data = C4::Circulation::checkHighHolds( $item_hr, $patron_hr ); |
| 95 |
is( $data->{exceeded}, 1, "Static mode should exceed threshold" ); |
108 |
is( $data->{exceeded}, 1, "Static mode should exceed threshold" ); |
|
Lines 107-113
for my $i ( 5 .. 10 ) {
Link Here
|
| 107 |
{ |
120 |
{ |
| 108 |
borrowernumber => $patron->id, |
121 |
borrowernumber => $patron->id, |
| 109 |
biblionumber => $biblio->id, |
122 |
biblionumber => $biblio->id, |
| 110 |
branchcode => 'MPL', |
123 |
branchcode => $library->{branchcode}, |
| 111 |
} |
124 |
} |
| 112 |
)->store(); |
125 |
)->store(); |
| 113 |
} |
126 |
} |
| 114 |
- |
|
|