bootstrap.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. require_once __DIR__ . '/../../../../app/autoload.php';
  7. if (!defined('TESTS_TEMP_DIR')) {
  8. define('TESTS_TEMP_DIR', dirname(__DIR__) . '/tmp');
  9. }
  10. require_once __DIR__ . '/autoload.php';
  11. setCustomErrorHandler();
  12. \Magento\Framework\Phrase::setRenderer(new \Magento\Framework\Phrase\Renderer\Placeholder());
  13. error_reporting(E_ALL);
  14. ini_set('display_errors', 1);
  15. /* For data consistency between displaying (printing) and serialization a float number */
  16. ini_set('precision', 14);
  17. ini_set('serialize_precision', 14);
  18. /**
  19. * Set custom error handler
  20. */
  21. function setCustomErrorHandler()
  22. {
  23. set_error_handler(
  24. function ($errNo, $errStr, $errFile, $errLine) {
  25. if (error_reporting()) {
  26. $errorNames = [
  27. E_ERROR => 'Error',
  28. E_WARNING => 'Warning',
  29. E_PARSE => 'Parse',
  30. E_NOTICE => 'Notice',
  31. E_CORE_ERROR => 'Core Error',
  32. E_CORE_WARNING => 'Core Warning',
  33. E_COMPILE_ERROR => 'Compile Error',
  34. E_COMPILE_WARNING => 'Compile Warning',
  35. E_USER_ERROR => 'User Error',
  36. E_USER_WARNING => 'User Warning',
  37. E_USER_NOTICE => 'User Notice',
  38. E_STRICT => 'Strict',
  39. E_RECOVERABLE_ERROR => 'Recoverable Error',
  40. E_DEPRECATED => 'Deprecated',
  41. E_USER_DEPRECATED => 'User Deprecated',
  42. ];
  43. $errName = isset($errorNames[$errNo]) ? $errorNames[$errNo] : "";
  44. throw new \PHPUnit\Framework\Exception(
  45. sprintf("%s: %s in %s:%s.", $errName, $errStr, $errFile, $errLine),
  46. $errNo
  47. );
  48. }
  49. }
  50. );
  51. }