Skip to content

[PHPUnitBridge] Add an implementation just for php 7.0 #27086

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Symfony/Bridge/PhpUnit/Legacy/TestRunnerForV6.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class TestRunnerForV6 extends BaseRunner
/**
* {@inheritdoc}
*/
protected function handleConfiguration(array &$arguments): void
protected function handleConfiguration(array &$arguments)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The existing runner looses its void return type, but keeps the code changes (doesn't return anything, extends from PHPUnit\TextUI\TestRunner)

{
$listener = new SymfonyTestsListener();

Expand Down
49 changes: 49 additions & 0 deletions src/Symfony/Bridge/PhpUnit/Legacy/TestRunnerForV7.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Bridge\PhpUnit\Legacy;

use PHPUnit\TextUI\TestRunner as BaseRunner;
use Symfony\Bridge\PhpUnit\SymfonyTestsListener;

/**
* {@inheritdoc}
*
* @internal
*/
class TestRunnerForV7 extends BaseRunner
Copy link
Contributor Author

@greg0ire greg0ire Apr 29, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is the former TestRunnerForV6, renamed

{
/**
* {@inheritdoc}
*/
protected function handleConfiguration(array &$arguments): void
{
$listener = new SymfonyTestsListener();

parent::handleConfiguration($arguments);

$arguments['listeners'] = isset($arguments['listeners']) ? $arguments['listeners'] : array();

$registeredLocally = false;

foreach ($arguments['listeners'] as $registeredListener) {
if ($registeredListener instanceof SymfonyTestsListener) {
$registeredListener->globalListenerDisabled();
$registeredLocally = true;
break;
}
}

if (!$registeredLocally) {
$arguments['listeners'][] = $listener;
}
}
}
4 changes: 3 additions & 1 deletion src/Symfony/Bridge/PhpUnit/TextUI/TestRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@

if (class_exists('PHPUnit_Runner_Version') && version_compare(\PHPUnit_Runner_Version::id(), '6.0.0', '<')) {
class_alias('Symfony\Bridge\PhpUnit\Legacy\TestRunnerForV5', 'Symfony\Bridge\PhpUnit\TextUI\TestRunner');
} else {
} elseif (class_exists('PHPUnit_Runner_Version') && version_compare(\PHPUnit_Runner_Version::id(), '7.0.0', '<')) {
class_alias('Symfony\Bridge\PhpUnit\Legacy\TestRunnerForV6', 'Symfony\Bridge\PhpUnit\TextUI\TestRunner');
} else {
class_alias('Symfony\Bridge\PhpUnit\Legacy\TestRunnerForV7', 'Symfony\Bridge\PhpUnit\TextUI\TestRunner');
}

if (false) {
Expand Down