|
Lines 235-256
subtest '->search_for_display' => sub {
Link Here
|
| 235 |
is($news->count, 4, 'Active and not expired news'); |
235 |
is($news->count, 4, 'Active and not expired news'); |
| 236 |
is($news->next->number, 2, 'News items are returned in correct order'); |
236 |
is($news->next->number, 2, 'News items are returned in correct order'); |
| 237 |
|
237 |
|
| 238 |
$news = Koha::News->search_for_display({ type => 'slip'}); |
238 |
$news = Koha::News->search_for_display({ location => 'slip'}); |
| 239 |
is($news->count, 2, 'Slip and all type returned'); |
239 |
is($news->count, 2, 'Slip and "all" locations returned'); |
| 240 |
|
240 |
|
| 241 |
$news = Koha::News->search_for_display({ type => 'koha'}); |
241 |
$news = Koha::News->search_for_display({ location => 'koha'}); |
| 242 |
is($news->count, 3, 'Intranet and all'); |
242 |
is($news->count, 3, 'Intranet and "all"'); |
| 243 |
|
243 |
|
| 244 |
$new_not_expired->lang('OpacNavRight_en')->store; |
244 |
$new_not_expired->lang('OpacNavRight_en')->store; |
| 245 |
$news = Koha::News->search_for_display({ type => 'OpacNavRight', lang => 'en'}); |
245 |
$news = Koha::News->search_for_display({ location => 'OpacNavRight', lang => 'en'}); |
| 246 |
is($news->count, 1, 'OpacNavRight'); |
246 |
is($news->count, 1, 'OpacNavRight'); |
| 247 |
is($news->next->idnew, $new_not_expired->idnew, 'Returned the right new item'); |
247 |
is($news->next->idnew, $new_not_expired->idnew, 'Returned the right new item'); |
| 248 |
|
248 |
|
| 249 |
$new_intra->lang('')->store; |
249 |
$new_intra->lang('')->store; |
| 250 |
$news = Koha::News->search_for_display({ type => 'opac', lang => 'en'}); |
250 |
$news = Koha::News->search_for_display({ location => 'opac', lang => 'en'}); |
| 251 |
is($news->count, 1, 'Only all type is returned'); |
251 |
is($news->count, 1, 'Only opac news are returned'); |
| 252 |
$new_not_expired->lang('en')->store; |
252 |
$new_not_expired->lang('en')->store; |
| 253 |
$news = Koha::News->search_for_display({ type => 'opac', lang => 'en'}); |
253 |
$news = Koha::News->search_for_display({ location => 'opac', lang => 'en'}); |
| 254 |
is($news->count, 2, 'Opac en and all is returned'); |
254 |
is($news->count, 2, 'Opac en and all is returned'); |
| 255 |
|
255 |
|
| 256 |
$news = Koha::News->search_for_display({ library_id => $library1->branchcode }); |
256 |
$news = Koha::News->search_for_display({ library_id => $library1->branchcode }); |
|
Lines 263-273
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'}); |
266 |
$news = Koha::News->search_for_display({ location => 'NonExistantType', lang => 'en'}); |
| 267 |
is($news->count, 0, 'Non-existant type is searched, but should not find any item'); |
267 |
is($news->count, 0, 'Non-existant location is searched, but should not find any item'); |
| 268 |
|
268 |
|
| 269 |
throws_ok { Koha::News->search_for_display({type => 'opac'}) } 'Koha::Exceptions::BadParameter', |
269 |
throws_ok { Koha::News->search_for_display({ location => 'opac'}) } 'Koha::Exceptions::BadParameter', |
| 270 |
'Exception raised when type is opac and no language given'; |
270 |
'Exception raised when location is opac and no language given'; |
| 271 |
|
271 |
|
| 272 |
$schema->storage->txn_rollback; |
272 |
$schema->storage->txn_rollback; |
| 273 |
}; |
273 |
}; |
| 274 |
- |
|
|