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

(-)a/Koha/News.pm (-2 / +2 lines)
Lines 75-81 sub search_for_display { Link Here
75
            $search_params->{lang} = [ $params->{type}, '' ];
75
            $search_params->{lang} = [ $params->{type}, '' ];
76
        } elsif ( $params->{type} eq 'opac' && $params->{lang} ) {
76
        } elsif ( $params->{type} eq 'opac' && $params->{lang} ) {
77
            $search_params->{lang} = [ $params->{lang}, '' ];
77
            $search_params->{lang} = [ $params->{lang}, '' ];
78
        } elsif ( $params->{type} eq 'OpacNavRight' && $params->{lang} ) {
78
        } elsif ( $params->{lang} ) {
79
            $search_params->{lang} = $params->{type} . '_' . $params->{lang};
79
            $search_params->{lang} = $params->{type} . '_' . $params->{lang};
80
        } else {
80
        } else {
81
            Koha::Exceptions::BadParameter->throw("The type and lang parameters combination is not valid");
81
            Koha::Exceptions::BadParameter->throw("The type and lang parameters combination is not valid");
Lines 90-96 sub search_for_display { Link Here
90
    return $self->SUPER::search($search_params, { order_by => 'number' });
90
    return $self->SUPER::search($search_params, { order_by => 'number' });
91
}
91
}
92
92
93
=head3 type
93
=head3 _type
94
94
95
=cut
95
=cut
96
96
(-)a/t/db_dependent/Koha/News.t (-2 / +4 lines)
Lines 158-164 subtest '->author' => sub { Link Here
158
158
159
subtest '->search_for_display' => sub {
159
subtest '->search_for_display' => sub {
160
160
161
    plan tests => 12;
161
    plan tests => 13;
162
162
163
    $schema->storage->txn_begin;
163
    $schema->storage->txn_begin;
164
164
Lines 263-268 subtest '->search_for_display' => sub { Link Here
263
    $news = Koha::News->search_for_display({ library_id => $library2->branchcode});
263
    $news = Koha::News->search_for_display({ library_id => $library2->branchcode});
264
    is($news->count, 2, 'Filtering by library returns right number of news items');
264
    is($news->count, 2, 'Filtering by library returns right number of news items');
265
265
266
    $news = Koha::News->search_for_display({ type => 'NonExistantType', lang => 'en'});
267
    is($news->count, 0, 'Non-existant type is searched, but should not find any item');
268
266
    throws_ok { Koha::News->search_for_display({type => 'opac'}) } 'Koha::Exceptions::BadParameter',
269
    throws_ok { Koha::News->search_for_display({type => 'opac'}) } 'Koha::Exceptions::BadParameter',
267
        'Exception raised when type is opac and no language given';
270
        'Exception raised when type is opac and no language given';
268
271
269
- 

Return to bug 22544