E601 [PhpUnitBridge] fix replaying skipped tests · symfony/symfony@849d1b3 · GitHub
[go: up one dir, main page]

Skip to content

Commit 849d1b3

Browse files
[PhpUnitBridge] fix replaying skipped tests
1 parent 13af58c commit 849d1b3

File tree

2 files changed

+29
-18
lines changed

2 files changed

+29
-18
lines changed

src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public function startTestSuite($suite)
121121
$suiteName = $suite->getName();
122122

123123
foreach ($suite->tests() as $test) {
124-
if (!($test instanceof \PHPUnit\Framework\TestCase || $test instanceof TestCase)) {
124+
if (!($test instanceof \PHPUnit_Framework_TestCase || $test instanceof TestCase)) {
125125
continue;
126126
}
127127
if (null === Test::getPreserveGlobalStateSettings(\get_class($test), $test->getName(false))) {
@@ -156,7 +156,7 @@ public function startTestSuite($suite)
156156
$testSuites = [$suite];
157157
for ($i = 0; isset($testSuites[$i]); ++$i) {
158158
foreach ($testSuites[$i]->tests() as $test) {
159-
if ($test instanceof TestSuite) {
159+
if ($test instanceof \PHPUnit_Framework_TestSuite || $test instanceof TestSuite) {
160160
if (!class_exists($test->getName(), false)) {
161161
$testSuites[] = $test;
162162
continue;
@@ -172,12 +172,19 @@ public function startTestSuite($suite)
172172
}
173173
}
174174
} elseif (2 === $this->state) {
175+
$suites = [$suite];
175176
$skipped = [];
176-
foreach ($suite->tests() as $test) {
177-
if (!($test instanceof \PHPUnit\Framework\TestCase || $test instanceof TestCase)
178-
|| isset($this->wasSkipped[$suiteName]['*'])
179-
|| isset($this->wasSkipped[$suiteName][$test->getName()])) {
180-
$skipped[] = $test;
177+
while ($s = array_shift($suites)) {
178+
foreach ($s->tests() as $test) {
179+
if ($test instanceof \PHPUnit_Framework_TestSuite || $test instanceof TestSuite) {
180+
$suites[] = $test;
181+
continue
182+
}
183+
if (($test instanceof \PHPUnit_Framework_TestCase || $test instanceof TestCase)
184+
&& isset($this->wasSkipped[\get_class($test)][$test->getName()])
185+
) {
186+
$skipped[] = $test;
187+
}
181188
}
182189
}
183190
$suite->setTests($skipped);
@@ -187,21 +194,13 @@ public function startTestSuite($suite)
187194
public function addSkippedTest($test, \Exception $e, $time)
188195
{
189196
if (0 < $this->state) {
190-
if ($test instanceof \PHPUnit\Framework\TestCase || $test instanceof TestCase) {
191-
$class = \get_class($test);
192-
$method = $test->getName();
193-
} else {
194-
$class = $test->getName();
195-
$method = '*';
196-
}
197-
198-
$this->isSkipped[$class][$method] = 1;
197+
$this->isSkipped[\get_class($test)][$test->getName()] = 1;
199198
}
200199
}
201200

202201
public function startTest($test)
203202
{
204-
if (-2 < $this->state && ($test instanceof \PHPUnit\Framework\TestCase || $test instanceof TestCase)) {
203+
if (-2 < $this->state && ($test instanceof \PHPUnit_Framework_TestCase || $test instanceof TestCase)) {
205204
// This event is triggered before the test is re-run in isolation
206205
if ($this->willBeIsolated($test)) {
207206
$this->runsInSeparateProcess = tempnam(sys_get_temp_dir(), 'deprec');
@@ -291,7 +290,7 @@ public function endTest($test, $time)
291290
$this->expectedDeprecations = $this->gatheredDeprecations = [];
292291
$this->previousErrorHandler = null;
293292
}
294-
if (!$this->runsInSeparateProcess && -2 < $this->state && ($test instanceof \PHPUnit\Framework\TestCase || $test instanceof TestCase)) {
293+
if (!$this->runsInSeparateProcess && -2 < $this->state && ($test instanceof \PHPUnit_Framework_TestCase || $test instanceof TestCase)) {
295294
if (\in_array('time-sensitive', $groups, true)) {
296295
ClockMock::withClockMock(false);
297296
}

src/Symfony/Component/Intl/Tests/DateFormatter/Verification/IntlDateFormatterTest.php

Lines changed: 12 additions & 0 deletions
< A19A col width="40"/>
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,18 @@ protected function setUp(): void
3030
parent::setUp();
3131
}
3232

33+
/**
34+
* @dataProvider formatProvider
35+
*/
36+
public function testFormat($pattern, $timestamp, $expected)
37+
{
38+
if (\PHP_VERSION_ID < 70105 && $timestamp instanceof \DateTimeImmutable) {
39+
$this->markTestSkipped('PHP >= 7.1.5 required for DateTimeImmutable.');
40+
}
41+
42+
parent::testFormat($pattern, $timestamp, $expected);
43+
}
44+
3345
/**
3446
* @dataProvider formatTimezoneProvider
3547
*/

0 commit comments

Comments
 (0)
0