@@ -, +, @@ --- C4/Templates.pm | 6 +++--- t/db_dependent/Templates.t | 17 ++++++++++++++--- 2 files changed, 17 insertions(+), 6 deletions(-) --- a/C4/Templates.pm +++ a/C4/Templates.pm @@ -256,18 +256,18 @@ sub themelanguage { my $where = $tmpl =~ /xsl$/ ? 'xslt' : 'modules'; for my $theme (@themes) { if ( -e "$htdocs/$theme/$lang/$where/$tmpl" ) { - return ( $theme, $lang, uniq( \@themes ) ); + return ( $theme, $lang, [ uniq(@themes) ] ); } } # Otherwise return theme/'en', last resort fallback/'en' for my $theme (@themes) { if ( -e "$htdocs/$theme/en/$where/$tmpl" ) { - return ( $theme, 'en', uniq( \@themes ) ); + return ( $theme, 'en', [ uniq(@themes) ] ); } } # tmpl is a full path, so this is a template for a plugin if ( $tmpl =~ /^\// && -e $tmpl ) { - return ( $themes[0], $lang, uniq( \@themes ) ); + return ( $themes[0], $lang, [ uniq(@themes) ] ); } } --- a/t/db_dependent/Templates.t +++ a/t/db_dependent/Templates.t @@ -19,8 +19,10 @@ use Modern::Perl; use CGI; -use Test::More tests => 5; +use Test::More tests => 7; +use List::MoreUtils qw/uniq/; use Test::Deep; +use Test::MockModule; BEGIN { use_ok( 'C4::Templates' ); @@ -45,5 +47,14 @@ is( scalar @keys, 6, "GetColumnDefs correctly returns the 5 tables defined in co my @tables = ( 'biblio', 'biblioitems', 'borrowers', 'items', 'statistics', 'subscription'); cmp_deeply( \@keys, \@tables, "GetColumnDefs returns the expected tables"); - -1; +# simple test for themelanguage +my $mod = Test::MockModule->new( 'C4::Languages' ); +$mod->mock( 'getlanguage', sub { 'en' } ); +my @retval = C4::Templates::themelanguage( C4::Context->config('intrahtdocs'), + 'about.tt', 'intranet', 'fake_query', +); +my $themeref = $retval[2]; +is( @$themeref > 0, 1, 'We still assume to get back at least one theme' ); +cmp_deeply( $themeref, [ uniq(@$themeref) ], 'Should be unique themes' ); + +# End of tests --