feat: add repeat iteration as function argument if no extra dataset is provided

This commit is contained in:
Katalam
2023-10-05 23:07:03 +02:00
parent 8c0b933fcd
commit 3ee5c29a00
3 changed files with 6 additions and 2 deletions

View File

@ -262,7 +262,7 @@ trait Testable
{
$method = TestSuite::getInstance()->tests->get(self::$__filename)->getMethod($this->name());
if ($method->repetitions > 1) {
if ($method->repetitions > 1 && $method->datasets !== []) {
array_shift($arguments);
}

View File

@ -116,7 +116,7 @@ final class TestCaseMethodFactory
*/
public function receivesArguments(): bool
{
return $this->datasets !== [] || $this->depends !== [];
return $this->datasets !== [] || $this->depends !== [] || $this->repetitions > 1;
}
/**

View File

@ -16,3 +16,7 @@ test('multiple times with multiple dataset', function (int $numberA, int $number
expect([1, 2, 3])->toContain($numberA)
->and([4, 5, 6])->toContain($numberB);
})->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);