Lines 5-11
use Koha::Database;
Link Here
|
5 |
use Koha::DateUtils; |
5 |
use Koha::DateUtils; |
6 |
use Koha::Libraries; |
6 |
use Koha::Libraries; |
7 |
|
7 |
|
8 |
use Test::More tests => 14; |
8 |
use Test::More tests => 11; |
9 |
|
9 |
|
10 |
BEGIN { |
10 |
BEGIN { |
11 |
use_ok('C4::NewsChannels'); |
11 |
use_ok('C4::NewsChannels'); |
Lines 134-190
$href_entry2->{idnew} = $idnew2;
Link Here
|
134 |
$rv = upd_opac_new($href_entry2); |
134 |
$rv = upd_opac_new($href_entry2); |
135 |
is( $rv, 1, 'Successfully updated second dummy news item!' ); |
135 |
is( $rv, 1, 'Successfully updated second dummy news item!' ); |
136 |
|
136 |
|
137 |
# Test get_opac_new (single news item) |
|
|
138 |
$timestamp1 = output_pref( { dt => dt_from_string( $timestamp1 ), dateonly => 1 } ); |
139 |
$expirationdate1 = output_pref( { dt => dt_from_string( $expirationdate1 ), dateonly => 1 } ); |
140 |
$timestamp2 = output_pref( { dt => dt_from_string( $timestamp2 ), dateonly => 1 } ); |
141 |
$expirationdate2 = output_pref( { dt => dt_from_string( $expirationdate2) , dateonly => 1 } ); |
142 |
|
143 |
is_deeply( |
144 |
get_opac_new($idnew1), |
145 |
{ |
146 |
title => $title1, |
147 |
content => $new1, |
148 |
lang => $lang1, |
149 |
expirationdate => $expirationdate1, |
150 |
timestamp => $timestamp1, |
151 |
number => $number1, |
152 |
borrowernumber => undef, |
153 |
idnew => $idnew1, |
154 |
branchname => "$addbra branch", |
155 |
branchcode => $addbra, |
156 |
# this represents $lang => 1 in the hash |
157 |
# that's returned... which seems a little |
158 |
# redundant given that there's a perfectly |
159 |
# good 'lang' key in the hash |
160 |
'' => 1, |
161 |
}, |
162 |
'got back expected news item via get_opac_new - ID 1' |
163 |
); |
164 |
|
165 |
# Test get_opac_new (single news item) |
166 |
is_deeply( |
167 |
get_opac_new($idnew2), |
168 |
{ |
169 |
title => $title2, |
170 |
content => $new2, |
171 |
lang => $lang2, |
172 |
expirationdate => $expirationdate2, |
173 |
timestamp => $timestamp2, |
174 |
number => $number2, |
175 |
borrowernumber => $brwrnmbr, |
176 |
idnew => $idnew2, |
177 |
branchname => "$addbra branch", |
178 |
branchcode => $addbra, |
179 |
'' => 1, |
180 |
}, |
181 |
'got back expected news item via get_opac_new - ID 2' |
182 |
); |
183 |
|
184 |
# Test get_opac_new (single news item without expiration date) |
185 |
my $news3 = get_opac_new($idnew3); |
186 |
is($news3->{ expirationdate }, undef, "Expiration date should be empty"); |
187 |
|
188 |
# Test get_opac_news (multiple news items) |
137 |
# Test get_opac_news (multiple news items) |
189 |
my ( $opac_news_count, $arrayref_opac_news ) = get_opac_news( 0, q{}, 'LIB1' ); |
138 |
my ( $opac_news_count, $arrayref_opac_news ) = get_opac_news( 0, q{}, 'LIB1' ); |
190 |
|
139 |
|