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