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

(-)a/Koha/Items.pm (-1 / +1 lines)
Lines 127-133 sub filter_by_visible_in_opac { Link Here
127
127
128
        my $rules_params;
128
        my $rules_params;
129
        foreach my $field ( keys %$rules ) {
129
        foreach my $field ( keys %$rules ) {
130
            $rules_params->{$field} =
130
            $rules_params->{'me.'.$field} =
131
              [ { '-not_in' => $rules->{$field} }, undef ];
131
              [ { '-not_in' => $rules->{$field} }, undef ];
132
        }
132
        }
133
133
(-)a/t/db_dependent/Koha/Items.t (-1 / +8 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 => 13;
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
1691
    $rules = { withdrawn => [ 1, 2 ], copynumber => [ 2 ] };
1698
    $rules = { withdrawn => [ 1, 2 ], copynumber => [ 2 ] };
1692
    is(
1699
    is(
1693
        $biblio->items->filter_by_visible_in_opac->count,
1700
        $biblio->items->filter_by_visible_in_opac->count,
(-)a/t/db_dependent/XSLT.t (-2 / +13 lines)
Lines 147-157 $schema->storage->txn_rollback; Link Here
147
147
148
subtest 'buildKohaItemsNamespace() including/omitting items tests' => sub {
148
subtest 'buildKohaItemsNamespace() including/omitting items tests' => sub {
149
149
150
    plan tests => 20;
150
    plan tests => 23;
151
151
152
    $schema->storage->txn_begin;
152
    $schema->storage->txn_begin;
153
153
154
    my $biblio = $builder->build_sample_biblio;
154
    my $biblio = $builder->build_sample_biblio;
155
    my $biblio2 = $builder->build_sample_biblio;
155
156
156
    # Have two known libraries for testing purposes
157
    # Have two known libraries for testing purposes
157
    my $library_1 = $builder->build_object({ class => 'Koha::Libraries' });
158
    my $library_1 = $builder->build_object({ class => 'Koha::Libraries' });
Lines 174-179 subtest 'buildKohaItemsNamespace() including/omitting items tests' => sub { Link Here
174
    like(   $xml, qr{<homebranch>$library_1_name</homebranch>}, '$item_1 present in the XML' );
175
    like(   $xml, qr{<homebranch>$library_1_name</homebranch>}, '$item_1 present in the XML' );
175
    like(   $xml, qr{<homebranch>$library_2_name</homebranch>}, '$item_2 present in the XML' );
176
    like(   $xml, qr{<homebranch>$library_2_name</homebranch>}, '$item_2 present in the XML' );
176
    unlike( $xml, qr{<homebranch>$library_3_name</homebranch>}, '$item_3 not present in the XML' );
177
    unlike( $xml, qr{<homebranch>$library_3_name</homebranch>}, '$item_3 not present in the XML' );
178
179
    my $mocked_context = Test::MockModule->new('C4::Context');
180
    $mocked_context->mock( 'yaml_preference', sub {
181
        return { biblionumber => [ $biblio2->biblionumber ] };
182
    });
183
    my $hid_rs = $biblio->items->search({ "me.itemnumber" => { '!=' => $item_3->itemnumber } })->filter_by_visible_in_opac();
184
    $xml = C4::XSLT::buildKohaItemsNamespace( $biblio->biblionumber, undef, $hid_rs );
185
    like(   $xml, qr{<homebranch>$library_1_name</homebranch>}, '$item_1 present in the XML' );
186
    like(   $xml, qr{<homebranch>$library_2_name</homebranch>}, '$item_2 present in the XML' );
187
    unlike( $xml, qr{<homebranch>$library_3_name</homebranch>}, '$item_3 not present in the XML' );
188
177
    ## Test passing one item in hidden_items and items_rs
189
    ## Test passing one item in hidden_items and items_rs
178
    $xml = C4::XSLT::buildKohaItemsNamespace( $biblio->biblionumber, [ $item_1->itemnumber ], $items_rs->reset );
190
    $xml = C4::XSLT::buildKohaItemsNamespace( $biblio->biblionumber, [ $item_1->itemnumber ], $items_rs->reset );
179
191
180
- 

Return to bug 29802