Skip to content

[PHPUnitBridge] Cross compatibility between PHPUnit 5 and 6 #21221

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 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?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\Compat\Framework;

if (class_exists('PHPUnit\Framework\AssertionFailedError')) {
/**
* Class AssertionFailedError
* @package Symfony\Bridge\PhpUnit\Compat\Framework
* @internal
*/
class AssertionFailedError extends \PHPUnit\Framework\AssertionFailedError
{}
} else {
/**
* Class AssertionFailedError
* @package Symfony\Bridge\PhpUnit\Compat\Framework
* @internal
*/
class AssertionFailedError extends \PHPUnit_Framework_AssertionFailedError
{}
}
30 changes: 30 additions & 0 deletions src/Symfony/Bridge/PhpUnit/Compat/Framework/BaseTestListener.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?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\Compat\Framework;

if (class_exists('PHPUnit\Framework\BaseTestListener')) {
/**
* Class BaseTestListener
* @package Symfony\Bridge\PhpUnit\Compat\Framework
* @internal
*/
abstract class BaseTestListener extends \PHPUnit\Framework\BaseTestListener
{}
} else {
/**
* Class BaseTestListener
* @package Symfony\Bridge\PhpUnit\Compat\Framework
* @internal
*/
abstract class BaseTestListener extends \PHPUnit_Framework_BaseTestListener
{}
}
30 changes: 30 additions & 0 deletions src/Symfony/Bridge/PhpUnit/Compat/Framework/TestCase.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?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\Compat\Framework;

if (class_exists('PHPUnit\Framework\TestCase')) {
/**
* Class TestCase
* @package Symfony\Bridge\PhpUnit\Compat\Framework
* @internal
*/
class TestCase extends \PHPUnit\Framework\TestCase
{}
} else {
/**
* Class TestCase
* @package Symfony\Bridge\PhpUnit\Compat\Framework
* @internal
*/
class TestCase extends \PHPUnit_Framework_TestCase
{}
}
30 changes: 30 additions & 0 deletions src/Symfony/Bridge/PhpUnit/Compat/Framework/Warning.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?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\Compat\Framework;

if (class_exists('PHPUnit\Framework\Warning')) {
/**
* Class Warning
* @package Symfony\Bridge\PhpUnit\Compat\Framework
* @internal
*/
class Warning extends \PHPUnit\Framework\Warning
{}
} else {
/**
* Class Warning
* @package Symfony\Bridge\PhpUnit\Compat\Framework
* @internal
*/
class Warning extends \PHPUnit_Framework_Warning
{}
}
30 changes: 30 additions & 0 deletions src/Symfony/Bridge/PhpUnit/Compat/Runner/BaseTestRunner.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?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\Compat\Runner;

if (class_exists('PHPUnit\Runner\BaseTestRunner')) {
/**
* Class BaseTestRunner
* @package Symfony\Bridge\PhpUnit\Compat\Runner
* @internal
*/
abstract class BaseTestRunner extends \PHPUnit\Runner\BaseTestRunner
{}
} else {
/**
* Class BaseTestRunner
* @package Symfony\Bridge\PhpUnit\Compat\Runner
* @internal
*/
abstract class BaseTestRunner extends \PHPUnit_Runner_BaseTestRunner
{}
}
30 changes: 30 additions & 0 deletions src/Symfony/Bridge/PhpUnit/Compat/TextUI/Command.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?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\Compat\TextUI;

if (class_exists('PHPUnit\TextUI\Command')) {
/**
* Class Command
* @package Symfony\Bridge\PhpUnit\Compat\TextUI
* @internal
*/
class Command extends \PHPUnit\TextUI\Command
{}
} else {
/**
* Class Command
* @package Symfony\Bridge\PhpUnit\Compat\TextUI
* @internal
*/
class Command extends \PHPUnit_TextUI_Command
{}
}
30 changes: 30 additions & 0 deletions src/Symfony/Bridge/PhpUnit/Compat/TextUI/TestRunner.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?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\Compat\TextUI;

if (class_exists('PHPUnit\TextUI\TestRunner')) {
/**
* Class TestRunner
* @package Symfony\Bridge\PhpUnit\Compat\TextUI
* @internal
*/
class TestRunner extends \PHPUnit\TextUI\TestRunner
{}
} else {
/**
* Class TestRunner
* @package Symfony\Bridge\PhpUnit\Compat\TextUI
* @internal
*/
class TestRunner extends \PHPUnit_TextUI_TestRunner
{}
}
30 changes: 30 additions & 0 deletions src/Symfony/Bridge/PhpUnit/Compat/Util/Blacklist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?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\Compat\Util;

