mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2026-04-04 12:03:44 +00:00
Add seeds to data fixtures, to avoid random failures in tests
This commit is contained in:
@@ -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),
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user