From 3223d50607fbde52fef5c1a8c2dae268efaa29e8 Mon Sep 17 00:00:00 2001 From: nuno maduro Date: Mon, 3 Aug 2026 16:47:34 -0400 Subject: [PATCH] fix dataset key --- src/Factories/TestCaseMethodFactory.php | 4 ++-- tests/Features/DatasetsTests.php | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Factories/TestCaseMethodFactory.php b/src/Factories/TestCaseMethodFactory.php index 5151a917..9f573c7e 100644 --- a/src/Factories/TestCaseMethodFactory.php +++ b/src/Factories/TestCaseMethodFactory.php @@ -235,8 +235,8 @@ final class TestCaseMethodFactory $attributesCode public function $methodName(...\$arguments) { - if (count(\$arguments) === 1 && \$arguments[0] instanceof __PestDatasetProviderError) { - throw \$arguments[0]->getPrevious() ?? \$arguments[0]; + if (count(\$arguments) === 1 && \$arguments[array_key_first(\$arguments)] instanceof __PestDatasetProviderError) { + throw \$arguments[array_key_first(\$arguments)]->getPrevious() ?? \$arguments[array_key_first(\$arguments)]; } return \$this->__runTest( diff --git a/tests/Features/DatasetsTests.php b/tests/Features/DatasetsTests.php index 99682015..e46cb3ea 100644 --- a/tests/Features/DatasetsTests.php +++ b/tests/Features/DatasetsTests.php @@ -542,3 +542,9 @@ test('dataset items can mix named and sequential styles', function (string $name ['James', 'james@laravel.com'], ['James', 'email' => 'james@laravel.com'], ]); + +test('named parameters work with a single argument', function (string $name) { + expect($name)->toBe('Taylor'); +})->with([ + ['name' => 'Taylor'], +]);