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 <fridolin.somers@biblibre.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Alex Buckley 2023-02-13 01:39:51 +00:00 committed by Tomas Cohen Arazi
parent d86786401a
commit 283cb0fd13
Signed by: tomascohen
GPG key ID: 0A272EA1B2F3C15F

View file

@ -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();