From 55a56369a5d0f102b156b708da683cfef6fb40df Mon Sep 17 00:00:00 2001 From: Alex Buckley Date: Mon, 13 Feb 2023 01:39:51 +0000 Subject: [PATCH] Bug 32775: (follow-up) Unit tests Test plan: 1. Apply this patch and restart services 2. Run t/db_dependent/Languages.t 3. Notice tests 16 and 17 sometimes fail 4. Apply all the other patches and restart services 5. Run t/db_dependent/Languages.t 6. Notice all tests consistently pass Sponsored-by: Kinder library, New Zealand Signed-off-by: Fridolin Somers --- t/db_dependent/Languages.t | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Languages.t b/t/db_dependent/Languages.t index f9e50aade8..d654a80790 100755 --- a/t/db_dependent/Languages.t +++ b/t/db_dependent/Languages.t @@ -5,7 +5,7 @@ use Modern::Perl; -use Test::More tests => 18; +use Test::More tests => 21; use List::Util qw(first); use Data::Dumper; use Test::Warn; @@ -24,6 +24,7 @@ isnt(C4::Languages::_get_themes(), undef, 'testing _get_themes doesnt return und ok(C4::Languages::_get_language_dirs(), 'test getting _get_language_dirs'); + my $result; warning_is { $result = C4::Languages::accept_language(); } q{accept_language(x,y) called with no clientPreferences (x).}, @@ -62,6 +63,16 @@ my @currentcheck2 = map { $_->{current} } @$translatedlanguages2; $onlyzeros = first { $_ != 0 } @currentcheck2; ok($onlyzeros, "There is a $onlyzeros\n"); +# Bug 32775 +my @languages = ('de-DE', 'en', 'en-NZ', 'mi-NZ'); +my @enabledlanguages = ('de-DE', 'en-NZ', 'mi-NZ'); +my $translatedlanguages3; +$translatedlanguages3 = C4::Languages::_build_languages_arrayref(\@languages,'en',\@enabledlanguages); +is( $translatedlanguages3->[0]->{rfc4646_subtag}, 'de-DE', '_build_languages_arrayref() returns first language of "de-DE"' ); +is( $translatedlanguages3->[1]->{rfc4646_subtag}, 'en', '_build_languages_arrayref() returns second language of "en"'); +is( $translatedlanguages3->[2]->{rfc4646_subtag}, 'mi-NZ', '_build_languages_arrayref() returns third language of "mi-NZ"'); + + # Language Descriptions my $sth = $dbh->prepare("SELECT DISTINCT subtag,type,lang,description from language_descriptions;"); $sth->execute(); -- 2.39.0