mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-10-01 02:49:42 +00:00
Change non-static class-level variables and methods to static in tests's data providers
The update modifies several test classes within the "chill-project" to change non-static class-level variables and methods to static ones. This change has been made to improve readability, performance, and to eliminate unnecessary instantiation of class objects in test scenarios. Also, flush and clear actions on the entity manager are moved to individual data providers.
This commit is contained in:
@@ -174,15 +174,16 @@ class PersonMoveTest extends KernelTestCase
|
||||
self::$entitiesToDelete[] = [Person\PersonCenterHistory::class, $personCenterHistoryBSecond];
|
||||
}
|
||||
|
||||
public function dataProviderMovePerson(): iterable
|
||||
public static function dataProviderMovePerson(): iterable
|
||||
{
|
||||
$this->setUp();
|
||||
self::bootKernel();
|
||||
$em = self::getContainer()->get(EntityManagerInterface::class);
|
||||
|
||||
$personA = new Person();
|
||||
$personB = new Person();
|
||||
|
||||
$this->em->persist($personA);
|
||||
$this->em->persist($personB);
|
||||
$em->persist($personA);
|
||||
$em->persist($personB);
|
||||
|
||||
self::$entitiesToDelete[] = [Person::class, $personA];
|
||||
self::$entitiesToDelete[] = [Person::class, $personB];
|
||||
@@ -197,9 +198,9 @@ class PersonMoveTest extends KernelTestCase
|
||||
$activity->addPerson($personA);
|
||||
$activity->addPerson($personB);
|
||||
|
||||
$this->em->persist($personA);
|
||||
$this->em->persist($personB);
|
||||
$this->em->persist($activity);
|
||||
$em->persist($personA);
|
||||
$em->persist($personB);
|
||||
$em->persist($activity);
|
||||
|
||||
self::$entitiesToDelete[] = [Person::class, $personA];
|
||||
self::$entitiesToDelete[] = [Person::class, $personB];
|
||||
@@ -219,11 +220,11 @@ class PersonMoveTest extends KernelTestCase
|
||||
->setStartDate(new \DateTimeImmutable('2023-01-01'))
|
||||
);
|
||||
|
||||
$this->em->persist($personA);
|
||||
$this->em->persist($personB);
|
||||
$this->em->persist($household);
|
||||
$this->em->persist($memberA);
|
||||
$this->em->persist($memberB);
|
||||
$em->persist($personA);
|
||||
$em->persist($personB);
|
||||
$em->persist($household);
|
||||
$em->persist($memberA);
|
||||
$em->persist($memberB);
|
||||
|
||||
self::$entitiesToDelete[] = [HouseholdMember::class, $memberA];
|
||||
self::$entitiesToDelete[] = [HouseholdMember::class, $memberB];
|
||||
@@ -240,9 +241,9 @@ class PersonMoveTest extends KernelTestCase
|
||||
$parcours->addPerson($personA);
|
||||
$parcours->addPerson($personB);
|
||||
|
||||
$this->em->persist($personA);
|
||||
$this->em->persist($personB);
|
||||
$this->em->persist($parcours);
|
||||
$em->persist($personA);
|
||||
$em->persist($personB);
|
||||
$em->persist($parcours);
|
||||
|
||||
self::$entitiesToDelete[] = [Person::class, $personA];
|
||||
self::$entitiesToDelete[] = [Person::class, $personB];
|
||||
@@ -262,11 +263,11 @@ class PersonMoveTest extends KernelTestCase
|
||||
$relationship->setReverse(false);
|
||||
$relationship->setCreatedBy($user);
|
||||
|
||||
$this->em->persist($personA);
|
||||
$this->em->persist($personB);
|
||||
$this->em->persist($relation);
|
||||
$this->em->persist($user);
|
||||
$this->em->persist($relationship);
|
||||
$em->persist($personA);
|
||||
$em->persist($personB);
|
||||
$em->persist($relation);
|
||||
$em->persist($user);
|
||||
$em->persist($relationship);
|
||||
|
||||
self::$entitiesToDelete[] = [Person::class, $personA];
|
||||
self::$entitiesToDelete[] = [Person::class, $personB];
|
||||
@@ -276,7 +277,7 @@ class PersonMoveTest extends KernelTestCase
|
||||
|
||||
yield [$personA, $personB, 'move 2 people with a relationship'];
|
||||
|
||||
$this->em->flush();
|
||||
$this->em->clear();
|
||||
$em->flush();
|
||||
$em->clear();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user