3 # add current source dir to the include-path
4 # we need this for make distcheck
5 (my $srcdir = $0) =~ s
,/[^/]+$,/,;
11 use Test
::More tests
=> 8;
14 my $tf = LightyTest
->new();
19 skip
"PHP already running on port 1026", 1 if $tf->listening_on(1026);
20 skip
"no php binary found", 1 unless $LightyTest::HAVE_PHP
;
21 ok
(-1 != ($php_child = $tf->spawnfcgi($ENV{'PHP'}, 1026)), "Spawning php");
25 skip
"no PHP running on port 1026", 6 unless $tf->listening_on(1026);
27 ok
($tf->start_proc == 0, "Starting lighttpd") or goto cleanup
;
29 $t->{REQUEST
} = ( <<EOF
30 GET /rewrite/foo HTTP/1.0
34 $t->{RESPONSE
} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => '' } ];
35 ok
($tf->handle_http($t) == 0, 'valid request');
37 $t->{REQUEST
} = ( <<EOF
38 GET /rewrite/foo?a=b HTTP/1.0
42 $t->{RESPONSE
} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => 'a=b' } ];
43 ok
($tf->handle_http($t) == 0, 'valid request');
45 $t->{REQUEST
} = ( <<EOF
46 GET /rewrite/bar?a=b HTTP/1.0
50 $t->{RESPONSE
} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => 'bar&a=b' } ];
51 ok
($tf->handle_http($t) == 0, 'valid request');
53 $t->{REQUEST
} = ( <<EOF
54 GET /rewrite/nofile?a=b HTTP/1.0
58 $t->{RESPONSE
} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => 'file=/rewrite/nofile&a=b' } ];
59 ok
($tf->handle_http($t) == 0, 'not existing file rewrite');
61 ok
($tf->stop_proc == 0, "Stopping lighttpd");
65 skip
"PHP not started, cannot stop it", 1 unless $php_child != -1;
66 ok
(0 == $tf->endspawnfcgi($php_child), "Stopping php");
74 $tf->endspawnfcgi($php_child) if $php_child != -1;