|
Lines 191-211
subtest 'AutoRemoveOverduesRestrictions' => sub {
Link Here
|
| 191 |
my $categorycode = $patron->categorycode; |
191 |
my $categorycode = $patron->categorycode; |
| 192 |
my $branchcode = $patron->branchcode; |
192 |
my $branchcode = $patron->branchcode; |
| 193 |
|
193 |
|
| 194 |
$dbh->do( |
194 |
Koha::CirculationRules->search->delete; |
| 195 |
qq{ |
195 |
Koha::CirculationRules->set_rules( |
| 196 |
INSERT INTO `overduerules` ( |
196 |
{ |
| 197 |
`categorycode`, |
197 |
categorycode => $categorycode, |
| 198 |
`delay1`, |
198 |
itemtype => undef, |
| 199 |
`letter1`, |
199 |
branchcode => undef, |
| 200 |
`debarred1`, |
200 |
rules => { |
| 201 |
`delay2`, |
201 |
overdue_1_delay => 6, |
| 202 |
`letter2`, |
202 |
overdue_1_notice => 'ODUE', |
| 203 |
`debarred2` |
203 |
overdue_1_mtt => 'email', |
| 204 |
) |
204 |
overdue_1_restrict => 0, |
| 205 |
VALUES ('$categorycode', 6, 'ODUE', 0, 10, 'ODUE2', 1) |
205 |
overdue_2_delay => 10, |
| 206 |
} |
206 |
overdue_2_notice => 'ODUE2', |
|
|
207 |
overdue_2_mtt => 'email', |
| 208 |
overdue_2_restrict => 1 |
| 209 |
} |
| 210 |
} |
| 207 |
); |
211 |
); |
| 208 |
|
212 |
|
|
|
213 |
note("Testing when_no_overdue"); |
| 209 |
t::lib::Mocks::mock_preference( 'AutoRemoveOverduesRestrictions', 'when_no_overdue' ); |
214 |
t::lib::Mocks::mock_preference( 'AutoRemoveOverduesRestrictions', 'when_no_overdue' ); |
| 210 |
|
215 |
|
| 211 |
t::lib::Mocks::mock_userenv( { branchcode => $branchcode } ); |
216 |
t::lib::Mocks::mock_userenv( { branchcode => $branchcode } ); |
|
Lines 236-241
subtest 'AutoRemoveOverduesRestrictions' => sub {
Link Here
|
| 236 |
$restrictions = $patron->restrictions; |
241 |
$restrictions = $patron->restrictions; |
| 237 |
is( $restrictions->count, 0, 'OVERDUES debarment is removed if patron does not have overdues' ); |
242 |
is( $restrictions->count, 0, 'OVERDUES debarment is removed if patron does not have overdues' ); |
| 238 |
|
243 |
|
|
|
244 |
note("Testing when_no_overdue_causing_debarment"); |
| 239 |
t::lib::Mocks::mock_preference( 'AutoRemoveOverduesRestrictions', 'when_no_overdue_causing_debarment' ); |
245 |
t::lib::Mocks::mock_preference( 'AutoRemoveOverduesRestrictions', 'when_no_overdue_causing_debarment' ); |
| 240 |
|
246 |
|
| 241 |
my $ten_days_ago = dt_from_string->subtract( days => 10 ); |
247 |
my $ten_days_ago = dt_from_string->subtract( days => 10 ); |
|
Lines 283-302
subtest 'AutoRemoveOverduesRestrictions' => sub {
Link Here
|
| 283 |
$checkout_2 = AddIssue( $patron, $item_2->barcode, $eleven_days_ago ); |
289 |
$checkout_2 = AddIssue( $patron, $item_2->barcode, $eleven_days_ago ); |
| 284 |
|
290 |
|
| 285 |
# $checkout_1 should now not trigger debarment with this new rule for specific branchcode |
291 |
# $checkout_1 should now not trigger debarment with this new rule for specific branchcode |
| 286 |
$dbh->do( |
292 |
Koha::CirculationRules->set_rules( |
| 287 |
qq{ |
293 |
{ |
| 288 |
INSERT INTO `overduerules` ( |
294 |
categorycode => $categorycode, |
| 289 |
`branchcode`, |
295 |
itemtype => undef, |
| 290 |
`categorycode`, |
296 |
branchcode => $branchcode, |
| 291 |
`delay1`, |
297 |
rules => { |
| 292 |
`letter1`, |
298 |
overdue_1_delay => 6, |
| 293 |
`debarred1`, |
299 |
overdue_1_notice => 'ODUE', |
| 294 |
`delay2`, |
300 |
overdue_1_mtt => 'email', |
| 295 |
`letter2`, |
301 |
overdue_1_restrict => 0, |
| 296 |
`debarred2` |
302 |
overdue_2_delay => 11, |
| 297 |
) |
303 |
overdue_2_notice => 'ODUE2', |
| 298 |
VALUES ('$branchcode', '$categorycode', 6, 'ODUE', 0, 11, 'ODUE2', 1) |
304 |
overdue_2_mtt => 'email', |
| 299 |
} |
305 |
overdue_2_restrict => 1 |
|
|
306 |
} |
| 307 |
} |
| 300 |
); |
308 |
); |
| 301 |
|
309 |
|
| 302 |
C4::Circulation::MarkIssueReturned( $patron->borrowernumber, $item_2->itemnumber ); |
310 |
C4::Circulation::MarkIssueReturned( $patron->borrowernumber, $item_2->itemnumber ); |
| 303 |
- |
|
|