View | Details | Raw Unified | Return to bug 12653
Collapse All | Expand All

(-)a/xt/author/icondirectories.t (-34 / +37 lines)
Lines 20-63 use lib qw( .. ); Link Here
20
20
21
use Data::Dumper;
21
use Data::Dumper;
22
use File::Find;
22
use File::Find;
23
use Test::More tests => 3;
23
use C4::Context;
24
24
25
my $opac_icon_directory  = 'koha-tmpl/opac-tmpl/prog/itemtypeimg';
25
use Test::More tests => 8;
26
my $staff_icon_directory = 'koha-tmpl/intranet-tmpl/prog/img/itemtypeimg';
26
27
27
my @themes;
28
ok( -d $opac_icon_directory, "opac_icon_directory: $opac_icon_directory exists" );
28
my $dh;
29
ok( -d $staff_icon_directory, "staff_icon_directory: $staff_icon_directory exists" );
29
# OPAC
30
30
my $htdocs = C4::Context->config('opachtdocs');
31
my $opac_icons; # hashref of filenames to sizes
31
opendir ($dh, $htdocs);
32
sub opac_wanted {
32
for my $theme ( grep { not /^\.|lib/ } readdir($dh) ) {
33
    my $file = $File::Find::name;
33
    push @themes, {
34
    $file =~ s/^$opac_icon_directory//;
34
        theme => $theme,
35
    $opac_icons->{ $file } = -s $_;
35
        icondir => "$htdocs/$theme/itemtypeimg",
36
    };
36
}
37
}
37
38
close $dh;
38
find( \&opac_wanted, $opac_icon_directory );
39
# Intranet
39
40
$htdocs = C4::Context->config('intrahtdocs');
40
my $staff_icons; # hashref of filenames to sizes
41
opendir ($dh, $htdocs);
41
sub staff_wanted {
42
for my $theme ( grep { not /^\.|lib|js/ } readdir($dh) ) {
42
    my $file = $File::Find::name;
43
    push @themes, {
43
    $file =~ s/^$staff_icon_directory//;
44
        theme => $theme,
44
    $staff_icons->{ $file } = -s $_;
45
        icondir => "$htdocs/$theme/img/itemtypeimg",
46
    };
45
}
47
}
46
find( \&staff_wanted, $staff_icon_directory );
48
close $dh;
47
48
is_deeply( $opac_icons, $staff_icons, "staff and OPAC icon directories have same contents" )
49
  or diag( Data::Dumper->Dump( [ $opac_icons ], [ 'opac_icons' ] ) );
