xref: /PHP-8.3/sapi/cli/tests/bug43177.phpt (revision 13274912)
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                    try {
15                        eval("this is a parse error");
16                    } catch (ParseError $e) {
17                    }
18                    echo "OK\n";
19                    break;
20            case "/fatal":
21                    eval("foo();");
22                    echo "OK\n";
23                    break;
24            case "/compile":
25                    eval("class foo { final private final function bar() {} }");
26                    echo "OK\n";
27                    break;
28            case "/fatal2":
29                    foo();
30                    echo "OK\n";
31                    break;
32            default:
33                    return false;
34    }
35SCRIPT
36);
37
38$host = PHP_CLI_SERVER_HOSTNAME;
39
40foreach(array("parse", "fatal", "fatal2", "compile") as $url) {
41    $fp = php_cli_server_connect();
42    if(fwrite($fp, <<<HEADER
43GET /$url HTTP/1.1
44Host: {$host}
45
46
47HEADER
48)) {
49        while (!feof($fp)) {
50                echo fgets($fp);
51        }
52    }
53}
54
55?>
56--EXPECTF--
57HTTP/1.1 200 OK
58Host: localhost
59Date: %s
60Connection: close
61X-Powered-By: %s
62Content-type: text/html; charset=UTF-8
63
64OK
65HTTP/1.0 500 Internal Server Error
66Host: localhost
67Date: %s
68Connection: close
69X-Powered-By: %s
70Content-type: text/html; charset=UTF-8
71
72HTTP/1.0 500 Internal Server Error
73Host: localhost
74Date: %s
75Connection: close
76X-Powered-By: %s
77Content-type: text/html; charset=UTF-8
78
79HTTP/1.0 500 Internal Server Error
80Host: localhost
81Date: %s
82Connection: close
83X-Powered-By: %s
84Content-type: text/html; charset=UTF-8
85