|
Lines 134-140
subtest 'Manually pass a return date' => sub {
Link Here
|
| 134 |
my $category = $builder->build_object( { class => 'Koha::Patron::Categories', value => { category_type => 'P', enrolmentfee => 0 } } ); |
134 |
my $category = $builder->build_object( { class => 'Koha::Patron::Categories', value => { category_type => 'P', enrolmentfee => 0 } } ); |
| 135 |
my $library = $builder->build_object( { class => 'Koha::Libraries' } ); |
135 |
my $library = $builder->build_object( { class => 'Koha::Libraries' } ); |
| 136 |
my $patron = $builder->build_object( |
136 |
my $patron = $builder->build_object( |
| 137 |
{ class => 'Koha::Patrons', |
137 |
{ |
|
|
138 |
class => 'Koha::Patrons', |
| 138 |
value => { branchcode => $library->branchcode, categorycode => $category->categorycode } |
139 |
value => { branchcode => $library->branchcode, categorycode => $category->categorycode } |
| 139 |
} |
140 |
} |
| 140 |
); |
141 |
); |
|
Lines 182-202
subtest 'AutoRemoveOverduesRestrictions' => sub {
Link Here
|
| 182 |
my $categorycode = $patron->categorycode; |
183 |
my $categorycode = $patron->categorycode; |
| 183 |
my $branchcode = $patron->branchcode; |
184 |
my $branchcode = $patron->branchcode; |
| 184 |
|
185 |
|
| 185 |
$dbh->do( |
186 |
Koha::CirculationRules->search->delete; |
| 186 |
qq{ |
187 |
Koha::CirculationRules->set_rules( |
| 187 |
INSERT INTO `overduerules` ( |
188 |
{ |
| 188 |
`categorycode`, |
189 |
categorycode => $categorycode, |
| 189 |
`delay1`, |
190 |
itemtype => undef, |
| 190 |
`letter1`, |
191 |
branchcode => undef, |
| 191 |
`debarred1`, |
192 |
rules => { |
| 192 |
`delay2`, |
193 |
overdue_1_delay => 6, |
| 193 |
`letter2`, |
194 |
overdue_1_notice => 'ODUE', |
| 194 |
`debarred2` |
195 |
overdue_1_mtt => 'email', |
| 195 |
) |
196 |
overdue_1_restrict => 0, |
| 196 |
VALUES ('$categorycode', 6, 'ODUE', 0, 10, 'ODUE2', 1) |
197 |
overdue_2_delay => 10, |
| 197 |
} |
198 |
overdue_2_notice => 'ODUE2', |
|
|
199 |
overdue_2_mtt => 'email', |
| 200 |
overdue_2_restrict => 1 |
| 201 |
} |
| 202 |
} |
| 198 |
); |
203 |
); |
| 199 |
|
204 |
|
|
|
205 |
note("Testing when_no_overdue"); |
| 200 |
t::lib::Mocks::mock_preference( 'AutoRemoveOverduesRestrictions', 'when_no_overdue' ); |
206 |
t::lib::Mocks::mock_preference( 'AutoRemoveOverduesRestrictions', 'when_no_overdue' ); |
| 201 |
|
207 |
|
| 202 |
t::lib::Mocks::mock_userenv( { branchcode => $branchcode } ); |
208 |
t::lib::Mocks::mock_userenv( { branchcode => $branchcode } ); |
|
Lines 230-235
subtest 'AutoRemoveOverduesRestrictions' => sub {
Link Here
|
| 230 |
$restrictions = $patron->restrictions; |
236 |
$restrictions = $patron->restrictions; |
| 231 |
is( $restrictions->count, 0, 'OVERDUES debarment is removed if patron does not have overdues' ); |
237 |
is( $restrictions->count, 0, 'OVERDUES debarment is removed if patron does not have overdues' ); |
| 232 |
|
238 |
|
|
|
239 |
note("Testing when_no_overdue_causing_debarment"); |
| 233 |
t::lib::Mocks::mock_preference( 'AutoRemoveOverduesRestrictions', 'when_no_overdue_causing_debarment' ); |
240 |
t::lib::Mocks::mock_preference( 'AutoRemoveOverduesRestrictions', 'when_no_overdue_causing_debarment' ); |
| 234 |
|
241 |
|
| 235 |
my $ten_days_ago = dt_from_string->subtract( days => 10 ); |
242 |
my $ten_days_ago = dt_from_string->subtract( days => 10 ); |
|
Lines 278-297
subtest 'AutoRemoveOverduesRestrictions' => sub {
Link Here
|
| 278 |
$checkout_2 = AddIssue( $patron, $item_2->barcode, $eleven_days_ago ); |
285 |
$checkout_2 = AddIssue( $patron, $item_2->barcode, $eleven_days_ago ); |
| 279 |
|
286 |
|
| 280 |
# $checkout_1 should now not trigger debarment with this new rule for specific branchcode |
287 |
# $checkout_1 should now not trigger debarment with this new rule for specific branchcode |
| 281 |
$dbh->do( |
288 |
Koha::CirculationRules->set_rules( |
| 282 |
qq{ |
289 |
{ |
| 283 |
INSERT INTO `overduerules` ( |
290 |
categorycode => $categorycode, |
| 284 |
`branchcode`, |
291 |
itemtype => undef, |
| 285 |
`categorycode`, |
292 |
branchcode => $branchcode, |
| 286 |
`delay1`, |
293 |
rules => { |
| 287 |
`letter1`, |
294 |
overdue_1_delay => 6, |
| 288 |
`debarred1`, |
295 |
overdue_1_notice => 'ODUE', |
| 289 |
`delay2`, |
296 |
overdue_1_mtt => 'email', |
| 290 |
`letter2`, |
297 |
overdue_1_restrict => 0, |
| 291 |
`debarred2` |
298 |
overdue_2_delay => 11, |
| 292 |
) |
299 |
overdue_2_notice => 'ODUE2', |
| 293 |
VALUES ('$branchcode', '$categorycode', 6, 'ODUE', 0, 11, 'ODUE2', 1) |
300 |
overdue_2_mtt => 'email', |
| 294 |
} |
301 |
overdue_2_restrict => 1 |
|
|
302 |
} |
| 303 |
} |
| 295 |
); |
304 |
); |
| 296 |
|
305 |
|
| 297 |
C4::Circulation::MarkIssueReturned( $patron->borrowernumber, $item_2->itemnumber ); |
306 |
C4::Circulation::MarkIssueReturned( $patron->borrowernumber, $item_2->itemnumber ); |
| 298 |
- |
|
|