|
Lines 30-36
use Koha::CirculationRules;
Link Here
|
| 30 |
use t::lib::TestBuilder; |
30 |
use t::lib::TestBuilder; |
| 31 |
use t::lib::Mocks; |
31 |
use t::lib::Mocks; |
| 32 |
|
32 |
|
| 33 |
use Test::More tests => 22; |
33 |
use Test::More tests => 23; |
| 34 |
|
34 |
|
| 35 |
my $dbh = C4::Context->dbh; |
35 |
my $dbh = C4::Context->dbh; |
| 36 |
my $schema = Koha::Database->new()->schema(); |
36 |
my $schema = Koha::Database->new()->schema(); |
|
Lines 132-138
my $patron_hr = { borrowernumber => $patron->id, branchcode => $library->{branch
Link Here
|
| 132 |
|
132 |
|
| 133 |
my $data = C4::Circulation::checkHighHolds( $item_hr, $patron_hr ); |
133 |
my $data = C4::Circulation::checkHighHolds( $item_hr, $patron_hr ); |
| 134 |
is( $data->{exceeded}, 1, "Static mode should exceed threshold" ); |
134 |
is( $data->{exceeded}, 1, "Static mode should exceed threshold" ); |
| 135 |
is( $data->{outstanding}, 6, "Should have 6 outstanding holds" ); |
135 |
is( $data->{outstanding}, 5, "Should have 5 outstanding holds" ); |
| 136 |
is( $data->{duration}, 0, "Should have duration of 0 because of specific circulation rules" ); |
136 |
is( $data->{duration}, 0, "Should have duration of 0 because of specific circulation rules" ); |
| 137 |
is( ref( $data->{due_date} ), 'DateTime', "due_date should be a DateTime object" ); |
137 |
is( ref( $data->{due_date} ), 'DateTime', "due_date should be a DateTime object" ); |
| 138 |
|
138 |
|
|
Lines 164-171
$data = C4::Circulation::checkHighHolds( $item_hr, $patron_hr );
Link Here
|
| 164 |
is( $data->{exceeded}, 0, "Should not exceed threshold" ); |
164 |
is( $data->{exceeded}, 0, "Should not exceed threshold" ); |
| 165 |
|
165 |
|
| 166 |
|
166 |
|
| 167 |
# Place 6 more holds - patrons 5,6,7,8,9,10 |
167 |
# Place 7 more holds - patrons 5,6,7,8,9,10,11 |
| 168 |
for my $i ( 5 .. 10 ) { |
168 |
for my $i ( 5 .. 11 ) { |
| 169 |
my $patron = $patrons[$i]; |
169 |
my $patron = $patrons[$i]; |
| 170 |
my $hold = Koha::Hold->new( |
170 |
my $hold = Koha::Hold->new( |
| 171 |
{ |
171 |
{ |
|
Lines 176-181
for my $i ( 5 .. 10 ) {
Link Here
|
| 176 |
)->store(); |
176 |
)->store(); |
| 177 |
} |
177 |
} |
| 178 |
|
178 |
|
|
|
179 |
# Note in counts below, patron's own hold is not counted |
| 180 |
|
| 179 |
# 12 holds, threshold is 1 over 10 holdable items = 11 |
181 |
# 12 holds, threshold is 1 over 10 holdable items = 11 |
| 180 |
$data = C4::Circulation::checkHighHolds( $item_hr, $patron_hr ); |
182 |
$data = C4::Circulation::checkHighHolds( $item_hr, $patron_hr ); |
| 181 |
is( $data->{exceeded}, 1, "Should exceed threshold of 1" ); |
183 |
is( $data->{exceeded}, 1, "Should exceed threshold of 1" ); |
|
Lines 218-229
$unholdable->store();
Link Here
|
| 218 |
$data = C4::Circulation::checkHighHolds( $item_hr, $patron_hr ); |
220 |
$data = C4::Circulation::checkHighHolds( $item_hr, $patron_hr ); |
| 219 |
is( $data->{exceeded}, 1, "Should exceed threshold with one withdrawn item" ); |
221 |
is( $data->{exceeded}, 1, "Should exceed threshold with one withdrawn item" ); |
| 220 |
|
222 |
|
| 221 |
$patron_hold->found('F')->store; |
|
|
| 222 |
# 11 holds, threshold is 2 over 9 holdable items = 11 |
| 223 |
$data = C4::Circulation::checkHighHolds( $item_hr, $patron_hr ); |
| 224 |
is( $data->{exceeded}, 1, "Should exceed threshold with one withdrawn item" ); |
| 225 |
$patron_hold->found(undef)->store; |
| 226 |
|
| 227 |
t::lib::Mocks::mock_preference('CircControl', 'PatronLibrary'); |
223 |
t::lib::Mocks::mock_preference('CircControl', 'PatronLibrary'); |
| 228 |
|
224 |
|
| 229 |
my $patron_object = Koha::Patrons->find( $patron_hr->{borrowernumber} ); |
225 |
my $patron_object = Koha::Patrons->find( $patron_hr->{borrowernumber} ); |
| 230 |
- |
|
|