3 # This Koha test module is a stub!
4 # Add more tests here!!!
9 use Test
::More tests
=> 8;
11 use File
::Path qw
/make_path/;
17 my $dir = File
::Temp
->newdir();
18 my @themes = ('prog', 'test');
19 my @langs = ('en', 'es-ES');
21 # create temporary files to be tested later
22 foreach my $theme (@themes) {
23 foreach my $lang (@langs) {
24 make_path
("$dir/$theme/$lang/xslt");
25 open my $fh, '>', "$dir/$theme/$lang/xslt/my_file.xslt";
26 print $fh "Theme $theme, language $lang";
32 my ($dir, $theme, $lang) = @_;
34 my $filename = C4
::XSLT
::_get_best_default_xslt_filename
($dir, $theme, $lang, 'my_file.xslt');
35 open my $fh, '<', $filename;
41 # These tests verify that we're finding the right XSLT file when present,
42 # and falling back to the right XSLT file when an exact match is not present.
43 is
(find_and_slurp
($dir, 'test', 'en' ), 'Theme test, language en', 'Found test/en');
44 is
(find_and_slurp
($dir, 'test', 'es-ES'), 'Theme test, language es-ES', 'Found test/es-ES');
45 is
(find_and_slurp
($dir, 'prog', 'en', ), 'Theme prog, language en', 'Found test/en');
46 is
(find_and_slurp
($dir, 'prog', 'es-ES'), 'Theme prog, language es-ES', 'Found test/es-ES');
47 is
(find_and_slurp
($dir, 'test', 'fr-FR'), 'Theme test, language en', 'Fell back to test/en for test/fr-FR');
48 is
(find_and_slurp
($dir, 'nope', 'es-ES'), 'Theme prog, language es-ES', 'Fell back to prog/es-ES for nope/es-ES');
49 is
(find_and_slurp
($dir, 'nope', 'fr-FR'), 'Theme prog, language en', 'Fell back to prog/en for nope/fr-FR');