Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[PhpBridge] add PHPUnit 7 support to SymfonyTestsListener #26024

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

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
57 changes: 57 additions & 0 deletions 57 src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerPhpunit6.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?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\Framework\BaseTestListener;
use PHPUnit\Framework\Test;
use PHPUnit\Framework\TestSuite;
use PHPUnit\Framework\Warning;

class SymfonyTestsListenerPhpunit6 extends BaseTestListener
{
private $trait;

public function __construct(array $mockedNamespaces = array())
{
$this->trait = new SymfonyTestsListenerTrait($mockedNamespaces);
}

public function globalListenerDisabled()
{
$this->trait->globalListenerDisabled();
}

public function startTestSuite(TestSuite $suite)
{
$this->trait->startTestSuite($suite);
}

public function addSkippedTest(Test $test, \Exception $e, $time)
{
$this->trait->addSkippedTest($test, $e, $time);
}

public function startTest(Test $test)
{
$this->trait->startTest($test);
}

public function addWarning(Test $test, Warning $e, $time)
{
$this->trait->addWarning($test, $e, $time);
}

public function endTest(Test $test, $time)
{
$this->trait->endTest($test, $time);
}
}
33 changes: 19 additions & 14 deletions 33 src/Symfony/Bridge/PhpUnit/SymfonyTestsListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,18 @@

namespace Symfony\Bridge\PhpUnit;

use PHPUnit\Framework\BaseTestListener;
use PHPUnit\Framework\Test;
use PHPUnit\Framework\TestListener;
use PHPUnit\Framework\TestListenerDefaultImplementation;
use PHPUnit\Framework\TestSuite;
use PHPUnit\Framework\Warning;

if (class_exists('PHPUnit_Runner_Version') && version_compare(\PHPUnit_Runner_Version::id(), '6.0.0', '<')) {
class_alias('Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListener', 'Symfony\Bridge\PhpUnit\SymfonyTestsListener');
// Using an early return instead of a else does not work when using the PHPUnit phar due to some weird PHP behavior (the class
// gets defined without executing the code before it and so the definition is not properly conditional)
if (class_exists('PHPUnit_Runner_Version') && version_compare(\PHPUnit_Runner_Version::id(), '6.0.0', '<')) {
class_alias('Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListener', 'Symfony\Bridge\PhpUnit\SymfonyTestsListener');
} elseif (version_compare(\PHPUnit\Runner\Version::id(), '7.0.0', '<')) {
class_alias('Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerPhpunit6', 'Symfony\Bridge\PhpUnit\SymfonyTestsListener');
} else {
/**
* Collects and replays skipped tests.
Expand All @@ -28,8 +31,10 @@ class_alias('Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListener', 'Symfony\Bridg
*
* @final
*/
class SymfonyTestsListener extends BaseTestListener
class SymfonyTestsListener implements TestListener
{
use TestListenerDefaultImplementation;

private $trait;

public function __construct(array $mockedNamespaces = array())
Expand All @@ -42,29 +47,29 @@ public function globalListenerDisabled()
$this->trait->globalListenerDisabled();
}

public function startTestSuite(TestSuite $suite)
public function startTestSuite(TestSuite $suite): void
{
return $this->trait->startTestSuite($suite);
$this->trait->startTestSuite($suite);
}

public function addSkippedTest(Test $test, \Exception $e, $time)
public function addSkippedTest(Test $test, \Throwable $t, float $time): void
{
return $this->trait->addSkippedTest($test, $e, $time);
$this->trait->addSkippedTest($test, $t, $time);
}

public function startTest(Test $test)
public function startTest(Test $test): void
{
return $this->trait->startTest($test);
$this->trait->startTest($test);
}

public function addWarning(Test $test, Warning $e, $time)
public function addWarning(Test $test, Warning $e, float $time): void
{
return $this->trait->addWarning($test, $e, $time);
$this->trait->addWarning($test, $e, $time);
}

public function endTest(Test $test, $time)
public function endTest(Test $test, float $time): void
{
return $this->trait->endTest($test, $time);
$this->trait->endTest($test, $time);
}
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.