Lines 64-70
for my $i ( 1 .. 10 ) {
Link Here
|
64 |
push( @items, $item ); |
64 |
push( @items, $item ); |
65 |
} |
65 |
} |
66 |
|
66 |
|
67 |
for my $i ( 0 .. 4 ) { |
67 |
for my $i ( 0 .. 5 ) { |
68 |
my $patron = $patrons[$i]; |
68 |
my $patron = $patrons[$i]; |
69 |
my $hold = Koha::Hold->new( |
69 |
my $hold = Koha::Hold->new( |
70 |
{ |
70 |
{ |
Lines 92-99
my $item_hr = { itemnumber => $item->id, biblionumber => $biblio->id, homebranch
Link Here
|
92 |
my $patron_hr = { borrower => $patron->id, branchcode => 'MPL' }; |
92 |
my $patron_hr = { borrower => $patron->id, branchcode => 'MPL' }; |
93 |
|
93 |
|
94 |
my $data = C4::Circulation::checkHighHolds( $item_hr, $patron_hr ); |
94 |
my $data = C4::Circulation::checkHighHolds( $item_hr, $patron_hr ); |
95 |
is( $data->{exceeded}, 1, "Should exceed threshold" ); |
95 |
is( $data->{exceeded}, 1, "Static mode should exceed threshold" ); |
96 |
is( $data->{outstanding}, 5, "Should have 5 outstanding holds" ); |
96 |
is( $data->{outstanding}, 6, "Should have 5 outstanding holds" ); |
97 |
is( $data->{duration}, 1, "Should have duration of 1" ); |
97 |
is( $data->{duration}, 1, "Should have duration of 1" ); |
98 |
is( ref( $data->{due_date} ), 'DateTime', "due_date should be a DateTime object" ); |
98 |
is( ref( $data->{due_date} ), 'DateTime', "due_date should be a DateTime object" ); |
99 |
|
99 |
|
Lines 113-151
for my $i ( 5 .. 10 ) {
Link Here
|
113 |
} |
113 |
} |
114 |
|
114 |
|
115 |
$data = C4::Circulation::checkHighHolds( $item_hr, $patron_hr ); |
115 |
$data = C4::Circulation::checkHighHolds( $item_hr, $patron_hr ); |
116 |
is( $data->{exceeded}, 1, "Should exceed threshold" ); |
116 |
is( $data->{exceeded}, 1, "Should exceed threshold of 1" ); |
117 |
|
117 |
|
118 |
C4::Context->set_preference( 'decreaseLoanHighHoldsValue', 2 ); |
118 |
C4::Context->set_preference( 'decreaseLoanHighHoldsValue', 2 ); |
119 |
$data = C4::Circulation::checkHighHolds( $item_hr, $patron_hr ); |
119 |
$data = C4::Circulation::checkHighHolds( $item_hr, $patron_hr ); |
120 |
is( $data->{exceeded}, 0, "Should not exceed threshold" ); |
120 |
is( $data->{exceeded}, 0, "Should not exceed threshold of 2" ); |
121 |
|
121 |
|
122 |
my $unholdable = pop(@items); |
122 |
my $unholdable = pop(@items); |
123 |
$unholdable->damaged(-1); |
123 |
$unholdable->damaged(-1); |
124 |
$unholdable->store(); |
124 |
$unholdable->store(); |
125 |
|
125 |
|
126 |
$data = C4::Circulation::checkHighHolds( $item_hr, $patron_hr ); |
126 |
$data = C4::Circulation::checkHighHolds( $item_hr, $patron_hr ); |
127 |
is( $data->{exceeded}, 1, "Should exceed threshold" ); |
127 |
is( $data->{exceeded}, 1, "Should exceed threshold with one damanged item" ); |
128 |
|
128 |
|
129 |
$unholdable->damaged(0); |
129 |
$unholdable->damaged(0); |
130 |
$unholdable->itemlost(-1); |
130 |
$unholdable->itemlost(-1); |
131 |
$unholdable->store(); |
131 |
$unholdable->store(); |
132 |
|
132 |
|
133 |
$data = C4::Circulation::checkHighHolds( $item_hr, $patron_hr ); |
133 |
$data = C4::Circulation::checkHighHolds( $item_hr, $patron_hr ); |
134 |
is( $data->{exceeded}, 1, "Should exceed threshold" ); |
134 |
is( $data->{exceeded}, 1, "Should exceed threshold with one lost item" ); |
135 |
|
135 |
|
136 |
$unholdable->itemlost(0); |
136 |
$unholdable->itemlost(0); |
137 |
$unholdable->notforloan(-1); |
137 |
$unholdable->notforloan(-1); |
138 |
$unholdable->store(); |
138 |
$unholdable->store(); |
139 |
|
139 |
|
140 |
$data = C4::Circulation::checkHighHolds( $item_hr, $patron_hr ); |
140 |
$data = C4::Circulation::checkHighHolds( $item_hr, $patron_hr ); |
141 |
is( $data->{exceeded}, 1, "Should exceed threshold" ); |
141 |
is( $data->{exceeded}, 1, "Should exceed threshold wiht one notforloan item" ); |
142 |
|
142 |
|
143 |
$unholdable->notforloan(0); |
143 |
$unholdable->notforloan(0); |
144 |
$unholdable->withdrawn(-1); |
144 |
$unholdable->withdrawn(-1); |
145 |
$unholdable->store(); |
145 |
$unholdable->store(); |
146 |
|
146 |
|
147 |
$data = C4::Circulation::checkHighHolds( $item_hr, $patron_hr ); |
147 |
$data = C4::Circulation::checkHighHolds( $item_hr, $patron_hr ); |
148 |
is( $data->{exceeded}, 1, "Should exceed threshold" ); |
148 |
is( $data->{exceeded}, 1, "Should exceed threshold with one withdrawn item" ); |
149 |
|
149 |
|
150 |
$schema->storage->txn_rollback(); |
150 |
$schema->storage->txn_rollback(); |
151 |
1; |
151 |
1; |
152 |
- |
|
|