Update test methods to static in AbstractFilterTest

The methods getFormData() and getQueryBuilders() across multiple test classes have been updated to static methods. This refactoring is part of a broader effort to improve code structure and readability. A rector rule has been employed to assist in the systematic update of these existing methods.
This commit is contained in:
2024-02-14 22:35:15 +01:00
parent 1f460916b6
commit 35d55cced4
67 changed files with 139 additions and 324 deletions

View File

@@ -51,39 +51,32 @@ final class AgentFilterTest extends AbstractFilterTest
return $this->filter;
}
public function getFormData(): iterable
public static function getFormData(): array
{
self::bootKernel();
$em = self::getContainer()->get(EntityManagerInterface::class);
$array = $em->createQueryBuilder()
->from(User::class, 'u')
->select('u')
->getQuery()
->getResult();
$data = [];
foreach ($array as $a) {
yield [
'accepted_agents' => $a,
];
}
self::ensureKernelShutdown();
}
public function getQueryBuilders(): iterable
public static function getQueryBuilders(): iterable
{
self::bootKernel();
$em = self::getContainer()->get(EntityManagerInterface::class);
yield $em->createQueryBuilder()
->select('cal.id')
->from(Calendar::class, 'cal')
;
self::ensureKernelShutdown();
}
}

View File

@@ -51,7 +51,7 @@ final class BetweenDatesFilterTest extends AbstractFilterTest
return $this->filter;
}
public function getFormData(): array
public static function getFormData(): array
{
return [
[
@@ -61,10 +61,9 @@ final class BetweenDatesFilterTest extends AbstractFilterTest
];
}
public function getQueryBuilders(): array
public static function getQueryBuilders(): iterable
{
self::bootKernel();
$em = self::getContainer()->get(EntityManagerInterface::class);
return [

View File

@@ -52,11 +52,10 @@ final class JobFilterTest extends AbstractFilterTest
return $this->filter;
}
public function getFormData(): iterable
public static function getFormData(): array
{
self::bootKernel();
$em = self::getContainer()->get(EntityManagerInterface::class);
$array = $em->createQueryBuilder()
->from(UserJob::class, 'uj')
->select('uj')
@@ -71,10 +70,9 @@ final class JobFilterTest extends AbstractFilterTest
];
}
public function getQueryBuilders(): array
public static function getQueryBuilders(): iterable
{
self::bootKernel();
$em = self::getContainer()->get(EntityManagerInterface::class);
return [

View File

@@ -52,11 +52,10 @@ final class ScopeFilterTest extends AbstractFilterTest
return $this->filter;
}
public function getFormData(): array
public static function getFormData(): array
{
self::bootKernel();
$em = self::getContainer()->get(EntityManagerInterface::class);
$array = $em->createQueryBuilder()
->from(Scope::class, 's')
->select('s')
@@ -71,10 +70,9 @@ final class ScopeFilterTest extends AbstractFilterTest
];
}
public function getQueryBuilders(): array
public static function getQueryBuilders(): iterable
{
self::bootKernel();
$em = self::getContainer()->get(EntityManagerInterface::class);
return [