5 eval { require Test::MockObject };
9 print ("ok $_ # skip Test::MockObject not found\n");
14 use Test::More tests => $tests;
18 # +--------------------------------------------------+
19 # | No. | GalleryCacheDir | Virtual | Strip Filename |
20 # | 1 | undef | y | y |
21 # | 2 | undef | y | n |
22 # | 3 | undef | n | y |
23 # | 4 | undef | n | n |
24 # | 5 | 't/cachetest' | y | y |
25 # | 6 | 't/cachetest' | y | n |
26 # | 7 | 't/cachetest' | n | y |
27 # | 8 | 't/cachetest' | n | n |
28 # +-----+-----------------+---------+----------------+
31 my ($cachedir, $virtual) = @_;
32 my $r=Test::MockObject->new();
33 $r->set_always('location', '/location');
34 $r->set_always('uri', '/uripath1/uripath2/urifile');
35 $r->set_always('dir_config', $cachedir);
36 my $server=Test::MockObject->new();
37 $server->set_always('is_virtual', $virtual);
38 $server->set_always('server_hostname', 'hostname' );
39 $r->set_always('server', $server);
44 my $r=request(undef, 1);
45 is(Apache::Gallery::cache_dir($r, 1), '/var/cache/www/hostname/uripath1/uripath2');
46 is(Apache::Gallery::cache_dir($r, 0), '/var/cache/www/hostname/uripath1/uripath2/urifile');
49 is(Apache::Gallery::cache_dir($r, 1), '/var/cache/www/location/uripath1/uripath2');
50 is(Apache::Gallery::cache_dir($r, 0), '/var/cache/www/location/uripath1/uripath2/urifile');
52 $r=request('t/cachetest', 1);
53 is(Apache::Gallery::cache_dir($r, 1), 't/cachetest/uripath1/uripath2');
54 is(Apache::Gallery::cache_dir($r, 0), 't/cachetest/uripath1/uripath2/urifile');
56 $r=request('t/cachetest', 0);
57 is(Apache::Gallery::cache_dir($r, 1), 't/cachetest/uripath1/uripath2');
58 is(Apache::Gallery::cache_dir($r, 0), 't/cachetest/uripath1/uripath2/urifile');