if (class_exists('PHPUnit\Util\Blacklist')) {
/**
* Class Blacklist
* @package Symfony\Bridge\PhpUnit\Compat\Util
* @internal
*/
class Blacklist extends \PHPUnit\Util\Blacklist
{}
} else {
/**
* Class Blacklist
* @package Symfony\Bridge\PhpUnit\Compat\Util
* @internal
*/
class Blacklist extends \PHPUnit_Util_Blacklist
{}
}
30 changes: 30 additions & 0 deletions src/Symfony/Bridge/PhpUnit/Compat/Util/ErrorHandler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?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\Compat\Util;

if (class_exists('PHPUnit\Util\ErrorHandler')) {
/**
* Class ErrorHandler
* @package Symfony\Bridge\PhpUnit\Compat\Util
* @internal
*/
class ErrorHandler extends \PHPUnit\Util\ErrorHandler
{}
} else {
/**
* Class ErrorHandler
* @package Symfony\Bridge\PhpUnit\Compat\Util
* @internal
*/
class ErrorHandler extends \PHPUnit_Util_ErrorHandler
{}
}
30 changes: 30 additions & 0 deletions src/Symfony/Bridge/PhpUnit/Compat/Util/Test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?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\Compat\Util;

if (class_exists('PHPUnit\Util\Test')) {
/**
* Class Test
* @package Symfony\Bridge\PhpUnit\Compat\Util
* @internal
*/
class Test extends \PHPUnit\Util\Test
{}
} else {
/**
* Class Test
* @package Symfony\Bridge\PhpUnit\Compat\Util
* @internal
*/
class Test extends \PHPUnit_Util_Test
{}
}
11 changes: 7 additions & 4 deletions src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@

namespace Symfony\Bridge\PhpUnit;

use Symfony\Bridge\PhpUnit\Compat\Util\ErrorHandler;
use Symfony\Bridge\PhpUnit\Compat\Util\Test;

/**
* Catch deprecation notices and print a summary report at the end of the test suite.
*
Expand Down Expand Up @@ -70,14 +73,14 @@ public static function register($mode = 0)
$deprecationHandler = function ($type, $msg, $file, $line, $context) use (&$deprecations, $getMode) {
$mode = $getMode();
if ((E_USER_DEPRECATED !== $type && E_DEPRECATED !== $type) || DeprecationErrorHandler::MODE_DISABLED === $mode) {
return \PHPUnit_Util_ErrorHandler::handleError($type, $msg, $file, $line, $context);
return ErrorHandler::handleError($type, $msg, $file, $line, $context);
}

$trace = debug_backtrace(true);
$group = 'other';

$i = count($trace);
while (1 < $i && (!isset($trace[--$i]['class']) || ('ReflectionMethod' === $trace[$i]['class'] || 0 === strpos($trace[$i]['class'], 'PHPUnit_')))) {
while (1 < $i && (!isset($trace[--$i]['class']) || ('ReflectionMethod' === $trace[$i]['class'] || 0 === strpos($trace[$i]['class'], 'PHPUnit_') || 0 === strpos($trace[$i]['class'], 'PHPUnit\\')))) {
// No-op
}

Expand All @@ -91,7 +94,7 @@ public static function register($mode = 0)
|| 0 === strpos($method, 'provideLegacy')
|| 0 === strpos($method, 'getLegacy')
|| strpos($class, '\Legacy')
|| in_array('legacy', \PHPUnit_Util_Test::getGroups($class, $method), true)
|| in_array('legacy', Test::getGroups($class, $method), true)
) {
$group = 'legacy';
} else {
Expand Down Expand Up @@ -128,7 +131,7 @@ public static function register($mode = 0)

if (null !== $oldErrorHandler) {
restore_error_handler();
if (array('PHPUnit_Util_ErrorHandler', 'handleError') === $oldErrorHandler) {
if (array('PHPUnit_Util_ErrorHandler', 'handleError') === $oldErrorHandler || array('PHPUnit\Util\ErrorHandler', 'handleError') === $oldErrorHandler) {
restore_error_handler();
self::register($mode);
}
Expand Down
Loading