Bug 14585: Fixing up online help on main page
[koha.git] / xt / author / icondirectories.t
blobe5b00394746e43adcdf4fdf89b18cf997e80e1ae
1 #!/usr/bin/env perl
3 # This file is part of Koha.
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.
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.
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>.
18 =head1 NAME
20 icondirectories.t - test to ensure that the two directories of icons
21 in the staff and opac interface are identical.
23 =head1 DESCRIPTION
25 Tere are two directories of icons for media types, one for the opac
26 and one for the staff interface. They need to be identical. This
27 ensures that they are.
29 =cut
31 use Modern::Perl;
33 use lib qw( .. );
35 use Data::Dumper;
36 use File::Find;
37 use Test::More tests => 3;
39 # hardcoded OPAC & STAFF dirs
40 my $opac_dir = 'koha-tmpl/opac-tmpl';
41 my $staff_dir = 'koha-tmpl/intranet-tmpl';
43 # Find OPAC themes
44 opendir ( my $dh, $opac_dir ) or die "can't opendir $opac_dir: $!";
45 my @opac_themes = grep { not /^\.|lib|js/ } readdir($dh);
46 close $dh;
48 # Find STAFF themes
49 opendir ( $dh, $staff_dir ) or die "can't opendir $staff_dir: $!";
50 my @staff_themes = grep { not /^\.|lib|js/ } readdir($dh);
51 close $dh;
53 # Check existence of OPAC icon dirs
54 for my $theme ( @opac_themes ) {
55 my $test_dir = "$opac_dir/$theme/itemtypeimg";
56 ok( -d $test_dir, "opac_icon_directory: $test_dir exists" );
59 # Check existence of STAFF icon dirs
60 for my $theme ( @staff_themes ) {
61 my $test_dir = "$staff_dir/$theme/img/itemtypeimg";
62 ok( -d $test_dir, "staff_icon_directory: $test_dir exists" );
65 # Check for same contents on STAFF and OPAC icondirs
66 # foreach STAFF theme
67 for my $staff_theme ( @staff_themes ) {
68 my $staff_icons; # hashref of filenames to sizes
69 my $staff_icon_directory = "$staff_dir/$staff_theme/img/itemtypeimg";
70 my $staff_wanted = sub {
71 my $file = $File::Find::name;
72 $file =~ s/^$staff_icon_directory//;
73 $staff_icons->{ $file } = -s $_;
75 find( { wanted => $staff_wanted }, $staff_icon_directory );
77 # foreach OPAC theme
78 for my $opac_theme ( @opac_themes ) {
79 next if ( $opac_theme =~ /ccsr/ ); # FIXME: skip CCSR opac theme, it fails and there is no point to fix it
80 my $opac_icons; # hashref of filenames to sizes
81 my $opac_icon_directory = "$opac_dir/$opac_theme/itemtypeimg";
82 my $opac_wanted = sub {
83 my $file = $File::Find::name;
84 $file =~ s/^$opac_icon_directory//;
85 $opac_icons->{ $file } = -s $_;
87 find( { wanted => $opac_wanted }, $opac_icon_directory );
89 is_deeply( $opac_icons, $staff_icons, "STAFF $staff_theme and OPAC $opac_theme icon directories have same contents" )
90 or diag( Data::Dumper->Dump( [ $opac_icons ], [ 'opac_icons' ] ) );