@@ -, +, @@ types --- Koha/News.pm | 4 ++-- t/db_dependent/Koha/News.t | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) --- a/Koha/News.pm +++ a/Koha/News.pm @@ -75,7 +75,7 @@ sub search_for_display { $search_params->{lang} = [ $params->{type}, '' ]; } elsif ( $params->{type} eq 'opac' && $params->{lang} ) { $search_params->{lang} = [ $params->{lang}, '' ]; - } elsif ( $params->{type} eq 'OpacNavRight' && $params->{lang} ) { + } elsif ( $params->{lang} ) { $search_params->{lang} = $params->{type} . '_' . $params->{lang}; } else { Koha::Exceptions::BadParameter->throw("The type and lang parameters combination is not valid"); @@ -90,7 +90,7 @@ sub search_for_display { return $self->SUPER::search($search_params, { order_by => 'number' }); } -=head3 type +=head3 _type =cut --- a/t/db_dependent/Koha/News.t +++ a/t/db_dependent/Koha/News.t @@ -143,7 +143,7 @@ subtest '->author' => sub { subtest '->search_for_display' => sub { - plan tests => 12; + plan tests => 13; $schema->storage->txn_begin; @@ -248,6 +248,9 @@ subtest '->search_for_display' => sub { $news = Koha::News->search_for_display({ library_id => $library2->branchcode}); is($news->count, 2, 'Filtering by library returns right number of news items'); + $news = Koha::News->search_for_display({ type => 'NonExistantType', lang => 'en'}); + is($news->count, 0, 'Non-existant type is searched, but should not find any item'); + throws_ok { Koha::News->search_for_display({type => 'opac'}) } 'Koha::Exceptions::BadParameter', 'Exception raised when type is opac and no language given'; --