|
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 |
|