mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-30 18:39:43 +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:
@@ -31,7 +31,7 @@ final class HouseholdApiControllerTest extends WebTestCase
|
||||
{
|
||||
use PrepareClientTrait;
|
||||
|
||||
private array $toDelete = [];
|
||||
private static array $toDelete = [];
|
||||
|
||||
protected function tearDown(): void
|
||||
{
|
||||
@@ -39,17 +39,17 @@ final class HouseholdApiControllerTest extends WebTestCase
|
||||
|
||||
$em = self::getContainer()->get(EntityManagerInterface::class);
|
||||
|
||||
foreach ($this->toDelete as [$class, $id]) {
|
||||
foreach (self::$toDelete as [$class, $id]) {
|
||||
$obj = $em->getRepository($class)->find($id);
|
||||
$em->remove($obj);
|
||||
}
|
||||
|
||||
$em->flush();
|
||||
|
||||
self::$toDelete = [];
|
||||
self::ensureKernelShutdown();
|
||||
}
|
||||
|
||||
public function generateHouseholdAssociatedWithAddressReference()
|
||||
public static function generateHouseholdAssociatedWithAddressReference()
|
||||
{
|
||||
self::bootKernel();
|
||||
$em = self::getContainer()->get(EntityManagerInterface::class);
|
||||
@@ -80,7 +80,7 @@ final class HouseholdApiControllerTest extends WebTestCase
|
||||
|
||||
$em->flush();
|
||||
|
||||
$this->toDelete += [
|
||||
self::$toDelete += [
|
||||
[HouseholdMember::class, $m->getId()],
|
||||
[User::class, $p->getId()],
|
||||
[Household::class, $h->getId()],
|
||||
|
Reference in New Issue
Block a user