003.phpt 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. --TEST--
  2. Test ErrorHandler in case of fatal error
  3. --SKIPIF--
  4. <?php if (!extension_loaded('symfony_debug')) {
  5. echo 'skip';
  6. } ?>
  7. --FILE--
  8. <?php
  9. namespace Psr\Log;
  10. class LogLevel
  11. {
  12. const EMERGENCY = 'emergency';
  13. const ALERT = 'alert';
  14. const CRITICAL = 'critical';
  15. const ERROR = 'error';
  16. const WARNING = 'warning';
  17. const NOTICE = 'notice';
  18. const INFO = 'info';
  19. const DEBUG = 'debug';
  20. }
  21. namespace Symfony\Component\Debug;
  22. $dir = __DIR__.'/../../../';
  23. require $dir.'ErrorHandler.php';
  24. require $dir.'Exception/FatalErrorException.php';
  25. require $dir.'Exception/UndefinedFunctionException.php';
  26. require $dir.'FatalErrorHandler/FatalErrorHandlerInterface.php';
  27. require $dir.'FatalErrorHandler/ClassNotFoundFatalErrorHandler.php';
  28. require $dir.'FatalErrorHandler/UndefinedFunctionFatalErrorHandler.php';
  29. require $dir.'FatalErrorHandler/UndefinedMethodFatalErrorHandler.php';
  30. function bar()
  31. {
  32. foo();
  33. }
  34. function foo()
  35. {
  36. notexist();
  37. }
  38. $handler = ErrorHandler::register();
  39. $handler->setExceptionHandler('print_r');
  40. if (\function_exists('xdebug_disable')) {
  41. xdebug_disable();
  42. }
  43. bar();
  44. ?>
  45. --EXPECTF--
  46. Fatal error: Call to undefined function Symfony\Component\Debug\notexist() in %s on line %d
  47. Symfony\Component\Debug\Exception\UndefinedFunctionException Object
  48. (
  49. [message:protected] => Attempted to call function "notexist" from namespace "Symfony\Component\Debug".
  50. [string:Exception:private] =>
  51. [code:protected] => 0
  52. [file:protected] => %s
  53. [line:protected] => %d
  54. [trace:Exception:private] => Array
  55. (
  56. [0] => Array
  57. (
  58. %A [function] => Symfony\Component\Debug\foo
  59. %A [args] => Array
  60. (
  61. )
  62. )
  63. [1] => Array
  64. (
  65. %A [function] => Symfony\Component\Debug\bar
  66. %A [args] => Array
  67. (
  68. )
  69. )
  70. %A
  71. )
  72. [previous:Exception:private] =>
  73. [severity:protected] => 1
  74. )