Lines 18-26
Link Here
|
18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
19 |
|
19 |
|
20 |
use CGI; |
20 |
use CGI; |
|
|
21 |
use File::Basename qw/dirname/; |
21 |
|
22 |
|
22 |
use Test::More tests => 5; |
23 |
use Test::More tests => 6; |
23 |
use Test::Deep; |
24 |
use Test::Deep; |
|
|
25 |
use Test::MockModule; |
26 |
use t::lib::Mocks; |
24 |
|
27 |
|
25 |
BEGIN { |
28 |
BEGIN { |
26 |
use_ok( 'C4::Templates' ); |
29 |
use_ok( 'C4::Templates' ); |
Lines 40-49
my $columns = C4::Templates::GetColumnDefs( $query );
Link Here
|
40 |
|
43 |
|
41 |
is( ref( $columns ) eq 'HASH', 1, 'GetColumnDefs returns a hashref' ); |
44 |
is( ref( $columns ) eq 'HASH', 1, 'GetColumnDefs returns a hashref' ); |
42 |
# get the tables names, sorted |
45 |
# get the tables names, sorted |
43 |
my @keys = sort keys %$columns; |
46 |
my @keys = sort keys %{$columns}; |
44 |
is( scalar @keys, 6, "GetColumnDefs correctly returns the 5 tables defined in columns.def" ); |
47 |
is( scalar @keys, 6, 'GetColumnDefs correctly returns the 5 tables defined in columns.def' ); |
45 |
my @tables = ( 'biblio', 'biblioitems', 'borrowers', 'items', 'statistics', 'subscription'); |
48 |
my @tables = qw( 'biblio', 'biblioitems', 'borrowers', 'items', 'statistics', 'subscription'); |
46 |
cmp_deeply( \@keys, \@tables, "GetColumnDefs returns the expected tables"); |
49 |
cmp_deeply( \@keys, \@tables, 'GetColumnDefs returns the expected tables'); |
47 |
|
50 |
|
|
|
51 |
subtest 'Test C4::Templates::themelanguage' => sub { |
52 |
plan tests => 4; |
53 |
my $testing_language; |
54 |
my $module_language = Test::MockModule('C4::Languages')->new(); |
55 |
|
56 |
$module_language->mock( |
57 |
'getlanguage', |
58 |
sub { |
59 |
return $testing_language; |
60 |
} |
61 |
); |
62 |
|
63 |
my $cgi = CGI->new(); |
64 |
my $htdocs = C4::Context->config('intrahtdocs'); |
65 |
my $section = 'intranet'; |
66 |
|
67 |
# trigger first case. |
68 |
$testing_language = 'fr-FR'; |
69 |
my ($theme, $lang, $availablethemes) = C4::Templates::themelanguage($htdocs, 'about.tt', $section, $cgi); |
70 |
is($lang,'fr-FR','Expected language: non-en'); |
71 |
|
72 |
# trigger second case. |
73 |
$testing_language = q{}; |
74 |
($theme, $lang, $availablethemes) = C4::Templates::themelanguage($htdocs, 'about.tt', $section, $cgi); |
75 |
is($lang,'en','Expected language: default en'); |
76 |
|
77 |
# trigger third case. |
78 |
my $template = $htdocs . '/prog/en/modules/about.tt'; |
79 |
($theme, $lang, $availablethemes) = C4::Templates::themelanguage($htdocs, $template, $section, $cgi); |
80 |
is($lang,q{},'Expected language: unset'); |
81 |
|
82 |
# trigger bad case. |
83 |
$template = $htdocs . '/prog/en/kaboom/about.tt'; |
84 |
($theme, $lang, $availablethemes) = C4::Templates::themelanguage($htdocs, $template, $section, $cgi); |
85 |
is($lang,undef,'Expected language: not coded for'); |
86 |
|
87 |
return; |
88 |
}; |
48 |
|
89 |
|
49 |
1; |
90 |
1; |
50 |
- |
|
|