Add second parameter to add-, get-, hasReference() methods in fixture classes

This commit is contained in:
2024-11-28 12:44:14 +01:00
parent 0ac49d1fde
commit 19e6ceba28
27 changed files with 61 additions and 59 deletions

View File

@@ -64,9 +64,9 @@ class LoadAccompanyingPeriodWork extends \Doctrine\Bundle\FixturesBundle\Fixture
->setStartDate(new \DateTimeImmutable('today'))
->addPerson($period->getPersons()->first())
->setCreatedAt(new \DateTimeImmutable())
->setCreatedBy($this->getReference('center a_social'))
->setCreatedBy($this->getReference('center a_social', null))
->setUpdatedAt(new \DateTimeImmutable())
->setUpdatedBy($this->getReference('center a_social'));
->setUpdatedBy($this->getReference('center a_social', null));
$manager->persist($work);
if ($action->getEvaluations()->count() > 0) {
@@ -91,9 +91,9 @@ class LoadAccompanyingPeriodWork extends \Doctrine\Bundle\FixturesBundle\Fixture
->setStartDate(new \DateTimeImmutable('today'))
->addPerson($period->getPersons()->first())
->setCreatedAt(new \DateTimeImmutable())
->setCreatedBy($this->getReference('center a_social'))
->setCreatedBy($this->getReference('center a_social', null))
->setUpdatedAt(new \DateTimeImmutable())
->setUpdatedBy($this->getReference('center a_social'));
->setUpdatedBy($this->getReference('center a_social', null));
$manager->persist($work);
$ev = new AccompanyingPeriod\AccompanyingPeriodWorkEvaluation();
$ev->setAccompanyingPeriodWork($work)

View File

@@ -127,7 +127,7 @@ class LoadHousehold extends Fixture implements DependentFixtureInterface
foreach ($this->getRandomPersons(1, 3) as $person) {
$date = $startDate->add(new \DateInterval('P'.\random_int(1, 200).'W'));
$position = $this->getReference(LoadHouseholdPosition::ADULT);
$position = $this->getReference(LoadHouseholdPosition::ADULT, null);
$movement->addMovement($date, $person, $position, 0 === $k, 'self generated');
++$k;
@@ -136,7 +136,7 @@ class LoadHousehold extends Fixture implements DependentFixtureInterface
// load children
foreach ($this->getRandomPersons(0, 3) as $person) {
$date = $startDate->add(new \DateInterval('P'.\random_int(1, 200).'W'));
$position = $this->getReference(LoadHouseholdPosition::CHILD);
$position = $this->getReference(LoadHouseholdPosition::CHILD, null);
$movement->addMovement($date, $person, $position, 0 === $k, 'self generated');
++$k;
@@ -145,7 +145,7 @@ class LoadHousehold extends Fixture implements DependentFixtureInterface
// load children out
foreach ($this->getRandomPersons(0, 2) as $person) {
$date = $startDate->add(new \DateInterval('P'.\random_int(1, 200).'W'));
$position = $this->getReference(LoadHouseholdPosition::CHILD_OUT);
$position = $this->getReference(LoadHouseholdPosition::CHILD_OUT, null);
$movement->addMovement($date, $person, $position, 0 === $k, 'self generated');
++$k;
@@ -161,7 +161,7 @@ class LoadHousehold extends Fixture implements DependentFixtureInterface
{
$ref = LoadPostalCodes::$refs[\array_rand(LoadPostalCodes::$refs)];
return $this->getReference($ref);
return $this->getReference($ref, null);
}
private function getRandomPersons(int $min, int $max): array

View File

@@ -358,8 +358,8 @@ class LoadPeople extends AbstractFixture implements ContainerAwareInterface, Ord
if (\random_int(0, 10) > 3) {
// always add social scope:
$accompanyingPeriod->addScope($this->getReference('scope_social'));
$origin = $this->getReference(LoadAccompanyingPeriodOrigin::ACCOMPANYING_PERIOD_ORIGIN);
$accompanyingPeriod->addScope($this->getReference('scope_social', null));
$origin = $this->getReference(LoadAccompanyingPeriodOrigin::ACCOMPANYING_PERIOD_ORIGIN, null);
$accompanyingPeriod->setOrigin($origin);
$accompanyingPeriod->setIntensity('regular');
$accompanyingPeriod->setAddressLocation($this->createAddress());
@@ -472,7 +472,7 @@ class LoadPeople extends AbstractFixture implements ContainerAwareInterface, Ord
{
$ref = LoadPostalCodes::$refs[array_rand(LoadPostalCodes::$refs)];
return $this->getReference($ref);
return $this->getReference($ref, null);
}
private function getRandomSocialIssue(): SocialIssue

View File

@@ -33,8 +33,8 @@ class LoadPersonACL extends AbstractFixture implements OrderedFixtureInterface
public function load(ObjectManager $manager): void
{
foreach (LoadPermissionsGroup::$refs as $permissionsGroupRef) {
$permissionsGroup = $this->getReference($permissionsGroupRef);
$scopeSocial = $this->getReference('scope_social');
$permissionsGroup = $this->getReference($permissionsGroupRef, null);
$scopeSocial = $this->getReference('scope_social', null);
// create permission group
switch ($permissionsGroup->getName()) {

View File

@@ -46,7 +46,7 @@ class LoadRelationships extends Fixture implements DependentFixtureInterface
->setFromPerson($this->getRandomPerson($this->em))
->setToPerson($this->getRandomPerson($this->em))
->setRelation($this->getReference(LoadRelations::RELATION_KEY.
random_int(0, \count(LoadRelations::RELATIONS) - 1)))
random_int(0, \count(LoadRelations::RELATIONS) - 1), null))
->setReverse((bool) random_int(0, 1))
->setCreatedBy($user)
->setUpdatedBy($user)
@@ -74,6 +74,6 @@ class LoadRelationships extends Fixture implements DependentFixtureInterface
{
$userRef = array_rand(LoadUsers::$refs);
return $this->getReference($userRef);
return $this->getReference($userRef, null);
}
}