xref: /PHP-5.5/sapi/cli/tests/bug43177.phpt (revision 36e19c9c)
1--TEST--
2Bug #61977 Test exit code for various errors
3--SKIPIF--
4<?php
5include "skipif.inc";
6?>
7--FILE--
8<?php
9include "php_cli_server.inc";
10php_cli_server_start(<<<'SCRIPT'
11	ini_set('display_errors', 0);
12	switch($_SERVER["REQUEST_URI"]) {
13	        case "/parse":
14	                eval("this is a parse error");
15					echo "OK\n";
16	                break;
17	        case "/fatal":
18	                eval("foo();");
19					echo "OK\n";
20	                break;
21			case "/compile":
22					eval("class foo { final private final function bar() {} }");
23					echo "OK\n";
24					break;
25			case "/fatal2":
26					foo();
27					echo "OK\n";
28					break;
29	        default:
30	                return false;
31	}
32SCRIPT
33);
34
35list($host, $port) = explode(':', PHP_CLI_SERVER_ADDRESS);
36$port = intval($port)?:80;
37
38foreach(array("parse", "fatal", "fatal2", "compile") as $url) {
39	$fp = fsockopen($host, $port, $errno, $errstr, 0.5);
40	if (!$fp) {
41  		die("connect failed");
42	}
43
44	if(fwrite($fp, <<<HEADER
45GET /$url HTTP/1.1
46Host: {$host}
47
48
49HEADER
50)) {
51        while (!feof($fp)) {
52                echo fgets($fp);
53        }
54	}
55}
56
57?>
58--EXPECTF--
59HTTP/1.1 200 OK
60Host: localhost
61Connection: close
62X-Powered-By: %s
63Content-type: text/html
64
65OK
66HTTP/1.0 500 Internal Server Error
67Host: localhost
68Connection: close
69X-Powered-By: %s
70Content-type: text/html
71
72HTTP/1.0 500 Internal Server Error
73Host: localhost
74Connection: close
75X-Powered-By: %s
76Content-type: text/html
77
78HTTP/1.0 500 Internal Server Error
79Host: localhost
80Connection: close
81X-Powered-By: %s
82Content-type: text/html
83