mirror of
https://github.com/pestphp/pest.git
synced 2026-03-07 00:07:22 +01:00
feat: add repeat iteration as function argument if no extra dataset is provided
This commit is contained in:
@ -262,7 +262,7 @@ trait Testable
|
|||||||
{
|
{
|
||||||
$method = TestSuite::getInstance()->tests->get(self::$__filename)->getMethod($this->name());
|
$method = TestSuite::getInstance()->tests->get(self::$__filename)->getMethod($this->name());
|
||||||
|
|
||||||
if ($method->repetitions > 1) {
|
if ($method->repetitions > 1 && $method->datasets !== []) {
|
||||||
array_shift($arguments);
|
array_shift($arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -116,7 +116,7 @@ final class TestCaseMethodFactory
|
|||||||
*/
|
*/
|
||||||
public function receivesArguments(): bool
|
public function receivesArguments(): bool
|
||||||
{
|
{
|
||||||
return $this->datasets !== [] || $this->depends !== [];
|
return $this->datasets !== [] || $this->depends !== [] || $this->repetitions > 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -16,3 +16,7 @@ test('multiple times with multiple dataset', function (int $numberA, int $number
|
|||||||
expect([1, 2, 3])->toContain($numberA)
|
expect([1, 2, 3])->toContain($numberA)
|
||||||
->and([4, 5, 6])->toContain($numberB);
|
->and([4, 5, 6])->toContain($numberB);
|
||||||
})->repeat(times: 7)->with(['a' => 1, 'b' => 2, 'c' => 3], [4, 5, 6]);
|
})->repeat(times: 7)->with(['a' => 1, 'b' => 2, 'c' => 3], [4, 5, 6]);
|
||||||
|
|
||||||
|
test('multiple times with iterator as argument', function (int $iteration) {
|
||||||
|
expect($iteration)->toBeGreaterThan(0);
|
||||||
|
})->repeat(times: 8);
|
||||||
|
|||||||
Reference in New Issue
Block a user