Lines 3-9
Link Here
|
3 |
use Modern::Perl; |
3 |
use Modern::Perl; |
4 |
use C4::Dates qw(format_date); |
4 |
use C4::Dates qw(format_date); |
5 |
use C4::Branch qw(GetBranchName); |
5 |
use C4::Branch qw(GetBranchName); |
6 |
use Test::More tests => 10; |
6 |
use Test::More tests => 14; |
7 |
|
7 |
|
8 |
BEGIN { |
8 |
BEGIN { |
9 |
use_ok('C4::NewsChannels'); |
9 |
use_ok('C4::NewsChannels'); |
Lines 27-33
my $rv = add_opac_new(); # intentionally bad
Link Here
|
27 |
ok( $rv == 0, 'Correctly failed on no parameter!' ); |
27 |
ok( $rv == 0, 'Correctly failed on no parameter!' ); |
28 |
|
28 |
|
29 |
my $timestamp = '2000-01-01'; |
29 |
my $timestamp = '2000-01-01'; |
30 |
my ( $timestamp1, $timestamp2 ) = ( $timestamp, $timestamp ); |
30 |
my ( $timestamp1, $timestamp2, $timestamp3 ) = ( $timestamp, $timestamp, $timestamp ); |
31 |
my ( $title1, $new1, $lang1, $expirationdate1, $number1 ) = |
31 |
my ( $title1, $new1, $lang1, $expirationdate1, $number1 ) = |
32 |
( 'News Title', '<p>We have some exciting news!</p>', q{}, '2999-12-30', 1 ); |
32 |
( 'News Title', '<p>We have some exciting news!</p>', q{}, '2999-12-30', 1 ); |
33 |
my $href_entry1 = { |
33 |
my $href_entry1 = { |
Lines 57-62
my $href_entry2 = {
Link Here
|
57 |
$rv = add_opac_new($href_entry2); |
57 |
$rv = add_opac_new($href_entry2); |
58 |
ok( $rv == 1, 'Successfully added the second dummy news item!' ); |
58 |
ok( $rv == 1, 'Successfully added the second dummy news item!' ); |
59 |
|
59 |
|
|
|
60 |
my ( $title3, $new3, $lang3, $expirationdate3, $number3 ) = |
61 |
( 'News Title3', '<p>We make news exciting!</p>', q{}, undef, 1 ); |
62 |
my $href_entry3 = { |
63 |
title => $title3, |
64 |
new => $new3, |
65 |
lang => $lang3, |
66 |
expirationdate => $expirationdate3, |
67 |
timestamp => $timestamp3, |
68 |
number => $number3, |
69 |
branchcode => 'LIB1', |
70 |
}; |
71 |
$rv = add_opac_new($href_entry3); |
72 |
ok( $rv == 1, 'Successfully added the third dummy news item!' ); |
73 |
|
60 |
# We need to determine the idnew in a non-MySQLism way. |
74 |
# We need to determine the idnew in a non-MySQLism way. |
61 |
# This should be good enough. |
75 |
# This should be good enough. |
62 |
my $query = |
76 |
my $query = |
Lines 132-138
my ( $opac_news_count, $arrayref_opac_news ) = get_opac_news( 0, q{}, 'LIB1' );
Link Here
|
132 |
ok( $opac_news_count >= 2, 'Successfully tested get_opac_news for LIB1!' ); |
146 |
ok( $opac_news_count >= 2, 'Successfully tested get_opac_news for LIB1!' ); |
133 |
|
147 |
|
134 |
# Test GetNewsToDisplay |
148 |
# Test GetNewsToDisplay |
135 |
( $opac_news_count, $arrayref_opac_news ) = GetNewsToDisplay( q{}, 'LIB1' ); |
149 |
( $arrayref_opac_news ) = GetNewsToDisplay( q{}, 'LIB1' ); |
136 |
ok( $opac_news_count >= 2, 'Successfully tested GetNewsToDisplay for LIB1!' ); |
150 |
ok( $arrayref_opac_news, '$arrayref_opac_news is ' . |
|
|
151 |
( defined($arrayref_opac_news) ? |
152 |
('Defined') : 'UNDEFINED') |
153 |
); |
154 |
ok( ref $arrayref_opac_news eq 'ARRAY', |
155 |
'$arrayref_opac_news is an array reference.' ); |
156 |
ok( (scalar @$arrayref_opac_news) >= 2, 'Successfully tested GetNewsToDisplay for LIB1!' ); |
157 |
|
158 |
$query = |
159 |
q{ SELECT idnew from opac_news WHERE timestamp='2000-01-01' AND expirationdate IS NULL; }; |
160 |
$sth = $dbh->prepare($query); |
161 |
$sth->execute(); |
162 |
my $nullcheck = $sth->fetchrow(); |
163 |
ok ($nullcheck && $nullcheck>=0, 'Successfully found third dummy newsitem.'); |
137 |
|
164 |
|
138 |
$dbh->rollback; |
165 |
$dbh->rollback; |
139 |
- |
|
|