"Fossies" - the Fresh Open Source Software Archive 
Member "Apache-Gallery-1.0.2/t/004_cache_dir.t" (8 Jun 2011, 2099 Bytes) of package /linux/www/old/Apache-Gallery-1.0.2.tar.gz:
As a special service "Fossies" has tried to format the requested text file into HTML format (style:
standard) with prefixed line numbers.
Alternatively you can here
view or
download the uninterpreted source code file.
1 use Apache::Gallery;
2 my $tests;
3 BEGIN {
4 $tests=8;
5 eval { require Test::MockObject };
6 if ($@) {
7 print("1..$tests\n");
8 for (1..$tests) {
9 print ("ok $_ # skip Test::MockObject not found\n");
10 }
11 exit 0;
12 }
13 }
14 use Test::More tests => $tests;
15 use File::Spec;
16
17 # Test these cases:
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 # +-----+-----------------+---------+----------------+
29
30 sub request {
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);
40
41 return $r;
42 }
43
44 my $r=request(undef, 1);
45 is(Apache::Gallery::cache_dir($r, 1), '/var/tmp/Apache-Gallery/hostname/uripath1/uripath2');
46 is(Apache::Gallery::cache_dir($r, 0), '/var/tmp/Apache-Gallery/hostname/uripath1/uripath2/urifile');
47
48 $r=request(undef, 0);
49 is(Apache::Gallery::cache_dir($r, 1), '/var/tmp/Apache-Gallery/location/uripath1/uripath2');
50 is(Apache::Gallery::cache_dir($r, 0), '/var/tmp/Apache-Gallery/location/uripath1/uripath2/urifile');
51
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');
55
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');