Bug 7276 : Follow up, adding a sub to clear the cache
[koha.git] / xt / author / icondirectories.t
1 #!/usr/bin/env perl
2
3 =head1 NAME
4
5 icondirectories.t - test to ensure that the two directories of icons
6 in the staff and opac interface are identical.
7
8 =head1 DESCRIPTION
9
10 Tere are two directories of icons for media types, one for the opac
11 and one for the staff interface. They need to be identical. This
12 ensures that they are.
13
14 =cut
15
16 use strict;
17 use warnings;
18
19 use lib qw( .. );
20
21 use Data::Dumper;
22 use File::Find;
23 use Test::More tests => 3;
24
25 my $opac_icon_directory  = 'koha-tmpl/opac-tmpl/prog/itemtypeimg';
26 my $staff_icon_directory = 'koha-tmpl/intranet-tmpl/prog/img/itemtypeimg';
27
28 ok( -d $opac_icon_directory, "opac_icon_directory: $opac_icon_directory exists" );
29 ok( -d $staff_icon_directory, "staff_icon_directory: $staff_icon_directory exists" );
30
31 my $opac_icons; # hashref of filenames to sizes
32 sub opac_wanted {
33     my $file = $File::Find::name;
34     $file =~ s/^$opac_icon_directory//;
35     $opac_icons->{ $file } = -s $_;
36 }
37
38 find( \&opac_wanted, $opac_icon_directory );
39
40 my $staff_icons; # hashref of filenames to sizes
41 sub staff_wanted {
42     my $file = $File::Find::name;
43     $file =~ s/^$staff_icon_directory//;
44     $staff_icons->{ $file } = -s $_;
45 }
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
63