summaryrefslogtreecommitdiff
path: root/sapi/cli/tests/bug43177.phpt
blob: 87dc8927ff10213a585a3e682efdcdcb54e82758 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
--TEST--
Bug #61977 Test exit code for various errors
--SKIPIF--
<?php
include "skipif.inc";
?>
--FILE--
<?php
include "php_cli_server.inc";
php_cli_server_start(<<<'SCRIPT'
	ini_set('display_errors', 0);
	switch($_SERVER["REQUEST_URI"]) {
	        case "/parse":
	                try {
                        eval("this is a parse error");
                    } catch (ParseError $e) {
                    }
					echo "OK\n";
	                break;
	        case "/fatal":
	                eval("foo();");
					echo "OK\n";
	                break;
			case "/compile":
					eval("class foo { final private final function bar() {} }");
					echo "OK\n";
					break;
			case "/fatal2":
					foo();
					echo "OK\n";
					break;
	        default:
	                return false;
	}
SCRIPT
);

list($host, $port) = explode(':', PHP_CLI_SERVER_ADDRESS);
$port = intval($port)?:80;

foreach(array("parse", "fatal", "fatal2", "compile") as $url) {
	$fp = fsockopen($host, $port, $errno, $errstr, 0.5);
	if (!$fp) {
  		die("connect failed");
	}

	if(fwrite($fp, <<<HEADER
GET /$url HTTP/1.1
Host: {$host}


HEADER
)) {
        while (!feof($fp)) {
                echo fgets($fp);
        }
	}
}

?>
--EXPECTF--
HTTP/1.1 200 OK
Host: localhost
Date: %s
Connection: close
X-Powered-By: %s
Content-type: text/html; charset=UTF-8

OK
HTTP/1.0 500 Internal Server Error
Host: localhost
Date: %s
Connection: close
X-Powered-By: %s
Content-type: text/html; charset=UTF-8

HTTP/1.0 500 Internal Server Error
Host: localhost
Date: %s
Connection: close
X-Powered-By: %s
Content-type: text/html; charset=UTF-8

HTTP/1.0 500 Internal Server Error
Host: localhost
Date: %s
Connection: close
X-Powered-By: %s
Content-type: text/html; charset=UTF-8