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

[Bridge\PhpUnit] Turn "preserveGlobalState" to false by default, revert "Blacklist" removal #25097

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
Nov 22, 2017
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
52 changes: 0 additions & 52 deletions 52 src/Symfony/Bridge/PhpUnit/Blacklist.php

This file was deleted.

21 changes: 18 additions & 3 deletions 21 src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use PHPUnit\Framework\AssertionFailedError;
use PHPUnit\Framework\TestCase;
use PHPUnit\Framework\TestSuite;
use PHPUnit\Util\Blacklist;
use Symfony\Bridge\PhpUnit\ClockMock;
use Symfony\Bridge\PhpUnit\DnsMock;

Expand Down Expand Up @@ -45,6 +46,14 @@ class SymfonyTestsListenerTrait
*/
public function __construct(array $mockedNamespaces = array())
{
if (class_exists('PHPUnit_Util_Blacklist')) {
\PHPUnit_Util_Blacklist::$blacklistedClassNames['\Symfony\Bridge\PhpUnit\SymfonyTestsListener'] = 1;
\PHPUnit_Util_Blacklist::$blacklistedClassNames['\Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListener'] = 1;
} else {
Blacklist::$blacklistedClassNames['\Symfony\Bridge\PhpUnit\SymfonyTestsListener'] = 1;
Blacklist::$blacklistedClassNames['\Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListener'] = 1;
}

$warn = false;
foreach ($mockedNamespaces as $type => $namespaces) {
if (!is_array($namespaces)) {
Expand Down Expand Up @@ -91,7 +100,7 @@ public function globalListenerDisabled()

public function startTestSuite($suite)
{
if (class_exists('PHPUnit_Util_Test', false)) {
if (class_exists('PHPUnit_Util_Blacklist', false)) {
$Test = 'PHPUnit_Util_Test';
} else {
$Test = 'PHPUnit\Util\Test';
Expand Down Expand Up @@ -134,6 +143,10 @@ public function startTestSuite($suite)
if (in_array('dns-sensitive', $groups, true)) {
DnsMock::register($test->getName());
}
} elseif (!($test instanceof \PHPUnit_Framework_TestCase || $test instanceof TestCase)) {
// no-op
} elseif (null === $Test::getPreserveGlobalStateSettings(get_class($test), $test->getName(false))) {
$test->setPreserveGlobalState(false);
}
}
}
Expand All @@ -144,6 +157,8 @@ public function startTestSuite($suite)
|| isset($this->wasSkipped[$suiteName]['*'])
|| isset($this->wasSkipped[$suiteName][$test->getName()])) {
$skipped[] = $test;
} elseif (null === $Test::getPreserveGlobalStateSettings(get_class($test), $test->getName(false))) {
$test->setPreserveGlobalState(false);
}
}
$suite->setTests($skipped);
Expand Down Expand Up @@ -178,7 +193,7 @@ public function startTest($test)
putenv('SYMFONY_DEPRECATIONS_SERIALIZE='.$this->runsInSeparateProcess);
}

if (class_exists('PHPUnit_Util_Test', false)) {
if (class_exists('PHPUnit_Util_Blacklist', false)) {
$Test = 'PHPUnit_Util_Test';
$AssertionFailedError = 'PHPUnit_Framework_AssertionFailedError';
} else {
Expand Down Expand Up @@ -224,7 +239,7 @@ public function addWarning($test, $e, $time)

public function endTest($test, $time)
{
if (class_exists('PHPUnit_Util_Test', false)) {
if (class_exists('PHPUnit_Util_Blacklist', false)) {
$Test = 'PHPUnit_Util_Test';
$BaseTestRunner = 'PHPUnit_Runner_BaseTestRunner';
$Warning = 'PHPUnit_Framework_Warning';
Expand Down
14 changes: 14 additions & 0 deletions 14 src/Symfony/Bridge/PhpUnit/bin/simple-phpunit
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,17 @@ if (!file_exists("$PHPUNIT_DIR/phpunit-$PHPUNIT_VERSION/phpunit") || md5_file(__
define('PHPUNIT_COMPOSER_INSTALL', __DIR__.'/vendor/autoload.php');
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();

EOPHP
Expand Down Expand Up @@ -200,6 +211,9 @@ if ($components) {
}
}
} 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'));
$_SERVER['argv'] = $argv;
$_SERVER['argc'] = ++$argc;
Expand Down
5 changes: 0 additions & 5 deletions 5 src/Symfony/Bridge/PhpUnit/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@
use Doctrine\Common\Annotations\AnnotationRegistry;
use Symfony\Bridge\PhpUnit\DeprecationErrorHandler;

// Replace the native phpunit Blacklist, it's a broken artifact from the past
if (!class_exists('Symfony\Bridge\PhpUnit\Blacklist', false)) {
require_once __DIR__.'/Blacklist.php';
}

// Detect if we need to serialize deprecations to a file.
if ($file = getenv('SYMFONY_DEPRECATIONS_SERIALIZE')) {
DeprecationErrorHandler::collectDeprecations($file);
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.