bug78323.phpt 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. --TEST--
  2. Bug #78323 Test exit code and error message for invalid parameters
  3. --SKIPIF--
  4. <?php
  5. include "skipif.inc";
  6. ?>
  7. --FILE--
  8. <?php
  9. $php = getenv('TEST_PHP_EXECUTABLE');
  10. // There are 3 types of option errors:
  11. // 1 : in flags
  12. // 2 option not found
  13. // 3 no argument for option
  14. // colon in flags
  15. ob_start();
  16. passthru("$php -a:Z 2>&1", $exitCode);
  17. $output = ob_get_contents();
  18. ob_end_clean();
  19. $lines = preg_split('/\R/', $output);
  20. echo $lines[0], "\n",
  21. $lines[1], "\n",
  22. "Done: $exitCode\n\n";
  23. // option not found
  24. ob_start();
  25. passthru("$php -Z 2>&1", $exitCode);
  26. $output = ob_get_contents();
  27. ob_end_clean();
  28. $lines = preg_split('/\R/', $output);
  29. echo $lines[0], "\n",
  30. $lines[1], "\n",
  31. "Done: $exitCode\n\n";
  32. // no argument for option
  33. ob_start();
  34. passthru("$php --memory-limit=1G 2>&1", $exitCode);
  35. $output = ob_get_contents();
  36. ob_end_clean();
  37. $lines = preg_split('/\R/', $output);
  38. echo $lines[0], "\n",
  39. $lines[1], "\n",
  40. "Done: $exitCode\n\n";
  41. // Successful execution
  42. ob_start();
  43. passthru("$php -dmemory-limit=1G -v", $exitCode);
  44. $output = ob_get_contents();
  45. ob_end_clean();
  46. $lines = preg_split('/\R/', $output);
  47. echo $lines[0], "\n",
  48. "Done: $exitCode\n";
  49. ?>
  50. --EXPECTF--
  51. Error in argument %d, char %d: : in flags
  52. Usage: %s [options] [-f] <file> [--] [args...]
  53. Done: 1
  54. Error in argument %d, char %d: option not found %s
  55. Usage: %s [options] [-f] <file> [--] [args...]
  56. Done: 1
  57. Error in argument %d, char %d: no argument for option %s
  58. Usage: %s [options] [-f] <file> [--] [args...]
  59. Done: 1
  60. PHP %s
  61. Done: 0