Skip to content

Commit

Permalink
Merge branch '5.1' into 5.x
Browse files Browse the repository at this point in the history
* 5.1:
  [PhpUnitBridge] fix replaying skipped tests
  Switch nightly run to 8.0snapshot
  • Loading branch information
nicolas-grekas committed Nov 3, 2020
2 parents 8a17f92 + 15611a4 commit d7676aa
Showing 1 changed file with 17 additions and 18 deletions.
35 changes: 17 additions & 18 deletions Legacy/SymfonyTestsListenerTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public function startTestSuite($suite)
$suiteName = $suite->getName();

foreach ($suite->tests() as $test) {
if (!($test instanceof \PHPUnit\Framework\TestCase || $test instanceof TestCase)) {
if (!($test instanceof \PHPUnit_Framework_TestCase || $test instanceof TestCase)) {
continue;
}
if (null === Test::getPreserveGlobalStateSettings(\get_class($test), $test->getName(false))) {
Expand Down Expand Up @@ -158,7 +158,7 @@ public function startTestSuite($suite)
$testSuites = [$suite];
for ($i = 0; isset($testSuites[$i]); ++$i) {
foreach ($testSuites[$i]->tests() as $test) {
if ($test instanceof TestSuite) {
if ($test instanceof \PHPUnit_Framework_TestSuite || $test instanceof TestSuite) {
if (!class_exists($test->getName(), false)) {
$testSuites[] = $test;
continue;
Expand All @@ -174,12 +174,19 @@ public function startTestSuite($suite)
}
}
} elseif (2 === $this->state) {
$suites = [$suite];
$skipped = [];
foreach ($suite->tests() as $test) {
if (!($test instanceof \PHPUnit\Framework\TestCase || $test instanceof TestCase)
|| isset($this->wasSkipped[$suiteName]['*'])
|| isset($this->wasSkipped[$suiteName][$test->getName()])) {
$skipped[] = $test;
while ($s = array_shift($suites)) {
foreach ($s->tests() as $test) {
if ($test instanceof \PHPUnit_Framework_TestSuite || $test instanceof TestSuite) {
$suites[] = $test;
continue
}
if (($test instanceof \PHPUnit_Framework_TestCase || $test instanceof TestCase)
&& isset($this->wasSkipped[\get_class($test)][$test->getName()])
) {
$skipped[] = $test;
}
}
}
$suite->setTests($skipped);
Expand All @@ -189,21 +196,13 @@ public function startTestSuite($suite)
public function addSkippedTest($test, \Exception $e, $time)
{
if (0 < $this->state) {
if ($test instanceof \PHPUnit\Framework\TestCase || $test instanceof TestCase) {
$class = \get_class($test);
$method = $test->getName();
} else {
$class = $test->getName();
$method = '*';
}

$this->isSkipped[$class][$method] = 1;
$this->isSkipped[\get_class($test)][$test->getName()] = 1;
}
}

public function startTest($test)
{
if (-2 < $this->state && ($test instanceof \PHPUnit\Framework\TestCase || $test instanceof TestCase)) {
if (-2 < $this->state && ($test instanceof \PHPUnit_Framework_TestCase || $test instanceof TestCase)) {
// This event is triggered before the test is re-run in isolation
if ($this->willBeIsolated($test)) {
$this->runsInSeparateProcess = tempnam(sys_get_temp_dir(), 'deprec');
Expand Down Expand Up @@ -313,7 +312,7 @@ public function endTest($test, $time)
self::$expectedDeprecations = self::$gatheredDeprecations = [];
self::$previousErrorHandler = null;
}
if (!$this->runsInSeparateProcess && -2 < $this->state && ($test instanceof \PHPUnit\Framework\TestCase || $test instanceof TestCase)) {
if (!$this->runsInSeparateProcess && -2 < $this->state && ($test instanceof \PHPUnit_Framework_TestCase || $test instanceof TestCase)) {
if (\in_array('time-sensitive', $groups, true)) {
ClockMock::withClockMock(false);
}
Expand Down

0 comments on commit d7676aa

Please sign in to comment.