|
Lines 220-241
subtest '->search_for_display' => sub {
Link Here
|
| 220 |
is($news->count, 4, 'Active and not expired news'); |
220 |
is($news->count, 4, 'Active and not expired news'); |
| 221 |
is($news->next->number, 2, 'News items are returned in correct order'); |
221 |
is($news->next->number, 2, 'News items are returned in correct order'); |
| 222 |
|
222 |
|
| 223 |
$news = Koha::News->search_for_display({ type => 'slip'}); |
223 |
$news = Koha::News->search_for_display({ location => 'slip'}); |
| 224 |
is($news->count, 2, 'Slip and all type returned'); |
224 |
is($news->count, 2, 'Slip and "all" locations returned'); |
| 225 |
|
225 |
|
| 226 |
$news = Koha::News->search_for_display({ type => 'koha'}); |
226 |
$news = Koha::News->search_for_display({ location => 'koha'}); |
| 227 |
is($news->count, 3, 'Intranet and all'); |
227 |
is($news->count, 3, 'Intranet and "all"'); |
| 228 |
|
228 |
|
| 229 |
$new_not_expired->lang('OpacNavRight_en')->store; |
229 |
$new_not_expired->lang('OpacNavRight_en')->store; |
| 230 |
$news = Koha::News->search_for_display({ type => 'OpacNavRight', lang => 'en'}); |
230 |
$news = Koha::News->search_for_display({ location => 'OpacNavRight', lang => 'en'}); |
| 231 |
is($news->count, 1, 'OpacNavRight'); |
231 |
is($news->count, 1, 'OpacNavRight'); |
| 232 |
is($news->next->idnew, $new_not_expired->idnew, 'Returned the right new item'); |
232 |
is($news->next->idnew, $new_not_expired->idnew, 'Returned the right new item'); |
| 233 |
|
233 |
|
| 234 |
$new_intra->lang('')->store; |
234 |
$new_intra->lang('')->store; |
| 235 |
$news = Koha::News->search_for_display({ type => 'opac', lang => 'en'}); |
235 |
$news = Koha::News->search_for_display({ location => 'opac', lang => 'en'}); |
| 236 |
is($news->count, 1, 'Only all type is returned'); |
236 |
is($news->count, 1, 'Only opac news are returned'); |
| 237 |
$new_not_expired->lang('en')->store; |
237 |
$new_not_expired->lang('en')->store; |
| 238 |
$news = Koha::News->search_for_display({ type => 'opac', lang => 'en'}); |
238 |
$news = Koha::News->search_for_display({ location => 'opac', lang => 'en'}); |
| 239 |
is($news->count, 2, 'Opac en and all is returned'); |
239 |
is($news->count, 2, 'Opac en and all is returned'); |
| 240 |
|
240 |
|
| 241 |
$news = Koha::News->search_for_display({ library_id => $library1->branchcode }); |
241 |
$news = Koha::News->search_for_display({ library_id => $library1->branchcode }); |
|
Lines 248-258
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'}); |
251 |
$news = Koha::News->search_for_display({ location => 'NonExistantType', lang => 'en'}); |
| 252 |
is($news->count, 0, 'Non-existant type is searched, but should not find any item'); |
252 |
is($news->count, 0, 'Non-existant location is searched, but should not find any item'); |
| 253 |
|
253 |
|
| 254 |
throws_ok { Koha::News->search_for_display({type => 'opac'}) } 'Koha::Exceptions::BadParameter', |
254 |
throws_ok { Koha::News->search_for_display({ location => 'opac'}) } 'Koha::Exceptions::BadParameter', |
| 255 |
'Exception raised when type is opac and no language given'; |
255 |
'Exception raised when location is opac and no language given'; |
| 256 |
|
256 |
|
| 257 |
$schema->storage->txn_rollback; |
257 |
$schema->storage->txn_rollback; |
| 258 |
}; |
258 |
}; |
| 259 |
- |
|
|