Add seeds to data fixtures, to avoid random failures in tests

This commit is contained in:
2026-03-09 13:00:30 +00:00
parent e2dec28577
commit a921009eff
16 changed files with 78 additions and 41 deletions

View File

@@ -37,7 +37,9 @@ class LoadCustomFields extends AbstractFixture implements OrderedFixtureInterfac
private readonly EntityManagerInterface $entityManager,
private readonly CustomFieldChoice $customFieldChoice,
private readonly CustomFieldText $customFieldText,
) {}
) {
mt_srand(123456789);
}
// put your code here
public function getOrder(): int
@@ -78,12 +80,12 @@ class LoadCustomFields extends AbstractFixture implements OrderedFixtureInterfac
// select a set of people and add data
foreach ($personIds as $id) {
// add info on 1 person on 2
if (1 === random_int(0, 1)) {
if (1 === mt_rand(0, 1)) {
/** @var Person $person */
$person = $manager->getRepository(Person::class)->find($id);
$person->setCFData([
'remarques' => $this->createCustomFieldText()
->serialize($faker->text(random_int(150, 250)), $this->cfText),
->serialize($faker->text(mt_rand(150, 250)), $this->cfText),
'document-d-identite' => $this->createCustomFieldChoice()
->serialize([$choices[array_rand($choices)]], $this->cfChoice),
]);