From 5b898a09bb065c9c104b50fc3562d4310cda6819 Mon Sep 17 00:00:00 2001 From: Mark Tompsett Date: Wed, 14 May 2014 23:38:12 -0400 Subject: [PATCH] Bug 7841: add unit tests to detect no functional changes to getTranslatedLanguages() 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 Test pass, no koha-qa errors Signed-off-by: Kyle M Hall Signed-off-by: Galen Charlton --- t/db_dependent/Languages.t | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Languages.t b/t/db_dependent/Languages.t index b3c82bcfbc..474987febf 100755 --- a/t/db_dependent/Languages.t +++ b/t/db_dependent/Languages.t @@ -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; -- 2.39.2