50
51
52
53
54
55
56
57
58
59
49
50
my $icons;
51
foreach my $theme ( @themes ) {
52
    ok( -d $theme->{'icondir'}, "$theme->{'theme'}: directory exists");
60
53
54
    $icons = undef;
55
    my $where = $theme->{'icondir' };
56
    sub wanted {
57
        my $file = $_;
58
        $icons->{ $file } = -s $_;
59
    }
61
60
61
    find( \&wanted, $where );
62
62
63
    ok ( defined $icons, "Some contents in $where dir")
64
        or diag( Data::Dumper->Dump( [ $icons ], [ 'icons' ] ) );
65
}
63
66
(-)a/xt/author/translatable-templates.t (-2 / +3 lines)
Lines 12-17 construct that the extractor cannot parse. Link Here
12
12
13
=cut
13
=cut
14
14
15
use C4::Context;
15
use Test::More tests => 2;
16
use Test::More tests => 2;
16
use File::Temp qw/tempdir/;
17
use File::Temp qw/tempdir/;
17
use IPC::Open3;
18
use IPC::Open3;
Lines 22-29 use utf8; Link Here
22
my $po_dir = tempdir(CLEANUP => 1);
23
my $po_dir = tempdir(CLEANUP => 1);
23
24
24
chdir "misc/translator"; # for now, tmpl_process3.pl works only if run from its directory
25
chdir "misc/translator"; # for now, tmpl_process3.pl works only if run from its directory
25
test_string_extraction("opac",     "../../koha-tmpl/opac-tmpl/prog/en",     $po_dir);
26
test_string_extraction("opac",     "../../koha-tmpl/opac-tmpl/".    C4::Context->preference('opacthemes')."/en", $po_dir);
26
test_string_extraction("intranet", "../../koha-tmpl/intranet-tmpl/prog/en", $po_dir);
27
test_string_extraction("intranet", "../../koha-tmpl/intranet-tmpl/".C4::Context->preference('template'  )."/en", $po_dir);
27
28
28
sub test_string_extraction {
29
sub test_string_extraction {
29
    my $module       = shift;
30
    my $module       = shift;
(-)a/xt/author/valid-templates.t (-26 / +46 lines)
Lines 35-66 use File::Find; Link Here
35
use File::Spec;
35
use File::Spec;
36
use Template;
36
use Template;
37
use Test::More;
37
use Test::More;
38
# use FindBin;
38
use C4::Context;
39
# use IPC::Open3;
39
40
40
my @themes;
41
print "Testing intranet prog templates\n";
41
my $dh;
42
run_template_test(
42
# OPAC
43
    'koha-tmpl/intranet-tmpl/prog/en/modules',
43
my $htdocs = C4::Context->config('opachtdocs');
44
    'koha-tmpl/intranet-tmpl/prog/en/includes'
44
opendir ($dh, $htdocs);
45
);
45
for my $theme ( grep { not /^\.|lib/ } readdir($dh) ) {
46
46
    push @themes, {
47
print "Testing opac bootstrap templates\n";
47
        theme    => $theme,
48
run_template_test(
48
        modules  => "$htdocs/$theme/en/modules",
49
    'koha-tmpl/opac-tmpl/bootstrap/en/modules',
49
        includes => "$htdocs/$theme/en/includes",
50
    'koha-tmpl/opac-tmpl/bootstrap/en/includes',
50
    }
51
    # templates to exclude from testing because
51
}
52
    # they cannot stand alone
52
close $dh;
53
    'doc-head-close.inc',
53
# Intranet
54
    'opac-bottom.inc',
54
$htdocs = C4::Context->config('intrahtdocs');
55
);
55
opendir ($dh, $htdocs);
56
56
for my $theme ( grep { not /^\.|lib|js/ } readdir($dh) ) {
57
print "Testing opac prog templates\n";
57
    push @themes, {
58
run_template_test(
58
        theme    => $theme,
59
    'koha-tmpl/opac-tmpl/prog/en/modules',
59
        modules  => "$htdocs/$theme/en/modules",
60
    'koha-tmpl/opac-tmpl/prog/en/includes'
60
        includes => "$htdocs/$theme/en/includes",
61
);
61
    }
62
62
}
63
# TODO add test of opac ccsr templates
63
close $dh;
64
65
foreach my $theme ( @themes ) {
66
    print "Testing $theme->{'theme'} templates\n";
67
    if ( $theme->{'theme'} eq 'bootstrap' ) {
68
        run_template_test(
69
            $theme->{'modules'},
70
            $theme->{'includes'},
71
            # templates to exclude from testing because
72
            # they cannot stand alone
73
            'doc-head-close.inc',
74
            'opac-bottom.inc',
75
        );
76
    }
77
    else{
78
        run_template_test(
79
            $theme->{'modules'},
80
            $theme->{'includes'},
81
        );
82
    }
83
}
64
84
65
done_testing();
85
done_testing();
66
86
(-)a/xt/single_quotes.t (-5 / +20 lines)
Lines 21-26 use warnings; Link Here
21
use strict;
21
use strict;
22
use Test::More tests => 1;
22
use Test::More tests => 1;
23
use File::Find;
23
use File::Find;
24
use C4::Context;
25
26
my @themes;
27
my $dh;
28
# OPAC
29
my $htdocs = C4::Context->config('opachtdocs');
30
opendir ($dh, $htdocs);
31
for my $theme ( grep { not /^\.|lib/ } readdir($dh) ) {
32
    push @themes, "$htdocs/$theme";
33
}
34
close $dh;
35
# Intranet
36
$htdocs = C4::Context->config('intrahtdocs');
37
opendir ($dh, $htdocs);
38
for my $theme ( grep { not /^\.|lib|js/ } readdir($dh) ) {
39
    push @themes, "$htdocs/$theme";
40
}
41
close $dh;
24
42
25
my @files;
43
my @files;
26
find(
44
find(
Lines 28-38 find( Link Here
28
        open my $fh, $_ or die "Could not open $_: $!";
46
        open my $fh, $_ or die "Could not open $_: $!";
29
        my @lines = sort grep /\_\(\'/, <$fh>;
47
        my @lines = sort grep /\_\(\'/, <$fh>;
30
        push @files, { name => "$_", lines => \@lines } if @lines;
48
        push @files, { name => "$_", lines => \@lines } if @lines;
31
    },qw#
49
    },
32
    ./koha-tmpl/opac-tmpl/prog/en
50
    @themes
33
    ./koha-tmpl/opac-tmpl/bootstrap/en
34
    ./koha-tmpl/intranet-tmpl/prog/en
35
    #
36
);
51
);
37
52
38
ok( !@files, "Files do not contain single quotes _(' " )
53
ok( !@files, "Files do not contain single quotes _(' " )
(-)a/xt/tt_valid.t (-5 / +20 lines)
Lines 23-29 use Test::More tests => 2; Link Here
23
use File::Find;
23
use File::Find;
24
use Cwd;
24
use Cwd;
25
use C4::TTParser;
25
use C4::TTParser;
26
26
use C4::Context;
27
28
my @themes;
29
my $dh;
30
# OPAC
31
my $htdocs = C4::Context->config('opachtdocs');
32
opendir ($dh, $htdocs);
33
for my $theme ( grep { not /^\.|lib/ } readdir($dh) ) {
34
    push @themes, "$htdocs/$theme";
35
}
36
close $dh;
37
# Intranet
38
$htdocs = C4::Context->config('intrahtdocs');
39
opendir ($dh, $htdocs);
40
for my $theme ( grep { not /^\.|lib|js/ } readdir($dh) ) {
41
    push @themes, "$htdocs/$theme";
42
}
43
close $dh;
27
44
28
my @files_with_directive_in_tag = do {
45
my @files_with_directive_in_tag = do {
29
    my @files;
46
    my @files;
Lines 42-54 my @files_with_directive_in_tag = do { Link Here
42
        }
59
        }
43
        ($dir) = $dir =~ /koha-tmpl\/(.*)$/;
60
        ($dir) = $dir =~ /koha-tmpl\/(.*)$/;
44
        push @files, { name => "$dir/$name", lines => \@lines } if @lines;
61
        push @files, { name => "$dir/$name", lines => \@lines } if @lines;
45
      }, ( "./koha-tmpl/opac-tmpl/prog/en",
62
      },
46
           "./koha-tmpl/intranet-tmpl/prog/en" )
63
      @themes,
47
    );
64
    );
48
    @files;
65
    @files;
49
};
66
};
50
67
51
52
ok( !@files_with_directive_in_tag, "TT syntax: not using TT directive within HTML tag" )
68
ok( !@files_with_directive_in_tag, "TT syntax: not using TT directive within HTML tag" )
53
    or diag(
69
    or diag(
54
          "Files list: \n",
70
          "Files list: \n",
55
- 

Return to bug 12653