Lines 4-11
use Modern::Perl;
Link Here
|
4 |
use Koha::Database; |
4 |
use Koha::Database; |
5 |
use Koha::DateUtils; |
5 |
use Koha::DateUtils; |
6 |
use Koha::Libraries; |
6 |
use Koha::Libraries; |
|
|
7 |
use Koha::News; |
7 |
|
8 |
|
8 |
use Test::More tests => 11; |
9 |
use Test::More tests => 9; |
9 |
|
10 |
|
10 |
BEGIN { |
11 |
BEGIN { |
11 |
use_ok('C4::NewsChannels'); |
12 |
use_ok('C4::NewsChannels'); |
Lines 134-176
$href_entry2->{idnew} = $idnew2;
Link Here
|
134 |
$rv = upd_opac_new($href_entry2); |
135 |
$rv = upd_opac_new($href_entry2); |
135 |
is( $rv, 1, 'Successfully updated second dummy news item!' ); |
136 |
is( $rv, 1, 'Successfully updated second dummy news item!' ); |
136 |
|
137 |
|
137 |
# Test get_opac_news (multiple news items) |
|
|
138 |
my ( $opac_news_count, $arrayref_opac_news ) = get_opac_news( 0, q{}, 'LIB1' ); |
139 |
|
140 |
# using >= 2, because someone may have LIB1 news already. |
141 |
ok( $opac_news_count >= 2, 'Successfully tested get_opac_news for LIB1!' ); |
142 |
|
143 |
# Test GetNewsToDisplay |
138 |
# Test GetNewsToDisplay |
144 |
( $opac_news_count, $arrayref_opac_news ) = GetNewsToDisplay( q{}, 'LIB1' ); |
139 |
my ( $opac_news_count, $arrayref_opac_news ) = GetNewsToDisplay( q{}, 'LIB1' ); |
145 |
ok( $opac_news_count >= 2, 'Successfully tested GetNewsToDisplay for LIB1!' ); |
140 |
ok( $opac_news_count >= 2, 'Successfully tested GetNewsToDisplay for LIB1!' ); |
146 |
|
141 |
|
147 |
# Regression test 14248 -- make sure author_title, author_firstname, and |
|
|
148 |
# author_surname exist. |
149 |
|
150 |
subtest 'Regression tests on author title, firstname, and surname.', sub { |
151 |
my ( $opac_news_count, $opac_news ) = get_opac_news( 0, q{}, 'LIB1' ); |
152 |
my $check = 0; # bitwise flag to confirm NULL and not NULL borrowernumber. |
153 |
ok($opac_news_count>0,'Data exists for regression testing'); |
154 |
foreach my $news_item (@$opac_news) { |
155 |
ok(exists $news_item->{author_title}, 'Author title exists'); |
156 |
ok(exists $news_item->{author_firstname},'Author first name exists'); |
157 |
ok(exists $news_item->{author_surname}, 'Author surname exists'); |
158 |
if ($news_item->{borrowernumber}) { |
159 |
ok(defined $news_item->{author_title} || |
160 |
defined $news_item->{author_firstname} || |
161 |
defined $news_item->{author_surname}, 'Author data defined'); |
162 |
$check = $check | 2; # bitwise flag; |
163 |
} |
164 |
else { |
165 |
ok(!defined $news_item->{author_title}, |
166 |
'Author title undefined as expected'); |
167 |
ok(!defined $news_item->{author_firstname}, |
168 |
'Author first name undefined as expected'); |
169 |
ok(!defined $news_item->{author_surname}, |
170 |
'Author surname undefined as expected'); |
171 |
$check = $check | 1; # bitwise flag; |
172 |
} |
173 |
} |
174 |
ok($check==3,'Both with and without author data tested'); |
175 |
done_testing(); |
176 |
}; |