From 521bfb082732c00e33843ee44cbb8ff2a2c1d56d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marc=20V=C3=A9ron?= Date: Fri, 20 May 2016 14:42:08 +0200 Subject: [PATCH] Bug 16550: Add test to NewsChannels.t To test: Run t/db_dependent/NewsChannels.t Tests adding and retreiving a news item without expiration date. This test should fail without patch for Bug 16550 and pass OK with patch. Signed-off-by: Nick Clemens Signed-off-by: Jonathan Druart Signed-off-by: Kyle M Hall --- t/db_dependent/NewsChannels.t | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/NewsChannels.t b/t/db_dependent/NewsChannels.t index 2f38c78eaa..e5d7515771 100644 --- a/t/db_dependent/NewsChannels.t +++ b/t/db_dependent/NewsChannels.t @@ -4,7 +4,7 @@ use Modern::Perl; use C4::Branch qw(GetBranchName); use Koha::DateUtils; -use Test::More tests => 12; +use Test::More tests => 14; BEGIN { use_ok('C4::NewsChannels'); @@ -69,6 +69,7 @@ ok( $rv == 0, 'Correctly failed on no parameter!' ); my $timestamp = '2000-01-01'; my ( $timestamp1, $timestamp2 ) = ( $timestamp, $timestamp ); +my $timestamp3 = '2000-01-02'; my ( $title1, $new1, $lang1, $expirationdate1, $number1 ) = ( 'News Title', '

We have some exciting news!

', q{}, '2999-12-30', 1 ); my $href_entry1 = { @@ -99,6 +100,20 @@ my $href_entry2 = { $rv = add_opac_new($href_entry2); ok( $rv == 1, 'Successfully added the second dummy news item!' ); +my ( $title3, $new3, $lang3, $number3 ) = + ( 'News Title3', '

News without expiration date

', q{}, 1 ); +my $href_entry3 = { + title => $title3, + new => $new3, + lang => $lang3, + timestamp => $timestamp3, + number => $number3, + borrowernumber => $brwrnmbr, + branchcode => 'LIB1', +}; +$rv = add_opac_new($href_entry3); +ok( $rv == 1, 'Successfully added the third dummy news item without expiration date!' ); + # We need to determine the idnew in a non-MySQLism way. # This should be good enough. my $query = @@ -112,6 +127,12 @@ $sth = $dbh->prepare($query); $sth->execute(); my $idnew2 = $sth->fetchrow; +$query = +q{ SELECT idnew from opac_news WHERE timestamp='2000-01-02'; }; +$sth = $dbh->prepare($query); +$sth->execute(); +my $idnew3 = $sth->fetchrow; + # Test upd_opac_new $rv = upd_opac_new(); # intentionally bad parmeters ok( $rv == 0, 'Correctly failed on no parameter!' ); @@ -169,6 +190,10 @@ is_deeply( 'got back expected news item via get_opac_new - ID 2' ); +# Test get_opac_new (single news item without expiration date) +my $news3 = get_opac_new($idnew3); +ok (! $news3->{ expirationdate }, "Expiration date should be empty"); + # Test get_opac_news (multiple news items) my ( $opac_news_count, $arrayref_opac_news ) = get_opac_news( 0, q{}, 'LIB1' ); -- 2.11.4.GIT