Skip to content

Commit 73e14d1

Browse files
Merge branch '11.5' into 12.2
2 parents b71849b + df59e64 commit 73e14d1

File tree

5 files changed

+80
-0
lines changed

5 files changed

+80
-0
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.6] - 2025-MM-DD
6+
7+
### Fixed
8+
9+
* [#6104](https://github.com/sebastianbergmann/phpunit/issues/6104): Test with dependencies and data provider fails
10+
511
## [12.2.5] - 2025-06-27
612

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

97+
[12.2.6]: https://github.com/sebastianbergmann/phpunit/compare/12.2.5...12.2
9198
[12.2.5]: https://github.com/sebastianbergmann/phpunit/compare/12.2.4...12.2.5
9299
[12.2.4]: https://github.com/sebastianbergmann/phpunit/compare/12.2.3...12.2.4
93100
[12.2.3]: https://github.com/sebastianbergmann/phpunit/compare/12.2.2...12.2.3

src/Framework/TestCase.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1456,6 +1456,10 @@ private function handleDependencies(): bool
14561456
return true;
14571457
}
14581458

1459+
if (!$passedTests->hasReturnValue($dependencyTarget)) {
1460+
return true;
1461+
}
1462+
14591463
$returnValue = $passedTests->returnValue($dependencyTarget);
14601464

14611465
if ($dependency->deepClone()) {

src/Runner/TestResult/PassedTests.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,14 @@
1111

1212
use function array_merge;
1313
use function assert;
14+
use function explode;
1415
use function in_array;
1516
use PHPUnit\Event\Code\TestMethod;
1617
use PHPUnit\Framework\TestSize\Known;
1718
use PHPUnit\Framework\TestSize\TestSize;
1819
use PHPUnit\Metadata\Api\Groups;
20+
use ReflectionMethod;
21+
use ReflectionNamedType;
1922

2023
/**
2124
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
@@ -113,6 +116,13 @@ public function isGreaterThan(string $method, TestSize $other): bool
113116
return $size->isGreaterThan($other);
114117
}
115118

119+
public function hasReturnValue(string $method): mixed
120+
{
121+
$returnType = (new ReflectionMethod(...explode('::', $method)))->getReturnType();
122+
123+
return !$returnType instanceof ReflectionNamedType || !in_array($returnType->getName(), ['never', 'void'], true);
124+
}
125+
116126
public function returnValue(string $method): mixed
117127
{
118128
if (isset($this->passedTestMethods[$method])) {
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php declare(strict_types=1);
2+
/*
3+
* This file is part of PHPUnit.
4+
*
5+
* (c) Sebastian Bergmann <[email protected]>
6+
*
7+
* For the full copyright and license information, please view the LICENSE
8+
* file that was distributed with this source code.
9+
*/
10+
namespace PHPUnit\TestFixture;
11+
12+
use PHPUnit\Framework\Attributes\DataProvider;
13+
use PHPUnit\Framework\Attributes\Depends;
14+
use PHPUnit\Framework\TestCase;
15+
16+
final class DataProviderDependencyVoidTest extends TestCase
17+
{
18+
public static function provider(): iterable
19+
{
20+
return [
21+
[0, 0],
22+
[1, 'b' => 1],
23+
['a' => 2, 'b' => 2],
24+
['b' => 3, 'a' => 3],
25+
];
26+
}
27+
28+
#[DataProvider('provider')]
29+
#[Depends('testDependency')]
30+
public function testEquality($a, $b): void
31+
{
32+
$this->assertSame($a, $b);
33+
}
34+
35+
public function testDependency(): void
36+
{
37+
$this->assertTrue(true);
38+
}
39+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--TEST--
2+
phpunit ../../_files/DataProviderDependencyVoidTest.php
3+
--FILE--
4+
<?php declare(strict_types=1);
5+
$_SERVER['argv'][] = '--do-not-cache-result';
6+
$_SERVER['argv'][] = '--no-configuration';
7+
$_SERVER['argv'][] = __DIR__ . '/../../_files/DataProviderDependencyVoidTest.php';
8+
9+
require_once __DIR__ . '/../../bootstrap.php';
10+
(new PHPUnit\TextUI\Application)->run($_SERVER['argv']);
11+
--EXPECTF--
12+
PHPUnit %s by Sebastian Bergmann and contributors.
13+
14+
Runtime: %s
15+
16+
..... 5 / 5 (100%)
17+
18+
Time: %s, Memory: %s
19+
20+
OK (5 tests, 5 assertions)

0 commit comments

Comments
 (0)