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

(-)a/xt/author/icondirectories.t (-36 / +67 lines)
Lines 1-5 Link Here
1
#!/usr/bin/env perl
1
#!/usr/bin/env perl
2
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 3 of the License, or
8
# (at your option) any later version.
9
#
10
# Koha is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with Koha; if not, see <http://www.gnu.org/licenses>.
17
3
=head1 NAME
18
=head1 NAME
4
19
5
icondirectories.t - test to ensure that the two directories of icons
20
icondirectories.t - test to ensure that the two directories of icons
Lines 20-63 use lib qw( .. ); Link Here
20
35
21
use Data::Dumper;
36
use Data::Dumper;
22
use File::Find;
37
use File::Find;
23
use Test::More tests => 3;
38
use Test::More tests => 6;
24
39
25
my $opac_icon_directory  = 'koha-tmpl/opac-tmpl/prog/itemtypeimg';
40
# hardcoded OPAC & STAFF dirs
26
my $staff_icon_directory = 'koha-tmpl/intranet-tmpl/prog/img/itemtypeimg';
41
my $opac_dir  = 'koha-tmpl/opac-tmpl';
27
42
my $staff_dir = 'koha-tmpl/intranet-tmpl';
28
ok( -d $opac_icon_directory, "opac_icon_directory: $opac_icon_directory exists" );
43
29
ok( -d $staff_icon_directory, "staff_icon_directory: $staff_icon_directory exists" );
44
# Find OPAC themes
30
45
opendir ( my $dh, $opac_dir ) or die "can't opendir $opac_dir: $!";
31
my $opac_icons; # hashref of filenames to sizes
46
my @opac_themes = grep { not /^\.|lib|js/ } readdir($dh);
32
sub opac_wanted {
47
close $dh;
33
    my $file = $File::Find::name;
48
34
    $file =~ s/^$opac_icon_directory//;
49
# Find STAFF themes
35
    $opac_icons->{ $file } = -s $_;
50
opendir ( $dh, $staff_dir ) or die "can't opendir $staff_dir: $!";
51
my @staff_themes = grep { not /^\.|lib|js/ } readdir($dh);
52
close $dh;
53
54
# Check existence of OPAC icon dirs
55
for my $theme ( @opac_themes ) {
56
    my $test_dir = "$opac_dir/$theme/itemtypeimg";
57
    ok( -d $test_dir, "opac_icon_directory: $test_dir exists" );
36
}
58
}
37
59
38
find( \&opac_wanted, $opac_icon_directory );
60
# Check existence of STAFF icon dirs
39
61
for my $theme ( @staff_themes ) {
40
my $staff_icons; # hashref of filenames to sizes
62
    my $test_dir = "$staff_dir/$theme/img/itemtypeimg";
41
sub staff_wanted {
63
    ok( -d $test_dir, "staff_icon_directory: $test_dir exists" );
42
    my $file = $File::Find::name;
43
    $file =~ s/^$staff_icon_directory//;
44
    $staff_icons->{ $file } = -s $_;
45
}
64
}
46
find( \&staff_wanted, $staff_icon_directory );
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
60
61
62
65
66
# Check for same contents on STAFF and OPAC icondirs
67
# foreach STAFF theme
68
for my $staff_theme ( @staff_themes ) {
69
    my $staff_icons; # hashref of filenames to sizes
70
    my $staff_icon_directory = "$staff_dir/$staff_theme/img/itemtypeimg";
71
    my $staff_wanted = sub {
72
        my $file = $File::Find::name;
73
        $file =~ s/^$staff_icon_directory//;
74
        $staff_icons->{ $file } = -s $_;
75
    };
76
    find( { wanted => $staff_wanted }, $staff_icon_directory );
77
78
    # foreach OPAC theme
79
    for my $opac_theme ( @opac_themes ) {
80
        next if ( $opac_theme =~ /ccsr/ );  # FIXME: skip CCSR opac theme, it fails and there is no point to fix it
81
        my $opac_icons; # hashref of filenames to sizes
82
        my $opac_icon_directory  = "$opac_dir/$opac_theme/itemtypeimg";
83
        my $opac_wanted  = sub {
84
            my $file = $File::Find::name;
85
            $file =~ s/^$opac_icon_directory//;
86
            $opac_icons->{ $file } = -s $_;
87
        };
88
        find( { wanted => $opac_wanted }, $opac_icon_directory );
89
90
        is_deeply( $opac_icons, $staff_icons, "STAFF $staff_theme and OPAC $opac_theme icon directories have same contents" )
91
            or diag( Data::Dumper->Dump( [ $opac_icons ], [ 'opac_icons' ] ) );
92
    }
93
}
63
94
(-)a/xt/author/translatable-templates.t (-3 / +40 lines)
Lines 1-5 Link Here
1
#!/usr/bin/perl
1
#!/usr/bin/perl
2
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 3 of the License, or
8
# (at your option) any later version.
9
#
10
# Koha is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with Koha; if not, see <http://www.gnu.org/licenses>.
17
3
use strict;
18
use strict;
4
use warnings;
19
use warnings;
5
20
Lines 12-18 construct that the extractor cannot parse. Link Here
12
27
13
=cut
28
=cut
14
29
15
use Test::More tests => 2;
30
use Test::More;
16
use File::Temp qw/tempdir/;
31
use File::Temp qw/tempdir/;
17
use IPC::Open3;
32
use IPC::Open3;
18
use File::Spec;
33
use File::Spec;
Lines 21-29 use utf8; Link Here
21
36
22
my $po_dir = tempdir(CLEANUP => 1);
37
my $po_dir = tempdir(CLEANUP => 1);
23
38
39
# Find OPAC themes
40
my $opac_dir  = 'koha-tmpl/opac-tmpl';
41
opendir ( my $dh, $opac_dir ) or die "can't opendir $opac_dir: $!";
42
my @opac_themes = grep { not /^\.|lib|js/ } readdir($dh);
43
close $dh;
44
45
# Find STAFF themes
46
my $staff_dir = 'koha-tmpl/intranet-tmpl';
47
opendir ( $dh, $staff_dir ) or die "can't opendir $staff_dir: $!";
48
my @staff_themes = grep { not /^\.|lib|js/ } readdir($dh);
49
close $dh;
50
24
chdir "misc/translator"; # for now, tmpl_process3.pl works only if run from its directory
51
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);
52
26
test_string_extraction("intranet", "../../koha-tmpl/intranet-tmpl/prog/en", $po_dir);
53
# Check translatable of OPAC themes
54
for my $theme ( @opac_themes ) {
55
    test_string_extraction("opac_$theme",     "../../koha-tmpl/opac-tmpl/$theme/en",     $po_dir);
56
}
57
58
# Check translatable of STAFF themes
59
for my $theme ( @staff_themes ) {
60
    test_string_extraction("staff_$theme",     "../../koha-tmpl/intranet-tmpl/$theme/en",     $po_dir);
61
}
27
62
28
sub test_string_extraction {
63
sub test_string_extraction {
29
    my $module       = shift;
64
    my $module       = shift;
Lines 53-55 sub test_string_extraction { Link Here
53
88
54
    ok($#warnings == -1, "$module templates are translatable") or diag join("\n", @warnings, '');
89
    ok($#warnings == -1, "$module templates are translatable") or diag join("\n", @warnings, '');
55
}
90
}
91
92
done_testing();
(-)a/xt/author/valid-templates.t (-40 / +65 lines)
Lines 1-21 Link Here
1
#!/usr/bin/perl
1
#!/usr/bin/perl
2
2
3
# Copyright 2011 Catalyst IT
4
# 
5
# This file is part of Koha.
3
# This file is part of Koha.
6
#
4
#
7
# Koha is free software; you can redistribute it and/or modify it under the
5
# Copyright 2011 Catalyst IT
8
# terms of the GNU General Public License as published by the Free Software
6
#
9
# Foundation; either version 2 of the License, or (at your option) any later
7
# Koha is free software; you can redistribute it and/or modify it
10
# version.
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
12
# Koha is distributed in the hope that it will be useful, but
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
15
#
16
#
16
# You should have received a copy of the GNU General Public License along
17
# You should have received a copy of the GNU General Public License
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
19
20
use strict;
20
use strict;
21
use warnings;
21
use warnings;
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
39
# use IPC::Open3;
39
my @themes;
40
40
41
print "Testing intranet prog templates\n";
41
# OPAC themes
42
run_template_test(
42
my $opac_dir  = 'koha-tmpl/opac-tmpl';
43
    'koha-tmpl/intranet-tmpl/prog/en/modules',
43
opendir ( my $dh, $opac_dir ) or die "can't opendir $opac_dir: $!";
44
    'koha-tmpl/intranet-tmpl/prog/en/includes'
44
for my $theme ( grep { not /^\.|lib|js/ } readdir($dh) ) {
45
);
45
    push @themes, {
46
46
        type     => "opac",
47
print "Testing opac bootstrap templates\n";
47
        theme    => $theme,
48
run_template_test(
48
        modules  => "$opac_dir/$theme/en/modules",
49
    'koha-tmpl/opac-tmpl/bootstrap/en/modules',
49
        includes => "$opac_dir/$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
54
    'opac-bottom.inc',
54
# STAFF themes
55
);
55
my $staff_dir = 'koha-tmpl/intranet-tmpl';
56
56
opendir ( $dh, $staff_dir ) or die "can't opendir $staff_dir: $!";
57
print "Testing opac prog templates\n";
57
for my $theme ( grep { not /^\.|lib|js/ } readdir($dh) ) {
58
run_template_test(
58
    push @themes, {
59
    'koha-tmpl/opac-tmpl/prog/en/modules',
59
        type     => "staff",
60
    'koha-tmpl/opac-tmpl/prog/en/includes'
60
        theme    => $theme,
61
);
61
        modules  => "$staff_dir/$theme/en/modules",
62
62
        includes => "$staff_dir/$theme/en/includes",
63
# TODO add test of opac ccsr templates
63
    }
64
}
65
close $dh;
66
67
# Tests
68
foreach my $theme ( @themes ) {
69
    print "Testing $theme->{'type'} $theme->{'theme'} templates\n";
70
    if ( $theme->{'theme'} eq 'bootstrap' ) {
71
        run_template_test(
72
            $theme->{'modules'},
73
            $theme->{'includes'},
74
            # templates to exclude from testing because
75
            # they cannot stand alone
76
            'doc-head-close.inc',
77
            'opac-bottom.inc',
78
        );
79
    }
80
    else {
81
        run_template_test(
82
            $theme->{'modules'},
83
            $theme->{'includes'},
84
        );
85
    }
86
}
64
87
65
done_testing();
88
done_testing();
66
89
Lines 94-101 sub create_template_test { Link Here
94
        }
117
        }
95
        my $vars;
118
        my $vars;
96
        my $output;
119
        my $output;
97
        if ( !ok( $tt->process( $_, $vars, \$output ), $_ ) ) {
120
        if ( ! -d $_ ) {    # skip dirs
98
            diag( $tt->error );
121
            if ( !ok( $tt->process( $_, $vars, \$output ), $_ ) ) {
122
                diag( $tt->error );
123
            }
99
        }
124
        }
100
    }
125
    }
101
}
126
}
(-)a/xt/single_quotes.t (-17 / +32 lines)
Lines 1-38 Link Here
1
#!/usr/bin/perl
1
#!/usr/bin/perl
2
2
3
# Copyright (C) 2013 Horowhenua Library Trust
4
#
5
# This file is part of Koha.
3
# This file is part of Koha.
6
#
4
#
7
# Koha is free software; you can redistribute it and/or modify it under the
5
# Copyright (C) 2013 Horowhenua Library Trust
8
# terms of the GNU General Public License as published by the Free Software
6
#
9
# Foundation; either version 3 of the License, or (at your option) any later
7
# Koha is free software; you can redistribute it and/or modify it
10
# version.
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
12
# Koha is distributed in the hope that it will be useful, but
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
15
#
16
#
16
# You should have received a copy of the GNU General Public License along
17
# You should have received a copy of the GNU General Public License
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
19
20
use warnings;
20
use warnings;
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
24
25
my @themes;
26
27
# OPAC themes
28
my $opac_dir  = 'koha-tmpl/opac-tmpl';
29
opendir ( my $dh, $opac_dir ) or die "can't opendir $opac_dir: $!";
30
for my $theme ( grep { not /^\.|lib|js/ } readdir($dh) ) {
31
    push @themes, "$opac_dir/$theme/en";
32
}
33
close $dh;
34
35
# STAFF themes
36
my $staff_dir = 'koha-tmpl/intranet-tmpl';
37
opendir ( $dh, $staff_dir ) or die "can't opendir $staff_dir: $!";
38
for my $theme ( grep { not /^\.|lib|js/ } readdir($dh) ) {
39
    push @themes, "$staff_dir/$theme/en";
40
}
41
close $dh;
42
25
my @files;
43
my @files;
26
find(
44
find(
27
    sub {
45
    sub {
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 (-15 / +30 lines)
Lines 1-21 Link Here
1
#!/usr/bin/perl
1
#!/usr/bin/perl
2
2
3
# Copyright (C) 2011 Tamil s.a.r.l.
4
#
5
# This file is part of Koha.
3
# This file is part of Koha.
6
#
4
#
7
# Koha is free software; you can redistribute it and/or modify it under the
5
# Copyright (C) 2011 Tamil s.a.r.l.
8
# terms of the GNU General Public License as published by the Free Software
6
#
9
# Foundation; either version 2 of the License, or (at your option) any later
7
# Koha is free software; you can redistribute it and/or modify it
10
# version.
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
12
# Koha is distributed in the hope that it will be useful, but
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
15
#
16
#
16
# You should have received a copy of the GNU General Public License along
17
# You should have received a copy of the GNU General Public License
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
19
20
use warnings;
20
use warnings;
21
use strict;
21
use strict;
Lines 24-29 use File::Find; Link Here
24
use Cwd;
24
use Cwd;
25
use C4::TTParser;
25
use C4::TTParser;
26
26
27
my @themes;
28
29
# OPAC themes
30
my $opac_dir  = 'koha-tmpl/opac-tmpl';
31
opendir ( my $dh, $opac_dir ) or die "can't opendir $opac_dir: $!";
32
for my $theme ( grep { not /^\.|lib|js/ } readdir($dh) ) {
33
    push @themes, "$opac_dir/$theme/en";
34
}
35
close $dh;
36
37
# STAFF themes
38
my $staff_dir = 'koha-tmpl/intranet-tmpl';
39
opendir ( $dh, $staff_dir ) or die "can't opendir $staff_dir: $!";
40
for my $theme ( grep { not /^\.|lib|js/ } readdir($dh) ) {
41
    push @themes, "$staff_dir/$theme/en";
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-49 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
      }, @themes
46
           "./koha-tmpl/intranet-tmpl/prog/en" )
47
    );
63
    );
48
    @files;
64
    @files;
49
};
65
};
50
- 

Return to bug 12653