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'], +]);