mirror of
https://github.com/pestphp/pest.git
synced 2026-09-05 14:23:34 +02:00
Fix repeat with named dataset arguments (#1769)
This commit is contained in:
@@ -408,16 +408,25 @@ trait Testable
|
||||
private function __resolveTestArguments(array $arguments): array
|
||||
{
|
||||
$method = TestSuite::getInstance()->tests->get(self::$__filename)->getMethod($this->name());
|
||||
|
||||
if ($method->repetitions > 1) {
|
||||
$firstArgument = array_shift($arguments);
|
||||
$arguments[] = $firstArgument;
|
||||
}
|
||||
|
||||
$underlyingTest = Reflection::getFunctionVariable($this->__test, 'closure');
|
||||
$testParameterTypesByName = Reflection::getFunctionArguments($underlyingTest);
|
||||
$testParameterTypes = array_values($testParameterTypesByName);
|
||||
|
||||
if ($method->repetitions > 1) {
|
||||
$firstArgument = array_shift($arguments);
|
||||
|
||||
if (array_is_list($arguments)) {
|
||||
$arguments[] = $firstArgument;
|
||||
} else {
|
||||
$testParameterNames = array_keys($testParameterTypesByName);
|
||||
$iterationParameterName = $testParameterNames[count($arguments)] ?? null;
|
||||
|
||||
if ($iterationParameterName !== null) {
|
||||
$arguments[$iterationParameterName] = $firstArgument;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (count($arguments) !== 1) {
|
||||
foreach ($arguments as $argumentIndex => $argumentValue) {
|
||||
if (! $argumentValue instanceof Closure) {
|
||||
|
||||
Reference in New Issue
Block a user