Bug 14248: Regression tests
authorMark Tompsett <mtompset@hotmail.com>
Thu, 22 Oct 2015 12:52:33 +0000 (08:52 -0400)
committerTomas Cohen Arazi <tomascohen@theke.io>
Tue, 27 Oct 2015 19:26:33 +0000 (16:26 -0300)
TEST PLAN
---------
1) apply patch
2) prove -v t/db_dependent/NewsChannels.t
3) run koha qa test tools.

Signed-off-by: Martin Persson <xarragon@gmail.com>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
t/db_dependent/NewsChannels.t

index 3818dac..1928b46 100644 (file)
@@ -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');
@@ -178,4 +178,35 @@ ok( $opac_news_count >= 2, 'Successfully tested get_opac_news for LIB1!' );
 ( $opac_news_count, $arrayref_opac_news ) = GetNewsToDisplay( q{}, 'LIB1' );
 ok( $opac_news_count >= 2, 'Successfully tested GetNewsToDisplay for LIB1!' );
 
+# Regression test 14248 -- make sure author_title, author_firstname, and
+# author_surname exist.
+
+subtest 'Regression tests on author title, firstname, and surname.', sub {
+    my ( $opac_news_count, $opac_news ) = get_opac_news( 0, q{}, 'LIB1' );
+    my $check = 0; # bitwise flag to confirm NULL and not NULL borrowernumber.
+    ok($opac_news_count>0,'Data exists for regression testing');
+    foreach my $news_item (@$opac_news) {
+        ok(exists $news_item->{author_title},    'Author title exists');
+        ok(exists $news_item->{author_firstname},'Author first name exists');
+        ok(exists $news_item->{author_surname},  'Author surname exists');
+        if ($news_item->{borrowernumber}) {
+            ok(defined $news_item->{author_title} ||
+               defined $news_item->{author_firstname} ||
+               defined $news_item->{author_surname},  'Author data defined');
+            $check = $check | 2; # bitwise flag;
+        }
+        else {
+            ok(!defined $news_item->{author_title},
+               'Author title undefined as expected');
+            ok(!defined $news_item->{author_firstname},
+               'Author first name undefined as expected');
+            ok(!defined $news_item->{author_surname},
+               'Author surname undefined as expected');
+            $check = $check | 1; # bitwise flag;
+        }
+    }
+    ok($check==3,'Both with and without author data tested');
+    done_testing();
+};
+
 $dbh->rollback;