Bug 42973: Unit test
Added a unit test to confirm that search_for_display orders manually positioned news first, followed by unnumbered news by publication date descending. Test passes: prove t/db_dependent/Koha/AdditionalContents.t Signed-off-by: Gretchen Maxeiner <MaxeinerGL@gcc.edu> Signed-off-by: David Cook <dcook@prosentient.com.au> Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
parent
2c29581606
commit
eeb73bd789
|
|
@ -304,6 +304,64 @@ subtest '->search_for_display' => sub {
|
|||
|
||||
# TODO We should add more tests here
|
||||
|
||||
my $older_numbered = $builder->build_object(
|
||||
{
|
||||
class => 'Koha::AdditionalContents',
|
||||
value => {
|
||||
expirationdate => $tomorrow,
|
||||
published_on => dt_from_string->add( days => -10 ),
|
||||
category => 'news',
|
||||
location => 'opac_only',
|
||||
branchcode => undef,
|
||||
number => 1,
|
||||
}
|
||||
}
|
||||
);
|
||||
$older_numbered->translated_contents( [ { lang => 'default', content => '' } ] );
|
||||
|
||||
my $newer_unnumbered = $builder->build_object(
|
||||
{
|
||||
class => 'Koha::AdditionalContents',
|
||||
value => {
|
||||
expirationdate => $tomorrow,
|
||||
published_on => $today,
|
||||
category => 'news',
|
||||
location => 'opac_only',
|
||||
branchcode => undef,
|
||||
number => undef,
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
$newer_unnumbered->translated_contents( [ { lang => 'default', content => '' } ] );
|
||||
|
||||
my $older_unnumbered = $builder->build_object(
|
||||
{
|
||||
class => 'Koha::AdditionalContents',
|
||||
value => {
|
||||
expirationdate => $tomorrow,
|
||||
published_on => dt_from_string->add( days => -5 ),
|
||||
category => 'news',
|
||||
location => 'opac_only',
|
||||
branchcode => undef,
|
||||
number => undef,
|
||||
}
|
||||
}
|
||||
);
|
||||
$older_unnumbered->translated_contents( [ { lang => 'default', content => '' } ] );
|
||||
|
||||
$news = Koha::AdditionalContents->search_for_display( { location => 'opac_only' } );
|
||||
|
||||
is_deeply(
|
||||
[ map { $_->additional_content->id } $news->as_list ],
|
||||
[
|
||||
$older_numbered->id,
|
||||
$newer_unnumbered->id,
|
||||
$older_unnumbered->id,
|
||||
],
|
||||
'Numbered news is displayed first, followed by unnumbered news by publication date descending'
|
||||
);
|
||||
|
||||
$schema->storage->txn_rollback;
|
||||
|
||||
subtest 'prevent SQL injections' => sub {
|
||||
|
|
|
|||
Loading…
Reference in New Issue