5 use File::Basename qw( dirname );
7 use Test::More tests => 25;
11 $PLP::use_cache = 0 if $PLP::use_cache;
12 #TODO: caching on (change file names)
14 chdir File::Spec->catdir(dirname($0), '50-cgi')
15 or BAIL_OUT('cannot change to test directory ./50-cgi/');
16 my $ORGDIR = '.'; # Cwd::getcwd();
18 # 0*: permission checks using generated dummy files
20 for my $file (glob '0*.html') {
21 $file =~ s/[.]html$/.plp/;
22 my ($mode) = $file =~ /^..-(\d*)\b/;
25 return 1; # do not create
29 open my $out, '>', $file or die "cannot generate source file ($!)\n";
33 chmod 0244, $file or die "cannot change permissions ($!)\n";
37 } or chomp $@, skip("$file: $@", 1); # ignore generation failure
40 eval { unlink $file }; # clean up
43 # 1*-2*: generic tests with standard environment
44 plp_ok($_) for glob '[12]*.html';
46 # 3*: error tests depending on warning message
48 my @inctests = glob '3*.html';
50 my $INCFILE = File::Spec->rel2abs("$ORGDIR/missinginclude");
51 if (open my $dummy, "<", $INCFILE) { # like PLP::source will
52 fail("file missinginclude shouldn't exist");
53 skip("missinginclude tests (3*)", @inctests - 1);
55 my $INCWARN = qq{Can't open "$INCFILE" ($!)};
57 plp_ok($_, INCWARN => $INCWARN) for @inctests;
60 # 4*-6*: apache environment (default)
61 plp_ok($_) for glob '[4-6]*.html';
68 local $TODO = 'future feature';
70 CONTENT_TYPE => 'multipart/form-data; boundary=knip',
71 }) for glob '7*.html';
74 # 8*: lighttpd environment
76 # lighttpd/1.4.7 CGI environment
77 REQUEST_METHOD => 'GET',
78 REQUEST_URI => "/$_/test/123",
79 QUERY_STRING => 'test=1&test=2',
80 GATEWAY_INTERFACE => 'CGI/1.1',
82 SCRIPT_NAME => "/$_", #XXX: .plp?
83 SCRIPT_FILENAME => "$ORGDIR/$_",
84 PATH_INFO => '/test/123',
85 PATH_TRANSLATED => undef,
86 DOCUMENT_ROOT => undef,