|
Lines 303-343
subtest 'filter_by_visible_in_opac() tests' => sub {
Link Here
|
| 303 |
} |
303 |
} |
| 304 |
); |
304 |
); |
| 305 |
|
305 |
|
| 306 |
my $rules = {}; |
306 |
my $rules = undef; |
|
|
307 |
|
| 308 |
my $mocked_context = Test::MockModule->new('C4::Context'); |
| 309 |
$mocked_context->mock( 'yaml_preference', sub { |
| 310 |
return $rules; |
| 311 |
}); |
| 307 |
|
312 |
|
| 308 |
t::lib::Mocks::mock_preference( 'hidelostitems', 0 ); |
313 |
t::lib::Mocks::mock_preference( 'hidelostitems', 0 ); |
| 309 |
is( $biblio->items->filter_by_visible_in_opac->count, |
314 |
is( $biblio->items->filter_by_visible_in_opac->count, |
| 310 |
6, 'No rules passed, hidelostitems unset' ); |
315 |
6, 'No rules passed, hidelostitems unset' ); |
| 311 |
|
316 |
|
|
|
317 |
$rules = {}; |
| 318 |
|
| 312 |
t::lib::Mocks::mock_preference( 'hidelostitems', 1 ); |
319 |
t::lib::Mocks::mock_preference( 'hidelostitems', 1 ); |
| 313 |
is( |
320 |
is( |
| 314 |
$biblio->items->filter_by_visible_in_opac( { rules => $rules } )->count, |
321 |
$biblio->items->filter_by_visible_in_opac->count, |
| 315 |
3, |
322 |
3, |
| 316 |
'No rules passed, hidelostitems set' |
323 |
'No rules passed, hidelostitems set' |
| 317 |
); |
324 |
); |
| 318 |
|
325 |
|
| 319 |
$rules = { withdrawn => [ 1, 2 ] }; |
326 |
$rules = { withdrawn => [ 1, 2 ] }; |
| 320 |
is( |
327 |
is( |
| 321 |
$biblio->items->filter_by_visible_in_opac( { rules => $rules } )->count, |
328 |
$biblio->items->filter_by_visible_in_opac->count, |
| 322 |
2, |
329 |
2, |
| 323 |
'Rules on withdrawn, hidelostitems set' |
330 |
'Rules on withdrawn, hidelostitems set' |
| 324 |
); |
331 |
); |
| 325 |
|
332 |
|
| 326 |
$rules = { itype => [ $itype_1->itemtype ] }; |
333 |
$rules = { itype => [ $itype_1->itemtype ] }; |
| 327 |
is( |
334 |
is( |
| 328 |
$biblio->items->filter_by_visible_in_opac( { rules => $rules } )->count, |
335 |
$biblio->items->filter_by_visible_in_opac->count, |
| 329 |
2, |
336 |
2, |
| 330 |
'Rules on itype, hidelostitems set' |
337 |
'Rules on itype, hidelostitems set' |
| 331 |
); |
338 |
); |
| 332 |
|
339 |
|
| 333 |
$rules = { withdrawn => [ 1, 2 ], itype => [ $itype_1->itemtype ] }; |
340 |
$rules = { withdrawn => [ 1, 2 ], itype => [ $itype_1->itemtype ] }; |
| 334 |
is( |
341 |
is( |
| 335 |
$biblio->items->filter_by_visible_in_opac( { rules => $rules } )->count, |
342 |
$biblio->items->filter_by_visible_in_opac->count, |
| 336 |
1, |
343 |
1, |
| 337 |
'Rules on itype and withdrawn, hidelostitems set' |
344 |
'Rules on itype and withdrawn, hidelostitems set' |
| 338 |
); |
345 |
); |
| 339 |
is( |
346 |
is( |
| 340 |
$biblio->items->filter_by_visible_in_opac( { rules => $rules } ) |
347 |
$biblio->items->filter_by_visible_in_opac |
| 341 |
->next->itemnumber, |
348 |
->next->itemnumber, |
| 342 |
$item_4->itemnumber, |
349 |
$item_4->itemnumber, |
| 343 |
'The right item is returned' |
350 |
'The right item is returned' |
|
Lines 345-356
subtest 'filter_by_visible_in_opac() tests' => sub {
Link Here
|
| 345 |
|
352 |
|
| 346 |
$rules = { withdrawn => [ 1, 2 ], itype => [ $itype_2->itemtype ] }; |
353 |
$rules = { withdrawn => [ 1, 2 ], itype => [ $itype_2->itemtype ] }; |
| 347 |
is( |
354 |
is( |
| 348 |
$biblio->items->filter_by_visible_in_opac( { rules => $rules } )->count, |
355 |
$biblio->items->filter_by_visible_in_opac->count, |
| 349 |
1, |
356 |
1, |
| 350 |
'Rules on itype and withdrawn, hidelostitems set' |
357 |
'Rules on itype and withdrawn, hidelostitems set' |
| 351 |
); |
358 |
); |
| 352 |
is( |
359 |
is( |
| 353 |
$biblio->items->filter_by_visible_in_opac( { rules => $rules } ) |
360 |
$biblio->items->filter_by_visible_in_opac |
| 354 |
->next->itemnumber, |
361 |
->next->itemnumber, |
| 355 |
$item_5->itemnumber, |
362 |
$item_5->itemnumber, |
| 356 |
'The right item is returned' |
363 |
'The right item is returned' |
| 357 |
- |
|
|