From 1d85c933a29d2c4f215420da64e0ae3d771b2543 Mon Sep 17 00:00:00 2001 From: Mark Tompsett Date: Sun, 27 Jul 2014 21:16:38 -0400 Subject: [PATCH] Bug 12167 - Bad expected results and condition check for GetNewsToDisplay This corrected the results expected to a single array reference. It then determines that it is defined and an array reference. And lastly, correct the logic that was supposed to check for valid results. TEST PLAN --------- 1) Apply patch 1 and 2. 2) prove -v t/db_dependent/NewsChannels.t -- all tests should pass -- note the test changes to verify correctly what should be tested for. --- t/db_dependent/NewsChannels.t | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/t/db_dependent/NewsChannels.t b/t/db_dependent/NewsChannels.t index a095f90..332b396 100644 --- a/t/db_dependent/NewsChannels.t +++ b/t/db_dependent/NewsChannels.t @@ -3,7 +3,7 @@ use Modern::Perl; use C4::Dates qw(format_date); use C4::Branch qw(GetBranchName); -use Test::More tests => 11; +use Test::More tests => 12; BEGIN { use_ok('C4::NewsChannels'); @@ -132,11 +132,13 @@ my ( $opac_news_count, $arrayref_opac_news ) = get_opac_news( 0, q{}, 'LIB1' ); ok( $opac_news_count >= 2, 'Successfully tested get_opac_news for LIB1!' ); # Test GetNewsToDisplay -( $opac_news_count, $arrayref_opac_news ) = GetNewsToDisplay( q{}, 'LIB1' ); -ok( !$arrayref_opac_news, 'Second parameter is ' . +( $arrayref_opac_news ) = GetNewsToDisplay( q{}, 'LIB1' ); +ok( $arrayref_opac_news, '$arrayref_opac_news is ' . ( defined($arrayref_opac_news) ? - ("Defined as '$arrayref_opac_news'") : "UNDEFINED") + ('Defined') : 'UNDEFINED') ); -ok( $opac_news_count >= 2, 'Successfully tested GetNewsToDisplay for LIB1!' ); +ok( ref $arrayref_opac_news eq 'ARRAY', + '$arrayref_opac_news is an array reference.' ); +ok( (scalar @$arrayref_opac_news) >= 2, 'Successfully tested GetNewsToDisplay for LIB1!' ); $dbh->rollback; -- 1.7.9.5