mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-22 23:53:50 +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:
@@ -27,23 +27,7 @@ final class UserControllerTest extends WebTestCase
|
||||
{
|
||||
use PrepareClientTrait;
|
||||
|
||||
private array $toDelete = [];
|
||||
|
||||
protected function tearDown(): void
|
||||
{
|
||||
self::bootKernel();
|
||||
$em = self::getContainer()->get(EntityManagerInterface::class);
|
||||
|
||||
foreach ($this->toDelete as [$class, $id]) {
|
||||
$obj = $em->getRepository($class)->find($id);
|
||||
$em->remove($obj);
|
||||
}
|
||||
|
||||
$em->flush();
|
||||
self::ensureKernelShutdown();
|
||||
}
|
||||
|
||||
public function dataGenerateUserId()
|
||||
public static function dataGenerateUserId()
|
||||
{
|
||||
self::bootKernel();
|
||||
$em = self::getContainer()->get(EntityManagerInterface::class);
|
||||
@@ -58,11 +42,9 @@ final class UserControllerTest extends WebTestCase
|
||||
$em->persist($user);
|
||||
$em->flush();
|
||||
|
||||
$this->toDelete[] = [User::class, $user->getId()];
|
||||
self::ensureKernelShutdown();
|
||||
|
||||
yield [$user->getId(), $user->getUsername()];
|
||||
|
||||
self::ensureKernelShutdown();
|
||||
}
|
||||
|
||||
public function testList()
|
||||
|
Reference in New Issue
Block a user