diff --git a/src/Framework/TestCase.php b/src/Framework/TestCase.php index 8a714c02eb2..df0dbbb0b7f 100644 --- a/src/Framework/TestCase.php +++ b/src/Framework/TestCase.php @@ -1176,10 +1176,10 @@ final protected function registerFailureType(string $classOrInterface): void */ final protected function runTest(): mixed { - $testArguments = array_merge($this->data, $this->dependencyInput); + $testArguments = array_merge($this->data, array_values($this->dependencyInput)); try { - $testResult = $this->{$this->name}(...array_values($testArguments)); + $testResult = $this->{$this->name}(...$testArguments); } catch (Throwable $exception) { if (!$this->shouldExceptionExpectationsBeVerified($exception)) { throw $exception; diff --git a/tests/_files/DataProviderNamedArgumentsTest.php b/tests/_files/DataProviderNamedArgumentsTest.php new file mode 100644 index 00000000000..57780c9d17a --- /dev/null +++ b/tests/_files/DataProviderNamedArgumentsTest.php @@ -0,0 +1,30 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +namespace PHPUnit\TestFixture; + +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\TestCase; + +class DataProviderNamedArgumentsTest extends TestCase +{ + public static function providerMethod() + { + return [ + ['a' => 1, 'b' => 2, 'c' => 3], + ['c' => 3, 'a' => 2, 'b' => 1], + ]; + } + + #[DataProvider('providerMethod')] + public function testAdd($a, $b, $c): void + { + $this->assertEquals($c, $a + $b); + } +} diff --git a/tests/end-to-end/generic/dataprovider-named-arguments.phpt b/tests/end-to-end/generic/dataprovider-named-arguments.phpt new file mode 100644 index 00000000000..8f14acebce7 --- /dev/null +++ b/tests/end-to-end/generic/dataprovider-named-arguments.phpt @@ -0,0 +1,20 @@ +--TEST-- +phpunit ../../_files/DataProviderNamedArgumentsTest.php +--FILE-- +run($_SERVER['argv']); +--EXPECTF-- +PHPUnit %s by Sebastian Bergmann and contributors. + +Runtime: %s + +.. 2 / 2 (100%) + +Time: %s, Memory: %s + +OK (2 tests, 2 assertions)