Lines 1380-1420
subtest 'filter_by_visible_in_opac() tests' => sub {
Link Here
|
1380 |
} |
1380 |
} |
1381 |
); |
1381 |
); |
1382 |
|
1382 |
|
1383 |
my $rules = {}; |
1383 |
my $rules = undef; |
|
|
1384 |
|
1385 |
my $mocked_context = Test::MockModule->new('C4::Context'); |
1386 |
$mocked_context->mock( 'yaml_preference', sub { |
1387 |
return $rules; |
1388 |
}); |
1384 |
|
1389 |
|
1385 |
t::lib::Mocks::mock_preference( 'hidelostitems', 0 ); |
1390 |
t::lib::Mocks::mock_preference( 'hidelostitems', 0 ); |
1386 |
is( $biblio->items->filter_by_visible_in_opac->count, |
1391 |
is( $biblio->items->filter_by_visible_in_opac->count, |
1387 |
6, 'No rules passed, hidelostitems unset' ); |
1392 |
6, 'No rules passed, hidelostitems unset' ); |
1388 |
|
1393 |
|
|
|
1394 |
$rules = {}; |
1395 |
|
1389 |
t::lib::Mocks::mock_preference( 'hidelostitems', 1 ); |
1396 |
t::lib::Mocks::mock_preference( 'hidelostitems', 1 ); |
1390 |
is( |
1397 |
is( |
1391 |
$biblio->items->filter_by_visible_in_opac( { rules => $rules } )->count, |
1398 |
$biblio->items->filter_by_visible_in_opac->count, |
1392 |
3, |
1399 |
3, |
1393 |
'No rules passed, hidelostitems set' |
1400 |
'No rules passed, hidelostitems set' |
1394 |
); |
1401 |
); |
1395 |
|
1402 |
|
1396 |
$rules = { withdrawn => [ 1, 2 ] }; |
1403 |
$rules = { withdrawn => [ 1, 2 ] }; |
1397 |
is( |
1404 |
is( |
1398 |
$biblio->items->filter_by_visible_in_opac( { rules => $rules } )->count, |
1405 |
$biblio->items->filter_by_visible_in_opac->count, |
1399 |
2, |
1406 |
2, |
1400 |
'Rules on withdrawn, hidelostitems set' |
1407 |
'Rules on withdrawn, hidelostitems set' |
1401 |
); |
1408 |
); |
1402 |
|
1409 |
|
1403 |
$rules = { itype => [ $itype_1->itemtype ] }; |
1410 |
$rules = { itype => [ $itype_1->itemtype ] }; |
1404 |
is( |
1411 |
is( |
1405 |
$biblio->items->filter_by_visible_in_opac( { rules => $rules } )->count, |
1412 |
$biblio->items->filter_by_visible_in_opac->count, |
1406 |
2, |
1413 |
2, |
1407 |
'Rules on itype, hidelostitems set' |
1414 |
'Rules on itype, hidelostitems set' |
1408 |
); |
1415 |
); |
1409 |
|
1416 |
|
1410 |
$rules = { withdrawn => [ 1, 2 ], itype => [ $itype_1->itemtype ] }; |
1417 |
$rules = { withdrawn => [ 1, 2 ], itype => [ $itype_1->itemtype ] }; |
1411 |
is( |
1418 |
is( |
1412 |
$biblio->items->filter_by_visible_in_opac( { rules => $rules } )->count, |
1419 |
$biblio->items->filter_by_visible_in_opac->count, |
1413 |
1, |
1420 |
1, |
1414 |
'Rules on itype and withdrawn, hidelostitems set' |
1421 |
'Rules on itype and withdrawn, hidelostitems set' |
1415 |
); |
1422 |
); |
1416 |
is( |
1423 |
is( |
1417 |
$biblio->items->filter_by_visible_in_opac( { rules => $rules } ) |
1424 |
$biblio->items->filter_by_visible_in_opac |
1418 |
->next->itemnumber, |
1425 |
->next->itemnumber, |
1419 |
$item_4->itemnumber, |
1426 |
$item_4->itemnumber, |
1420 |
'The right item is returned' |
1427 |
'The right item is returned' |
Lines 1422-1433
subtest 'filter_by_visible_in_opac() tests' => sub {
Link Here
|
1422 |
|
1429 |
|
1423 |
$rules = { withdrawn => [ 1, 2 ], itype => [ $itype_2->itemtype ] }; |
1430 |
$rules = { withdrawn => [ 1, 2 ], itype => [ $itype_2->itemtype ] }; |
1424 |
is( |
1431 |
is( |
1425 |
$biblio->items->filter_by_visible_in_opac( { rules => $rules } )->count, |
1432 |
$biblio->items->filter_by_visible_in_opac->count, |
1426 |
1, |
1433 |
1, |
1427 |
'Rules on itype and withdrawn, hidelostitems set' |
1434 |
'Rules on itype and withdrawn, hidelostitems set' |
1428 |
); |
1435 |
); |
1429 |
is( |
1436 |
is( |
1430 |
$biblio->items->filter_by_visible_in_opac( { rules => $rules } ) |
1437 |
$biblio->items->filter_by_visible_in_opac |
1431 |
->next->itemnumber, |
1438 |
->next->itemnumber, |
1432 |
$item_5->itemnumber, |
1439 |
$item_5->itemnumber, |
1433 |
'The right item is returned' |
1440 |
'The right item is returned' |
1434 |
- |
|
|