Skip to content

Commit cd83cfa

Browse files
Merge branch '11.5' into 12.2
2 parents f6d1235 + be3a590 commit cd83cfa

File tree

4 files changed

+139
-15
lines changed

4 files changed

+139
-15
lines changed

ChangeLog-12.2.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
All notable changes of the PHPUnit 12.2 release series are documented in this file using the [Keep a CHANGELOG](https://keepachangelog.com/) principles.
44

5+
## [12.2.2] - 2025-MM-DD
6+
7+
### Fixed
8+
9+
* [#6222](https://github.com/sebastianbergmann/phpunit/issues/6222): Data Provider seems to mess up Test Dependencies
10+
511
## [12.2.1] - 2025-06-07
612

713
### Fixed
@@ -53,5 +59,6 @@ This feature is experimental and the generated XML may change to enhance complia
5359
* A warning is now emitted when more than one of `#[Small]`, `#[Medium]`, or `#[Large]` is used on a test class
5460
* A warning is now emitted when a data provider provides data sets that have more values than the test method consumes using arguments
5561

62+
[12.2.2]: https://github.com/sebastianbergmann/phpunit/compare/12.2.1...12.2
5663
[12.2.1]: https://github.com/sebastianbergmann/phpunit/compare/12.2.0...12.2.1
5764
[12.2.0]: https://github.com/sebastianbergmann/phpunit/compare/12.1.6...12.2.0

src/Runner/TestResult/Collector.php

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,10 @@
5757
final class Collector
5858
{
5959
private readonly IssueFilter $issueFilter;
60-
private int $numberOfTests = 0;
61-
private int $numberOfTestsRun = 0;
62-
private int $numberOfAssertions = 0;
63-
private bool $prepared = false;
64-
private bool $currentTestSuiteForTestClassFailed = false;
60+
private int $numberOfTests = 0;
61+
private int $numberOfTestsRun = 0;
62+
private int $numberOfAssertions = 0;
63+
private bool $prepared = false;
6564

6665
/**
6766
* @var non-negative-int
@@ -258,16 +257,10 @@ public function testSuiteStarted(TestSuiteStarted $event): void
258257
if (!$testSuite->isForTestClass()) {
259258
return;
260259
}
261-
262-
$this->currentTestSuiteForTestClassFailed = false;
263260
}
264261

265262
public function testSuiteFinished(TestSuiteFinished $event): void
266263
{
267-
if ($this->currentTestSuiteForTestClassFailed) {
268-
return;
269-
}
270-
271264
$testSuite = $event->testSuite();
272265

273266
if ($testSuite->isWithName()) {
@@ -282,6 +275,12 @@ public function testSuiteFinished(TestSuiteFinished $event): void
282275

283276
assert($test instanceof TestMethod);
284277

278+
foreach ($this->testFailedEvents as $testFailedEvent) {
279+
if ($testFailedEvent->test()->isTestMethod() && $testFailedEvent->test()->methodName() === $test->methodName()) {
280+
return;
281+
}
282+
}
283+
285284
PassedTests::instance()->testMethodPassed($test, null);
286285

287286
return;
@@ -334,8 +333,6 @@ public function testErrored(Errored $event): void
334333
{
335334
$this->testErroredEvents[] = $event;
336335

337-
$this->currentTestSuiteForTestClassFailed = true;
338-
339336
/*
340337
* @todo Eliminate this special case
341338
*/
@@ -351,8 +348,6 @@ public function testErrored(Errored $event): void
351348
public function testFailed(Failed $event): void
352349
{
353350
$this->testFailedEvents[] = $event;
354-
355-
$this->currentTestSuiteForTestClassFailed = true;
356351
}
357352

358353
public function testMarkedIncomplete(MarkedIncomplete $event): void
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
--TEST--
2+
https://github.com/sebastianbergmann/phpunit/issues/6222
3+
--FILE--
4+
<?php declare(strict_types=1);
5+
$_SERVER['argv'][] = '--do-not-cache-result';
6+
$_SERVER['argv'][] = '--no-configuration';
7+
$_SERVER['argv'][] = '--display-skipped';
8+
$_SERVER['argv'][] = __DIR__ . '/6222/Issue6222Test.php';
9+
10+
require_once __DIR__ . '/../../bootstrap.php';
11+
12+
(new PHPUnit\TextUI\Application)->run($_SERVER['argv']);
13+
--EXPECTF--
14+
PHPUnit %s by Sebastian Bergmann and contributors.
15+
16+
Runtime: %s
17+
18+
F....FSFFS 10 / 10 (100%)
19+
20+
Time: %s, Memory: %s
21+
22+
There were 4 failures:
23+
24+
1) PHPUnit\TestFixture\Issue6222\Issue6222Test::testOne
25+
Failed asserting that false is true.
26+
27+
%sIssue6222Test.php:%d
28+
29+
2) PHPUnit\TestFixture\Issue6222\Issue6222Test::testOneCasePassing with data set #1 (2)
30+
Failed asserting that 2 is identical to 1.
31+
32+
%sIssue6222Test.php:%d
33+
34+
3) PHPUnit\TestFixture\Issue6222\Issue6222Test::testZeroCasesPassing with data set #0 (1)
35+
Failed asserting that 1 is identical to 3.
36+
37+
%sIssue6222Test.php:%d
38+
39+
4) PHPUnit\TestFixture\Issue6222\Issue6222Test::testZeroCasesPassing with data set #1 (2)
40+
Failed asserting that 2 is identical to 3.
41+
42+
%sIssue6222Test.php:%d
43+
44+
--
45+
46+
There were 2 skipped tests:
47+
48+
1) PHPUnit\TestFixture\Issue6222\Issue6222Test::testDependingOnOneCasePassing
49+
This test depends on "PHPUnit\TestFixture\Issue6222\Issue6222Test::testOneCasePassing" to pass
50+
51+
2) PHPUnit\TestFixture\Issue6222\Issue6222Test::testDependingOnZeroCasesPassing
52+
This test depends on "PHPUnit\TestFixture\Issue6222\Issue6222Test::testZeroCasesPassing" to pass
53+
54+
FAILURES!
55+
Tests: 10, Assertions: 8, Failures: 4, Skipped: 2.
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
/*
5+
* This file is part of PHPUnit.
6+
*
7+
* (c) Sebastian Bergmann <[email protected]>
8+
*
9+
* For the full copyright and license information, please view the LICENSE
10+
* file that was distributed with this source code.
11+
*/
12+
namespace PHPUnit\TestFixture\Issue6222;
13+
14+
use PHPUnit\Framework\Attributes\DataProvider;
15+
use PHPUnit\Framework\Attributes\Depends;
16+
use PHPUnit\Framework\TestCase;
17+
18+
class Issue6222Test extends TestCase
19+
{
20+
public static function provider(): iterable
21+
{
22+
yield [1];
23+
24+
yield [2];
25+
}
26+
27+
public function testOne(): void
28+
{
29+
$this->assertTrue(false);
30+
}
31+
32+
#[DataProvider('provider')]
33+
public function testTwoCasesPassing(int $x): void
34+
{
35+
$this->assertGreaterThan(0, $x);
36+
}
37+
38+
#[Depends('testTwoCasesPassing')]
39+
public function testDependingOnTwoCasesPassing(): void
40+
{
41+
$this->assertTrue(true);
42+
}
43+
44+
#[DataProvider('provider')]
45+
public function testOneCasePassing(int $x): void
46+
{
47+
$this->assertSame(1, $x);
48+
}
49+
50+
#[Depends('testOneCasePassing')]
51+
public function testDependingOnOneCasePassing(): void
52+
{
53+
$this->assertTrue(true);
54+
}
55+
56+
#[DataProvider('provider')]
57+
public function testZeroCasesPassing(int $x): void
58+
{
59+
$this->assertSame(3, $x);
60+
}
61+
62+
#[Depends('testZeroCasesPassing')]
63+
public function testDependingOnZeroCasesPassing(): void
64+
{
65+
$this->assertTrue(true);
66+
}
67+
}

0 commit comments

Comments
 (0)