bug43177.phpt 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. --TEST--
  2. Bug #61977 Test exit code for various errors
  3. --SKIPIF--
  4. <?php
  5. include "skipif.inc";
  6. ?>
  7. --FILE--
  8. <?php
  9. include "php_cli_server.inc";
  10. php_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. }
  35. SCRIPT
  36. );
  37. $host = PHP_CLI_SERVER_HOSTNAME;
  38. foreach(array("parse", "fatal", "fatal2", "compile") as $url) {
  39. $fp = php_cli_server_connect();
  40. if(fwrite($fp, <<<HEADER
  41. GET /$url HTTP/1.1
  42. Host: {$host}
  43. HEADER
  44. )) {
  45. while (!feof($fp)) {
  46. echo fgets($fp);
  47. }
  48. }
  49. }
  50. ?>
  51. --EXPECTF--
  52. HTTP/1.1 200 OK
  53. Host: localhost
  54. Date: %s
  55. Connection: close
  56. X-Powered-By: %s
  57. Content-type: text/html; charset=UTF-8
  58. OK
  59. HTTP/1.0 500 Internal Server Error
  60. Host: localhost
  61. Date: %s
  62. Connection: close
  63. X-Powered-By: %s
  64. Content-type: text/html; charset=UTF-8
  65. HTTP/1.0 500 Internal Server Error
  66. Host: localhost
  67. Date: %s
  68. Connection: close
  69. X-Powered-By: %s
  70. Content-type: text/html; charset=UTF-8
  71. HTTP/1.0 500 Internal Server Error
  72. Host: localhost
  73. Date: %s
  74. Connection: close
  75. X-Powered-By: %s
  76. Content-type: text/html; charset=UTF-8