Skip to content

Commit f566bfb

Browse files
committed
Add an implementation just for php 7.0
php 7 does not have the void return type.
1 parent f87bc56 commit f566bfb

File tree

3 files changed

+53
-2
lines changed

3 files changed

+53
-2
lines changed

Legacy/TestRunnerForV6.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class TestRunnerForV6 extends BaseRunner
2424
/**
2525
* {@inheritdoc}
2626
*/
27-
protected function handleConfiguration(array &$arguments): void
27+
protected function handleConfiguration(array &$arguments)
2828
{
2929
$listener = new SymfonyTestsListener();
3030

Legacy/TestRunnerForV7.php

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Bridge\PhpUnit\Legacy;
13+
14+
use PHPUnit\TextUI\TestRunner as BaseRunner;
15+
use Symfony\Bridge\PhpUnit\SymfonyTestsListener;
16+
17+
/**
18+
* {@inheritdoc}
19+
*
20+
* @internal
21+
*/
22+
class TestRunnerForV7 extends BaseRunner
23+
{
24+
/**
25+
* {@inheritdoc}
26+
*/
27+
protected function handleConfiguration(array &$arguments): void
28+
{
29+
$listener = new SymfonyTestsListener();
30+
31+
parent::handleConfiguration($arguments);
32+
33+
$arguments['listeners'] = isset($arguments['listeners']) ? $arguments['listeners'] : array();
34+
35+
$registeredLocally = false;
36+
37+
foreach ($arguments['listeners'] as $registeredListener) {
38+
if ($registeredListener instanceof SymfonyTestsListener) {
39+
$registeredListener->globalListenerDisabled();
40+
$registeredLocally = true;
41+
break;
42+
}
43+
}
44+
45+
if (!$registeredLocally) {
46+
$arguments['listeners'][] = $listener;
47+
}
48+
}
49+
}

TextUI/TestRunner.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@
1313

1414
if (class_exists('PHPUnit_Runner_Version') && version_compare(\PHPUnit_Runner_Version::id(), '6.0.0', '<')) {
1515
class_alias('Symfony\Bridge\PhpUnit\Legacy\TestRunnerForV5', 'Symfony\Bridge\PhpUnit\TextUI\TestRunner');
16-
} else {
16+
} elseif (class_exists('PHPUnit_Runner_Version') && version_compare(\PHPUnit_Runner_Version::id(), '7.0.0', '<')) {
1717
class_alias('Symfony\Bridge\PhpUnit\Legacy\TestRunnerForV6', 'Symfony\Bridge\PhpUnit\TextUI\TestRunner');
18+
} else {
19+
class_alias('Symfony\Bridge\PhpUnit\Legacy\TestRunnerForV7', 'Symfony\Bridge\PhpUnit\TextUI\TestRunner');
1820
}
1921

2022
if (false) {

0 commit comments

Comments
 (0)