CommandForV5.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. namespace Symfony\Bridge\PhpUnit\Legacy;
  11. /**
  12. * {@inheritdoc}
  13. *
  14. * @internal
  15. */
  16. class CommandForV5 extends \PHPUnit_TextUI_Command
  17. {
  18. /**
  19. * {@inheritdoc}
  20. */
  21. protected function createRunner()
  22. {
  23. $this->arguments['listeners'] = isset($this->arguments['listeners']) ? $this->arguments['listeners'] : [];
  24. $registeredLocally = false;
  25. foreach ($this->arguments['listeners'] as $registeredListener) {
  26. if ($registeredListener instanceof SymfonyTestsListenerForV5) {
  27. $registeredListener->globalListenerDisabled();
  28. $registeredLocally = true;
  29. break;
  30. }
  31. }
  32. if (isset($this->arguments['configuration'])) {
  33. $configuration = $this->arguments['configuration'];
  34. if (!$configuration instanceof \PHPUnit_Util_Configuration) {
  35. $configuration = \PHPUnit_Util_Configuration::getInstance($this->arguments['configuration']);
  36. }
  37. foreach ($configuration->getListenerConfiguration() as $registeredListener) {
  38. if ('Symfony\Bridge\PhpUnit\SymfonyTestsListener' === ltrim($registeredListener['class'], '\\')) {
  39. $registeredLocally = true;
  40. break;
  41. }
  42. }
  43. }
  44. if (!$registeredLocally) {
  45. $this->arguments['listeners'][] = new SymfonyTestsListenerForV5();
  46. }
  47. return parent::createRunner();
  48. }
  49. }