Skip to content

Commit

Permalink
Fix generator unique test
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-doehring committed Oct 16, 2022
1 parent f1e63e1 commit 879bc37
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions test/Faker/GeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -274,13 +274,14 @@ public function word(): string

$uniqueGenerator = $generator->unique();

$generatedWords = [
$uniqueGenerator->word(),
$uniqueGenerator->word(),
$uniqueGenerator->word(),
];

self::assertEquals($words, $generatedWords);
$remainingWords = $words;
// ensure that all words are found only once
for ($i = 0; $i < count($words); $i++) {
$word = $uniqueGenerator->word();
$foundKey = array_search($word, $remainingWords);
self::assertNotFalse($foundKey);
unset($remainingWords[$foundKey]);
}
}

public function testUniqueReturnsUniqueGeneratorThatThrowsWhenItCanNotGenerateUniqueValuesAnymore(): void
Expand Down

0 comments on commit 879bc37

Please sign in to comment.