Skip to content

Commit 1c051ad

Browse files
kubawerlossebastianbergmann
authored andcommitted
Fix saving information about passed tests
1 parent ccb1e3d commit 1c051ad

File tree

2 files changed

+15
-23
lines changed

2 files changed

+15
-23
lines changed

src/Runner/TestResult/Collector.php

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,10 @@
5454
final class Collector
5555
{
5656
private readonly IssueFilter $issueFilter;
57-
private int $numberOfTests = 0;
58-
private int $numberOfTestsRun = 0;
59-
private int $numberOfAssertions = 0;
60-
private bool $prepared = false;
61-
private bool $currentTestSuiteForTestClassFailed = false;
57+
private int $numberOfTests = 0;
58+
private int $numberOfTestsRun = 0;
59+
private int $numberOfAssertions = 0;
60+
private bool $prepared = false;
6261

6362
/**
6463
* @var non-negative-int
@@ -243,16 +242,10 @@ public function testSuiteStarted(TestSuiteStarted $event): void
243242
if (!$testSuite->isForTestClass()) {
244243
return;
245244
}
246-
247-
$this->currentTestSuiteForTestClassFailed = false;
248245
}
249246

250247
public function testSuiteFinished(TestSuiteFinished $event): void
251248
{
252-
if ($this->currentTestSuiteForTestClassFailed) {
253-
return;
254-
}
255-
256249
$testSuite = $event->testSuite();
257250

258251
if ($testSuite->isWithName()) {
@@ -266,6 +259,12 @@ public function testSuiteFinished(TestSuiteFinished $event): void
266259

267260
assert($test instanceof TestMethod);
268261

262+
foreach ($this->testFailedEvents as $testFailedEvent) {
263+
if ($testFailedEvent->test()->isTestMethod() && $testFailedEvent->test()->methodName() === $test->methodName()) {
264+
return;
265+
}
266+
}
267+
269268
PassedTests::instance()->testMethodPassed($test, null);
270269

271270
return;
@@ -306,8 +305,6 @@ public function testErrored(Errored $event): void
306305
{
307306
$this->testErroredEvents[] = $event;
308307

309-
$this->currentTestSuiteForTestClassFailed = true;
310-
311308
/*
312309
* @todo Eliminate this special case
313310
*/
@@ -323,8 +320,6 @@ public function testErrored(Errored $event): void
323320
public function testFailed(Failed $event): void
324321
{
325322
$this->testFailedEvents[] = $event;
326-
327-
$this->currentTestSuiteForTestClassFailed = true;
328323
}
329324

330325
public function testMarkedIncomplete(MarkedIncomplete $event): void

tests/end-to-end/regression/6222.phpt

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ PHPUnit %s by Sebastian Bergmann and contributors.
1515

1616
Runtime: %s
1717

18-
F..S.FSFFS 10 / 10 (100%)
18+
F....FSFFS 10 / 10 (100%)
1919

2020
Time: %s, Memory: %s
2121

@@ -43,16 +43,13 @@ Failed asserting that 2 is identical to 3.
4343

4444
--
4545

46-
There were 3 skipped tests:
46+
There were 2 skipped tests:
4747

48-
1) PHPUnit\TestFixture\Issue6222\Issue6222Test::testDependingOnTwoCasesPassing
49-
This test depends on "PHPUnit\TestFixture\Issue6222\Issue6222Test::testTwoCasesPassing" to pass
50-
51-
2) PHPUnit\TestFixture\Issue6222\Issue6222Test::testDependingOnOneCasePassing
48+
1) PHPUnit\TestFixture\Issue6222\Issue6222Test::testDependingOnOneCasePassing
5249
This test depends on "PHPUnit\TestFixture\Issue6222\Issue6222Test::testOneCasePassing" to pass
5350

54-
3) PHPUnit\TestFixture\Issue6222\Issue6222Test::testDependingOnZeroCasesPassing
51+
2) PHPUnit\TestFixture\Issue6222\Issue6222Test::testDependingOnZeroCasesPassing
5552
This test depends on "PHPUnit\TestFixture\Issue6222\Issue6222Test::testZeroCasesPassing" to pass
5653

5754
FAILURES!
58-
Tests: 10, Assertions: 7, Failures: 4, Skipped: 3.
55+
Tests: 10, Assertions: 8, Failures: 4, Skipped: 2.

0 commit comments

Comments
 (0)