Skip to content

Commit

Permalink
feat: add repeat iteration as function argument if no extra dataset i…
Browse files Browse the repository at this point in the history
…s provided
  • Loading branch information
Katalam committed Oct 5, 2023
1 parent 8c0b933 commit 3ee5c29
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Concerns/Testable.php
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ private function __resolveTestArguments(array $arguments): array
{
$method = TestSuite::getInstance()->tests->get(self::$__filename)->getMethod($this->name());

if ($method->repetitions > 1) {
if ($method->repetitions > 1 && $method->datasets !== []) {
array_shift($arguments);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Factories/TestCaseMethodFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public function getClosure(TestCase $concrete): Closure
*/
public function receivesArguments(): bool
{
return $this->datasets !== [] || $this->depends !== [];
return $this->datasets !== [] || $this->depends !== [] || $this->repetitions > 1;
}

/**
Expand Down
4 changes: 4 additions & 0 deletions tests/Features/Repeat.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,7 @@
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);

0 comments on commit 3ee5c29

Please sign in to comment.