bootstrap.php 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. use Doctrine\Common\Annotations\AnnotationRegistry;
  11. use Symfony\Bridge\PhpUnit\DeprecationErrorHandler;
  12. if (class_exists(\PHPUnit_Runner_Version::class) && version_compare(\PHPUnit_Runner_Version::id(), '6.0.0', '<')) {
  13. $classes = [
  14. 'PHPUnit_Framework_Assert', // override PhpUnit's ForwardCompat child class
  15. 'PHPUnit_Framework_AssertionFailedError', // override PhpUnit's ForwardCompat child class
  16. 'PHPUnit_Framework_BaseTestListener', // override PhpUnit's ForwardCompat child class
  17. 'PHPUnit_Framework_Constraint',
  18. 'PHPUnit_Framework_Constraint_ArrayHasKey',
  19. 'PHPUnit_Framework_Constraint_ArraySubset',
  20. 'PHPUnit_Framework_Constraint_Attribute',
  21. 'PHPUnit_Framework_Constraint_Callback',
  22. 'PHPUnit_Framework_Constraint_ClassHasAttribute',
  23. 'PHPUnit_Framework_Constraint_ClassHasStaticAttribute',
  24. 'PHPUnit_Framework_Constraint_Composite',
  25. 'PHPUnit_Framework_Constraint_Count',
  26. 'PHPUnit_Framework_Constraint_Exception',
  27. 'PHPUnit_Framework_Constraint_ExceptionCode',
  28. 'PHPUnit_Framework_Constraint_ExceptionMessage',
  29. 'PHPUnit_Framework_Constraint_ExceptionMessageRegExp',
  30. 'PHPUnit_Framework_Constraint_FileExists',
  31. 'PHPUnit_Framework_Constraint_GreaterThan',
  32. 'PHPUnit_Framework_Constraint_IsAnything',
  33. 'PHPUnit_Framework_Constraint_IsEmpty',
  34. 'PHPUnit_Framework_Constraint_IsEqual',
  35. 'PHPUnit_Framework_Constraint_IsFalse',
  36. 'PHPUnit_Framework_Constraint_IsIdentical',
  37. 'PHPUnit_Framework_Constraint_IsInstanceOf',
  38. 'PHPUnit_Framework_Constraint_IsJson',
  39. 'PHPUnit_Framework_Constraint_IsNull',
  40. 'PHPUnit_Framework_Constraint_IsTrue',
  41. 'PHPUnit_Framework_Constraint_IsType',
  42. 'PHPUnit_Framework_Constraint_JsonMatches',
  43. 'PHPUnit_Framework_Constraint_JsonMatches_ErrorMessageProvider',
  44. 'PHPUnit_Framework_Constraint_LessThan',
  45. 'PHPUnit_Framework_Constraint_ObjectHasAttribute',
  46. 'PHPUnit_Framework_Constraint_PCREMatch',
  47. 'PHPUnit_Framework_Constraint_SameSize',
  48. 'PHPUnit_Framework_Constraint_StringContains',
  49. 'PHPUnit_Framework_Constraint_StringEndsWith',
  50. 'PHPUnit_Framework_Constraint_StringMatches',
  51. 'PHPUnit_Framework_Constraint_StringStartsWith',
  52. 'PHPUnit_Framework_Constraint_TraversableContains',
  53. 'PHPUnit_Framework_Constraint_TraversableContainsOnly',
  54. 'PHPUnit_Framework_Error_Deprecated',
  55. 'PHPUnit_Framework_Error_Notice',
  56. 'PHPUnit_Framework_Error_Warning',
  57. 'PHPUnit_Framework_Exception',
  58. 'PHPUnit_Framework_ExpectationFailedException',
  59. 'PHPUnit_Framework_MockObject_MockObject',
  60. 'PHPUnit_Framework_IncompleteTest',
  61. 'PHPUnit_Framework_IncompleteTestCase',
  62. 'PHPUnit_Framework_IncompleteTestError',
  63. 'PHPUnit_Framework_RiskyTest',
  64. 'PHPUnit_Framework_RiskyTestError',
  65. 'PHPUnit_Framework_SkippedTest',
  66. 'PHPUnit_Framework_SkippedTestCase',
  67. 'PHPUnit_Framework_SkippedTestError',
  68. 'PHPUnit_Framework_SkippedTestSuiteError',
  69. 'PHPUnit_Framework_SyntheticError',
  70. 'PHPUnit_Framework_Test',
  71. 'PHPUnit_Framework_TestCase', // override PhpUnit's ForwardCompat child class
  72. 'PHPUnit_Framework_TestFailure',
  73. 'PHPUnit_Framework_TestListener',
  74. 'PHPUnit_Framework_TestResult',
  75. 'PHPUnit_Framework_TestSuite', // override PhpUnit's ForwardCompat child class
  76. 'PHPUnit_Runner_BaseTestRunner',
  77. 'PHPUnit_Runner_Version',
  78. 'PHPUnit_Util_Blacklist',
  79. 'PHPUnit_Util_ErrorHandler',
  80. 'PHPUnit_Util_Test',
  81. 'PHPUnit_Util_XML',
  82. ];
  83. foreach ($classes as $class) {
  84. class_alias($class, '\\'.strtr($class, '_', '\\'));
  85. }
  86. class_alias('PHPUnit_Framework_Constraint_And', 'PHPUnit\Framework\Constraint\LogicalAnd');
  87. class_alias('PHPUnit_Framework_Constraint_Not', 'PHPUnit\Framework\Constraint\LogicalNot');
  88. class_alias('PHPUnit_Framework_Constraint_Or', 'PHPUnit\Framework\Constraint\LogicalOr');
  89. class_alias('PHPUnit_Framework_Constraint_Xor', 'PHPUnit\Framework\Constraint\LogicalXor');
  90. class_alias('PHPUnit_Framework_Error', 'PHPUnit\Framework\Error\Error');
  91. }
  92. // Detect if we need to serialize deprecations to a file.
  93. if ($file = getenv('SYMFONY_DEPRECATIONS_SERIALIZE')) {
  94. DeprecationErrorHandler::collectDeprecations($file);
  95. return;
  96. }
  97. // Detect if we're loaded by an actual run of phpunit
  98. if (!defined('PHPUNIT_COMPOSER_INSTALL') && !class_exists(\PHPUnit_TextUI_Command::class, false) && !class_exists(\PHPUnit\TextUI\Command::class, false)) {
  99. return;
  100. }
  101. // Enforce a consistent locale
  102. setlocale(\LC_ALL, 'C');
  103. if (!class_exists(AnnotationRegistry::class, false) && class_exists(AnnotationRegistry::class)) {
  104. if (method_exists(AnnotationRegistry::class, 'registerUniqueLoader')) {
  105. AnnotationRegistry::registerUniqueLoader('class_exists');
  106. } else {
  107. AnnotationRegistry::registerLoader('class_exists');
  108. }
  109. }
  110. if ('disabled' !== getenv('SYMFONY_DEPRECATIONS_HELPER')) {
  111. DeprecationErrorHandler::register(getenv('SYMFONY_DEPRECATIONS_HELPER'));
  112. }