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