Bug 7841: add unit tests to detect no functional changes to getTranslatedLanguages()
authorMark Tompsett <mtompset@hotmail.com>
Thu, 15 May 2014 03:38:12 +0000 (23:38 -0400)
committerGalen Charlton <gmc@esilibrary.com>
Mon, 19 May 2014 16:38:57 +0000 (16:38 +0000)
When called with undef, floody messages appear in the error
logs. Less floody messages appear when using 'en' as the
language.  This patch adds tests to verify that the behavior of
getTranslatedLanguages() doesn't change when a subsequent
patch updates it to not generate the warnings.

TEST PLAN
---------
1) apply the patch
2) prove -v t/db_dependent/Languages.t
   -- All the tests should pass, including the last two which
      a) check that when undef is used no language is marked
          as current.
      b) check that when 'en' is used there is a language marked
          as current.

Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>
Test pass, no koha-qa errors

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
t/db_dependent/Languages.t

index b3c82bc..474987f 100755 (executable)
@@ -6,7 +6,9 @@
 use strict;
 use warnings;
 
-use Test::More tests => 9;
+use Test::More tests => 11;
+use List::Util qw(first);
+use Data::Dumper;
 
 BEGIN {
     use_ok('C4::Languages');
@@ -38,4 +40,14 @@ C4::Context->set_preference('AdvancedSearchLanguages', 'ita|eng');
 $languages = C4::Languages::getLanguages('eng', 1);
 is(scalar(@$languages), 2, 'getLanguages() filtering using AdvancedSearchLanguages works');
 
+my $translatedlanguages1 = C4::Languages::getTranslatedLanguages('opac','prog',undef,'');
+my @currentcheck1 = map { $_->{current} } @$translatedlanguages1;
+my $onlyzeros = first { $_ != 0 } @currentcheck1;
+ok(! $onlyzeros, "Everything was zeros.\n");
+
+my $translatedlanguages2 = C4::Languages::getTranslatedLanguages('opac','prog','en','');
+my @currentcheck2 = map { $_->{current} } @$translatedlanguages2;
+$onlyzeros = first { $_ != 0 } @currentcheck2;
+ok($onlyzeros, "There is a $onlyzeros\n");
+
 $dbh->rollback;