[Bridge\PhpUnit] Disable broken auto-require mechanism of phpunit
This commit is contained in:
parent
3b6c22e86a
commit
0577d20ade
41
src/Symfony/Bridge/PhpUnit/Blacklist.php
Normal file
41
src/Symfony/Bridge/PhpUnit/Blacklist.php
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
<?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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Utility class replacing PHPUnit's implementation of the same class.
|
||||||
|
*
|
||||||
|
* All files are blacklisted so that process-isolated tests don't start with broken
|
||||||
|
* "require_once" statements. Composer is the only supported way to load code there.
|
||||||
|
*/
|
||||||
|
class Blacklist
|
||||||
|
{
|
||||||
|
public static $blacklistedClassNames = array();
|
||||||
|
|
||||||
|
public function getBlacklistedDirectories()
|
||||||
|
{
|
||||||
|
$root = dirname(__DIR__);
|
||||||
|
while ($root !== $parent = dirname($root)) {
|
||||||
|
$root = $parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
return array($root);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isBlacklisted($file)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class_alias('Symfony\Bridge\PhpUnit\Blacklist', 'PHPUnit\Util\Blacklist');
|
||||||
|
class_alias('Symfony\Bridge\PhpUnit\Blacklist', 'PHPUnit_Util_Blacklist');
|
@ -15,7 +15,6 @@ use Doctrine\Common\Annotations\AnnotationRegistry;
|
|||||||
use PHPUnit\Framework\AssertionFailedError;
|
use PHPUnit\Framework\AssertionFailedError;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use PHPUnit\Framework\TestSuite;
|
use PHPUnit\Framework\TestSuite;
|
||||||
use PHPUnit\Util\Blacklist;
|
|
||||||
use Symfony\Bridge\PhpUnit\ClockMock;
|
use Symfony\Bridge\PhpUnit\ClockMock;
|
||||||
use Symfony\Bridge\PhpUnit\DnsMock;
|
use Symfony\Bridge\PhpUnit\DnsMock;
|
||||||
|
|
||||||
@ -46,17 +45,6 @@ class SymfonyTestsListenerTrait
|
|||||||
*/
|
*/
|
||||||
public function __construct(array $mockedNamespaces = array())
|
public function __construct(array $mockedNamespaces = array())
|
||||||
{
|
{
|
||||||
if (class_exists('PHPUnit_Util_Blacklist')) {
|
|
||||||
\PHPUnit_Util_Blacklist::$blacklistedClassNames['\Symfony\Bridge\PhpUnit\DeprecationErrorHandler'] = 1;
|
|
||||||
\PHPUnit_Util_Blacklist::$blacklistedClassNames['\Symfony\Bridge\PhpUnit\SymfonyTestsListener'] = 1;
|
|
||||||
\PHPUnit_Util_Blacklist::$blacklistedClassNames['\Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListener'] = 1;
|
|
||||||
\PHPUnit_Util_Blacklist::$blacklistedClassNames['\Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerTrait'] = 1;
|
|
||||||
} else {
|
|
||||||
Blacklist::$blacklistedClassNames['\Symfony\Bridge\PhpUnit\DeprecationErrorHandler'] = 1;
|
|
||||||
Blacklist::$blacklistedClassNames['\Symfony\Bridge\PhpUnit\SymfonyTestsListener'] = 1;
|
|
||||||
Blacklist::$blacklistedClassNames['\Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerTrait'] = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
$warn = false;
|
$warn = false;
|
||||||
foreach ($mockedNamespaces as $type => $namespaces) {
|
foreach ($mockedNamespaces as $type => $namespaces) {
|
||||||
if (!is_array($namespaces)) {
|
if (!is_array($namespaces)) {
|
||||||
@ -103,7 +91,7 @@ class SymfonyTestsListenerTrait
|
|||||||
|
|
||||||
public function startTestSuite($suite)
|
public function startTestSuite($suite)
|
||||||
{
|
{
|
||||||
if (class_exists('PHPUnit_Util_Blacklist', false)) {
|
if (class_exists('PHPUnit_Util_Test', false)) {
|
||||||
$Test = 'PHPUnit_Util_Test';
|
$Test = 'PHPUnit_Util_Test';
|
||||||
} else {
|
} else {
|
||||||
$Test = 'PHPUnit\Util\Test';
|
$Test = 'PHPUnit\Util\Test';
|
||||||
@ -190,7 +178,7 @@ class SymfonyTestsListenerTrait
|
|||||||
putenv('SYMFONY_DEPRECATIONS_SERIALIZE='.$this->runsInSeparateProcess);
|
putenv('SYMFONY_DEPRECATIONS_SERIALIZE='.$this->runsInSeparateProcess);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (class_exists('PHPUnit_Util_Blacklist', false)) {
|
if (class_exists('PHPUnit_Util_Test', false)) {
|
||||||
$Test = 'PHPUnit_Util_Test';
|
$Test = 'PHPUnit_Util_Test';
|
||||||
$AssertionFailedError = 'PHPUnit_Framework_AssertionFailedError';
|
$AssertionFailedError = 'PHPUnit_Framework_AssertionFailedError';
|
||||||
} else {
|
} else {
|
||||||
@ -236,7 +224,7 @@ class SymfonyTestsListenerTrait
|
|||||||
|
|
||||||
public function endTest($test, $time)
|
public function endTest($test, $time)
|
||||||
{
|
{
|
||||||
if (class_exists('PHPUnit_Util_Blacklist', false)) {
|
if (class_exists('PHPUnit_Util_Test', false)) {
|
||||||
$Test = 'PHPUnit_Util_Test';
|
$Test = 'PHPUnit_Util_Test';
|
||||||
$BaseTestRunner = 'PHPUnit_Runner_BaseTestRunner';
|
$BaseTestRunner = 'PHPUnit_Runner_BaseTestRunner';
|
||||||
$Warning = 'PHPUnit_Framework_Warning';
|
$Warning = 'PHPUnit_Framework_Warning';
|
||||||
|
@ -82,17 +82,6 @@ if (!file_exists("$PHPUNIT_DIR/phpunit-$PHPUNIT_VERSION/phpunit") || md5_file(__
|
|||||||
define('PHPUNIT_COMPOSER_INSTALL', __DIR__.'/vendor/autoload.php');
|
define('PHPUNIT_COMPOSER_INSTALL', __DIR__.'/vendor/autoload.php');
|
||||||
require PHPUNIT_COMPOSER_INSTALL;
|
require PHPUNIT_COMPOSER_INSTALL;
|
||||||
|
|
||||||
if (!class_exists('SymfonyBlacklistPhpunit', false)) {
|
|
||||||
class SymfonyBlacklistPhpunit {}
|
|
||||||
}
|
|
||||||
if (class_exists('PHPUnit_Util_Blacklist')) {
|
|
||||||
PHPUnit_Util_Blacklist::$blacklistedClassNames['SymfonyBlacklistPhpunit'] = 1;
|
|
||||||
PHPUnit_Util_Blacklist::$blacklistedClassNames['SymfonyBlacklistSimplePhpunit'] = 1;
|
|
||||||
} else {
|
|
||||||
PHPUnit\Util\Blacklist::$blacklistedClassNames['SymfonyBlacklistPhpunit'] = 1;
|
|
||||||
PHPUnit\Util\Blacklist::$blacklistedClassNames['SymfonyBlacklistSimplePhpunit'] = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
Symfony\Bridge\PhpUnit\TextUI\Command::main();
|
Symfony\Bridge\PhpUnit\TextUI\Command::main();
|
||||||
|
|
||||||
EOPHP
|
EOPHP
|
||||||
@ -211,9 +200,6 @@ if ($components) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} elseif (!isset($argv[1]) || 'install' !== $argv[1] || file_exists('install')) {
|
} elseif (!isset($argv[1]) || 'install' !== $argv[1] || file_exists('install')) {
|
||||||
if (!class_exists('SymfonyBlacklistSimplePhpunit', false)) {
|
|
||||||
class SymfonyBlacklistSimplePhpunit {}
|
|
||||||
}
|
|
||||||
array_splice($argv, 1, 0, array('--colors=always'));
|
array_splice($argv, 1, 0, array('--colors=always'));
|
||||||
$_SERVER['argv'] = $argv;
|
$_SERVER['argv'] = $argv;
|
||||||
$_SERVER['argc'] = ++$argc;
|
$_SERVER['argc'] = ++$argc;
|
||||||
|
@ -12,6 +12,9 @@
|
|||||||
use Doctrine\Common\Annotations\AnnotationRegistry;
|
use Doctrine\Common\Annotations\AnnotationRegistry;
|
||||||
use Symfony\Bridge\PhpUnit\DeprecationErrorHandler;
|
use Symfony\Bridge\PhpUnit\DeprecationErrorHandler;
|
||||||
|
|
||||||
|
// Replace the native phpunit Blacklist, it's a broken artifact from the past
|
||||||
|
require_once __DIR__.'/Blacklist.php';
|
||||||
|
|
||||||
// Detect if we need to serialize deprecations to a file.
|
// Detect if we need to serialize deprecations to a file.
|
||||||
if ($file = getenv('SYMFONY_DEPRECATIONS_SERIALIZE')) {
|
if ($file = getenv('SYMFONY_DEPRECATIONS_SERIALIZE')) {
|
||||||
DeprecationErrorHandler::collectDeprecations($file);
|
DeprecationErrorHandler::collectDeprecations($file);
|
||||||
|
Reference in New Issue
Block a user