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 143-149 subtest '->author' => sub { Link Here
143
143
144
subtest '->search_for_display' => sub {
144
subtest '->search_for_display' => sub {
145
145
146
    plan tests => 12;
146
    plan tests => 13;
147
147
148
    $schema->storage->txn_begin;
148
    $schema->storage->txn_begin;
149
149
Lines 248-253 subtest '->search_for_display' => sub { Link Here
248
    $news = Koha::News->search_for_display({ library_id => $library2->branchcode});
248
    $news = Koha::News->search_for_display({ library_id => $library2->branchcode});
249
    is($news->count, 2, 'Filtering by library returns right number of news items');
249
    is($news->count, 2, 'Filtering by library returns right number of news items');
250
250
251
    $news = Koha::News->search_for_display({ type => 'NonExistantType', lang => 'en'});
252
    is($news->count, 0, 'Non-existant type is searched, but should not find any item');
253
251
    throws_ok { Koha::News->search_for_display({type => 'opac'}) } 'Koha::Exceptions::BadParameter',
254
    throws_ok { Koha::News->search_for_display({type => 'opac'}) } 'Koha::Exceptions::BadParameter',
252
        'Exception raised when type is opac and no language given';
255
        'Exception raised when type is opac and no language given';
253
256
254
- 

Return to bug 22544