[Bridge/PhpUnit] Fix disabling global state preservation

This commit is contained in:
Nicolas Grekas 2017-11-22 10:23:05 +01:00
parent e64b8d341c
commit fe328345d7
2 changed files with 10 additions and 7 deletions

View File

@ -106,6 +106,15 @@ class SymfonyTestsListenerTrait
$suiteName = $suite->getName();
$this->testsWithWarnings = array();
foreach ($suite->tests() as $test) {
if (!($test instanceof \PHPUnit_Framework_TestCase || $test instanceof TestCase)) {
continue;
}
if (null === $Test::getPreserveGlobalStateSettings(get_class($test), $test->getName(false))) {
$test->setPreserveGlobalState(false);
}
}
if (-1 === $this->state) {
echo "Testing $suiteName\n";
$this->state = 0;
@ -141,10 +150,6 @@ class SymfonyTestsListenerTrait
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);
}
}
}
@ -155,8 +160,6 @@ class SymfonyTestsListenerTrait
|| 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);

View File

@ -11,7 +11,7 @@
*/
// Please update when phpunit needs to be reinstalled with fresh deps:
// Cache-Id-Version: 2017-11-22 09:00 UTC
// Cache-Id-Version: 2017-11-22 09:30 UTC
error_reporting(-1);