|
Lines 2540-2546
subtest 'filter_by_for_hold' => sub {
Link Here
|
| 2540 |
}; |
2540 |
}; |
| 2541 |
|
2541 |
|
| 2542 |
subtest 'filter_by_bookable' => sub { |
2542 |
subtest 'filter_by_bookable' => sub { |
| 2543 |
plan tests => 4; |
2543 |
plan tests => 7; |
| 2544 |
|
2544 |
|
| 2545 |
$schema->storage->txn_begin; |
2545 |
$schema->storage->txn_begin; |
| 2546 |
|
2546 |
|
|
Lines 2584-2589
subtest 'filter_by_bookable' => sub {
Link Here
|
| 2584 |
"filter_by_bookable returns the correct number of items when not set at item level and using item level itemtypes" |
2584 |
"filter_by_bookable returns the correct number of items when not set at item level and using item level itemtypes" |
| 2585 |
); |
2585 |
); |
| 2586 |
|
2586 |
|
|
|
2587 |
note("Parent itemtype fallback tests for filter_by_bookable"); |
| 2588 |
|
| 2589 |
my $parent_itype = |
| 2590 |
$builder->build_object( { class => 'Koha::ItemTypes', value => { bookable => 1, parent_type => undef } } ); |
| 2591 |
my $child_itype = $builder->build_object( |
| 2592 |
{ class => 'Koha::ItemTypes', value => { bookable => 0, parent_type => $parent_itype->itemtype } } ); |
| 2593 |
|
| 2594 |
my $biblio2 = $builder->build_sample_biblio( { itemtype => $child_itype->itemtype } ); |
| 2595 |
my $child_item = $builder->build_sample_item( |
| 2596 |
{ biblionumber => $biblio2->biblionumber, itype => $child_itype->itemtype, bookable => undef } ); |
| 2597 |
|
| 2598 |
t::lib::Mocks::mock_preference( 'item-level_itypes', 1 ); |
| 2599 |
is( |
| 2600 |
$biblio2->items->filter_by_bookable->count, 1, |
| 2601 |
"filter_by_bookable includes child of bookable parent (item-level_itypes=1)" |
| 2602 |
); |
| 2603 |
|
| 2604 |
t::lib::Mocks::mock_preference( 'item-level_itypes', 0 ); |
| 2605 |
is( |
| 2606 |
$biblio2->items->filter_by_bookable->count, 1, |
| 2607 |
"filter_by_bookable includes child of bookable parent (item-level_itypes=0)" |
| 2608 |
); |
| 2609 |
|
| 2610 |
$child_item->bookable(0)->store(); |
| 2611 |
$child_item->discard_changes; |
| 2612 |
is( |
| 2613 |
$biblio2->items->filter_by_bookable->count, 0, |
| 2614 |
"filter_by_bookable excludes item with explicit bookable=0 even if parent is bookable" |
| 2615 |
); |
| 2616 |
|
| 2587 |
$schema->storage->txn_rollback; |
2617 |
$schema->storage->txn_rollback; |
| 2588 |
}; |
2618 |
}; |
| 2589 |
|
2619 |
|
| 2590 |
- |
|
|