Skip to content

Commit d7676aa

Browse files
committedNov 3, 2020
Merge branch '5.1' into 5.x
* 5.1: [PhpUnitBridge] fix replaying skipped tests Switch nightly run to 8.0snapshot
2 parents 8a17f92 + 15611a4 commit d7676aa

File tree

1 file changed

+17
-18
lines changed

1 file changed

+17
-18
lines changed
 

‎Legacy/SymfonyTestsListenerTrait.php

+17-18
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ public function startTestSuite($suite)
123123
$suiteName = $suite->getName();
124124

125125
foreach ($suite->tests() as $test) {
126-
if (!($test instanceof \PHPUnit\Framework\TestCase || $test instanceof TestCase)) {
126+
if (!($test instanceof \PHPUnit_Framework_TestCase || $test instanceof TestCase)) {
127127
continue;
128128
}
129129
if (null === Test::getPreserveGlobalStateSettings(\get_class($test), $test->getName(false))) {
@@ -158,7 +158,7 @@ public function startTestSuite($suite)
158158
$testSuites = [$suite];
159159
for ($i = 0; isset($testSuites[$i]); ++$i) {
160160
foreach ($testSuites[$i]->tests() as $test) {
161-
if ($test instanceof TestSuite) {
161+
if ($test instanceof \PHPUnit_Framework_TestSuite || $test instanceof TestSuite) {
162162
if (!class_exists($test->getName(), false)) {
163163
$testSuites[] = $test;
164164
continue;
@@ -174,12 +174,19 @@ public function startTestSuite($suite)
174174
}
175175
}
176176
} elseif (2 === $this->state) {
177+
$suites = [$suite];
177178
$skipped = [];
178-
foreach ($suite->tests() as $test) {
179-
if (!($test instanceof \PHPUnit\Framework\TestCase || $test instanceof TestCase)
180-
|| isset($this->wasSkipped[$suiteName]['*'])
181-
|| isset($this->wasSkipped[$suiteName][$test->getName()])) {
182-
$skipped[] = $test;
179+
while ($s = array_shift($suites)) {
180+
foreach ($s->tests() as $test) {
181+
if ($test instanceof \PHPUnit_Framework_TestSuite || $test instanceof TestSuite) {
182+
$suites[] = $test;
183+
continue
184+
}
185+
if (($test instanceof \PHPUnit_Framework_TestCase || $test instanceof TestCase)
186+
&& isset($this->wasSkipped[\get_class($test)][$test->getName()])
187+
) {
188+
$skipped[] = $test;
189+
}
183190
}
184191
}
185192
$suite->setTests($skipped);
@@ -189,21 +196,13 @@ public function startTestSuite($suite)
189196
public function addSkippedTest($test, \Exception $e, $time)
190197
{
191198
if (0 < $this->state) {
192-
if ($test instanceof \PHPUnit\Framework\TestCase || $test instanceof TestCase) {
193-
$class = \get_class($test);
194-
$method = $test->getName();
195-
} else {
196-
$class = $test->getName();
197-
$method = '*';
198-
}
199-
200-
$this->isSkipped[$class][$method] = 1;
199+
$this->isSkipped[\get_class($test)][$test->getName()] = 1;
201200
}
202201
}
203202

204203
public function startTest($test)
205204
{
206-
if (-2 < $this->state && ($test instanceof \PHPUnit\Framework\TestCase || $test instanceof TestCase)) {
205+
if (-2 < $this->state && ($test instanceof \PHPUnit_Framework_TestCase || $test instanceof TestCase)) {
207206
// This event is triggered before the test is re-run in isolation
208207
if ($this->willBeIsolated($test)) {
209208
$this->runsInSeparateProcess = tempnam(sys_get_temp_dir(), 'deprec');
@@ -313,7 +312,7 @@ public function endTest($test, $time)
313312
self::$expectedDeprecations = self::$gatheredDeprecations = [];
314313
self::$previousErrorHandler = null;
315314
}
316-
if (!$this->runsInSeparateProcess && -2 < $this->state && ($test instanceof \PHPUnit\Framework\TestCase || $test instanceof TestCase)) {
315+
if (!$this->runsInSeparateProcess && -2 < $this->state && ($test instanceof \PHPUnit_Framework_TestCase || $test instanceof TestCase)) {
317316
if (\in_array('time-sensitive', $groups, true)) {
318317
ClockMock::withClockMock(false);
319318
}

0 commit comments

Comments
 (0)
Please sign in to comment.