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

This commit is contained in:
2026-03-09 13:00:30 +00:00
committed by Boris Waaub
parent b7e8eec067
commit 0a8d650d95
16 changed files with 78 additions and 41 deletions

View File

@@ -240,6 +240,7 @@ class LoadPeople extends AbstractFixture implements ContainerAwareInterface, Ord
protected UserRepository $userRepository,
protected GenderRepository $genderRepository,
) {
mt_srand(123456789);
$this->faker = Factory::create('fr_FR');
$this->faker->addProvider($this);
$this->loader = new NativeLoader($this->faker);
@@ -273,7 +274,7 @@ class LoadPeople extends AbstractFixture implements ContainerAwareInterface, Ord
$this->cacheCountries = $this->countryRepository->findAll();
}
if (\random_int(0, 100) > $nullPercentage) {
if (\mt_rand(0, 100) > $nullPercentage) {
return null;
}
@@ -289,7 +290,7 @@ class LoadPeople extends AbstractFixture implements ContainerAwareInterface, Ord
$this->cacheGenders = $this->genderRepository->findByActiveOrdered();
}
if (\random_int(0, 100) > $nullPercentage) {
if (\mt_rand(0, 100) > $nullPercentage) {
return null;
}
@@ -307,7 +308,7 @@ class LoadPeople extends AbstractFixture implements ContainerAwareInterface, Ord
$this->cacheMaritalStatuses = $this->maritalStatusRepository->findAll();
}
if (\random_int(0, 100) > $nullPercentage) {
if (\mt_rand(0, 100) > $nullPercentage) {
return null;
}
@@ -352,7 +353,7 @@ class LoadPeople extends AbstractFixture implements ContainerAwareInterface, Ord
$accompanyingPeriod = new AccompanyingPeriod(
(new \DateTime())
->sub(
new \DateInterval('P'.\random_int(0, 180).'D')
new \DateInterval('P'.\mt_rand(0, 180).'D')
)
);
$accompanyingPeriod->setCreatedBy($this->getRandomUser())
@@ -360,7 +361,7 @@ class LoadPeople extends AbstractFixture implements ContainerAwareInterface, Ord
$person->addAccompanyingPeriod($accompanyingPeriod);
$accompanyingPeriod->addSocialIssue($this->getRandomSocialIssue());
if (\random_int(0, 10) > 3) {
if (\mt_rand(0, 10) > 3) {
// always add social scope:
$accompanyingPeriod->addScope($this->getReference('scope_social', Scope::class));
$origin = $this->getReference(LoadAccompanyingPeriodOrigin::ACCOMPANYING_PERIOD_ORIGIN, AccompanyingPeriod\Origin::class);