View | Details | Raw Unified | Return to bug 29802
Collapse All | Expand All

(-)a/t/db_dependent/Koha/Items.t (-1 / +13 lines)
Lines 1587-1593 $schema->storage->txn_rollback; Link Here
1587
1587
1588
subtest 'filter_by_visible_in_opac() tests' => sub {
1588
subtest 'filter_by_visible_in_opac() tests' => sub {
1589
1589
1590
    plan tests => 12;
1590
    plan tests => 14;
1591
1591
1592
    $schema->storage->txn_begin;
1592
    $schema->storage->txn_begin;
1593
1593
Lines 1688-1693 subtest 'filter_by_visible_in_opac() tests' => sub { Link Here
1688
        'No rules passed, hidelostitems set, patron exception changes nothing'
1688
        'No rules passed, hidelostitems set, patron exception changes nothing'
1689
    );
1689
    );
1690
1690
1691
    $rules = { biblionumber => [ $biblio->biblionumber ] };
1692
    is(
1693
        $biblio->items->filter_by_visible_in_opac->count,
1694
        0,
1695
        'Biblionumber rule successfully hides all items'
1696
    );
1697
1698
    my $biblio2 = $builder->build_sample_biblio;
1699
    $rules = { biblionumber => [ $biblio2->biblionumber ] };
1700
    my $prefetched = $biblio->items->search({},{ prefetch => ['branchtransfers','reserves'] })->filter_by_visible_in_opac;
1701
    ok( $prefetched->next, "Can retrieve object when prefetching and hiding on a duplicated column");
1702
1691
    $rules = { withdrawn => [ 1, 2 ], copynumber => [ 2 ] };
1703
    $rules = { withdrawn => [ 1, 2 ], copynumber => [ 2 ] };
1692
    is(
1704
    is(
1693
        $biblio->items->filter_by_visible_in_opac->count,
1705
        $biblio->items->filter_by_visible_in_opac->count,
(-)a/t/db_dependent/XSLT.t (-2 / +10 lines)
Lines 160-170 $schema->storage->txn_rollback; Link Here
160
160
161
subtest 'buildKohaItemsNamespace() including/omitting items tests' => sub {
161
subtest 'buildKohaItemsNamespace() including/omitting items tests' => sub {
162
162
163
    plan tests => 20;
163
    plan tests => 23;
164
164
165
    $schema->storage->txn_begin;
165
    $schema->storage->txn_begin;
166
166
167
    my $biblio = $builder->build_sample_biblio;
167
    my $biblio = $builder->build_sample_biblio;
168
    my $biblio2 = $builder->build_sample_biblio;
168
169
169
    # Have two known libraries for testing purposes
170
    # Have two known libraries for testing purposes
170
    my $library_1 = $builder->build_object({ class => 'Koha::Libraries' });
171
    my $library_1 = $builder->build_object({ class => 'Koha::Libraries' });
Lines 187-192 subtest 'buildKohaItemsNamespace() including/omitting items tests' => sub { Link Here
187
    like(   $xml, qr{<homebranch>$library_1_name</homebranch>}, '$item_1 present in the XML' );
188
    like(   $xml, qr{<homebranch>$library_1_name</homebranch>}, '$item_1 present in the XML' );
188
    like(   $xml, qr{<homebranch>$library_2_name</homebranch>}, '$item_2 present in the XML' );
189
    like(   $xml, qr{<homebranch>$library_2_name</homebranch>}, '$item_2 present in the XML' );
189
    unlike( $xml, qr{<homebranch>$library_3_name</homebranch>}, '$item_3 not present in the XML' );
190
    unlike( $xml, qr{<homebranch>$library_3_name</homebranch>}, '$item_3 not present in the XML' );
191
192
    t::lib::Mocks::mock_preference('OpacHiddenItems', 'biblionumber: ['.$biblio2->biblionumber.']');
193
    my $hid_rs = $biblio->items->search({ "me.itemnumber" => { '!=' => $item_3->itemnumber } })->filter_by_visible_in_opac();
194
    $xml = C4::XSLT::buildKohaItemsNamespace( $biblio->biblionumber, undef, $hid_rs );
195
    like(   $xml, qr{<homebranch>$library_1_name</homebranch>}, '$item_1 present in the XML' );
196
    like(   $xml, qr{<homebranch>$library_2_name</homebranch>}, '$item_2 present in the XML' );
197
    unlike( $xml, qr{<homebranch>$library_3_name</homebranch>}, '$item_3 not present in the XML' );
198
190
    ## Test passing one item in hidden_items and items_rs
199
    ## Test passing one item in hidden_items and items_rs
191
    $xml = C4::XSLT::buildKohaItemsNamespace( $biblio->biblionumber, [ $item_1->itemnumber ], $items_rs->reset );
200
    $xml = C4::XSLT::buildKohaItemsNamespace( $biblio->biblionumber, [ $item_1->itemnumber ], $items_rs->reset );
192
201
193
- 

Return to bug 29802