mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-28 04:56:13 +00:00
fix tests implementing AbstractFilterTest
This commit is contained in:
parent
f8f04c69d0
commit
a197a6b418
@ -21,8 +21,6 @@
|
||||
</testsuite>
|
||||
<testsuite name="PersonBundle">
|
||||
<directory suffix="Test.php">src/Bundle/ChillPersonBundle/Tests/</directory>
|
||||
<!-- test for export will be runned later -->
|
||||
<exclude>src/Bundle/ChillPersonBundle/Tests/Export/*</exclude>
|
||||
<!-- we are rewriting accompanying periods... Work in progress -->
|
||||
<exclude>src/Bundle/ChillPersonBundle/Tests/Controller/AccompanyingPeriodControllerTest.php</exclude>
|
||||
<!-- we are rewriting address, Work in progress -->
|
||||
|
@ -37,8 +37,11 @@ use function count;
|
||||
|
||||
class PersonHavingActivityBetweenDateFilter implements ExportElementValidatedInterface, FilterInterface
|
||||
{
|
||||
public function __construct(protected TranslatableStringHelper $translatableStringHelper, protected ActivityReasonRepository $activityReasonRepository, protected TranslatorInterface $translator)
|
||||
{
|
||||
public function __construct(
|
||||
protected TranslatableStringHelper $translatableStringHelper,
|
||||
protected ActivityReasonRepository $activityReasonRepository,
|
||||
protected TranslatorInterface $translator
|
||||
) {
|
||||
}
|
||||
|
||||
public function addRole(): ?string
|
||||
|
@ -41,6 +41,7 @@ final class ActivityTypeFilterTest extends AbstractFilterTest
|
||||
|
||||
public function getFormData(): array
|
||||
{
|
||||
self::bootKernel();
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
|
||||
$array = $em->createQueryBuilder()
|
||||
@ -62,9 +63,7 @@ final class ActivityTypeFilterTest extends AbstractFilterTest
|
||||
|
||||
public function getQueryBuilders(): array
|
||||
{
|
||||
if (null === self::$kernel) {
|
||||
self::bootKernel();
|
||||
}
|
||||
self::bootKernel();
|
||||
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
|
||||
|
@ -13,6 +13,7 @@ namespace Chill\ActivityBundle\Tests\Export\Filter\ACPFilters;
|
||||
|
||||
use Chill\ActivityBundle\Entity\Activity;
|
||||
use Chill\ActivityBundle\Export\Filter\ACPFilters\ByCreatorFilter;
|
||||
use Chill\ActivityBundle\Export\Filter\ACPFilters\UserFilter;
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Chill\MainBundle\Test\Export\AbstractFilterTest;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
@ -21,7 +22,7 @@ use Doctrine\ORM\EntityManagerInterface;
|
||||
* @internal
|
||||
* @coversNothing
|
||||
*/
|
||||
final class ByUserFilterTest extends AbstractFilterTest
|
||||
final class ByCreatorFilterTest extends AbstractFilterTest
|
||||
{
|
||||
private ByCreatorFilter $filter;
|
||||
|
||||
@ -29,7 +30,7 @@ final class ByUserFilterTest extends AbstractFilterTest
|
||||
{
|
||||
self::bootKernel();
|
||||
|
||||
$this->filter = self::$container->get('chill.activity.export.byuser_filter');
|
||||
$this->filter = self::$container->get(ByCreatorFilter::class);
|
||||
}
|
||||
|
||||
public function getFilter()
|
||||
@ -39,12 +40,14 @@ final class ByUserFilterTest extends AbstractFilterTest
|
||||
|
||||
public function getFormData(): array
|
||||
{
|
||||
self::bootKernel();
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
|
||||
$array = $em->createQueryBuilder()
|
||||
->from(User::class, 'u')
|
||||
->select('u')
|
||||
->getQuery()
|
||||
->setMaxResults(2)
|
||||
->getResult();
|
||||
|
||||
$data = [];
|
||||
@ -60,9 +63,7 @@ final class ByUserFilterTest extends AbstractFilterTest
|
||||
|
||||
public function getQueryBuilders(): array
|
||||
{
|
||||
if (null === self::$kernel) {
|
||||
self::bootKernel();
|
||||
}
|
||||
self::bootKernel();
|
||||
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
|
@ -15,6 +15,7 @@ use Chill\ActivityBundle\Entity\Activity;
|
||||
use Chill\ActivityBundle\Export\Filter\ACPFilters\BySocialActionFilter;
|
||||
use Chill\MainBundle\Test\Export\AbstractFilterTest;
|
||||
use Chill\PersonBundle\Entity\SocialWork\SocialAction;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
/**
|
||||
@ -39,19 +40,22 @@ final class BySocialActionFilterTest extends AbstractFilterTest
|
||||
|
||||
public function getFormData(): array
|
||||
{
|
||||
self::bootKernel();
|
||||
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
|
||||
$array = $em->createQueryBuilder()
|
||||
->from(SocialAction::class, 'sa')
|
||||
->select('sa')
|
||||
->getQuery()
|
||||
->setMaxResults(4)
|
||||
->getResult();
|
||||
|
||||
$data = [];
|
||||
|
||||
foreach ($array as $a) {
|
||||
$data[] = [
|
||||
'accepted_socialactions' => $a,
|
||||
'accepted_socialactions' => new ArrayCollection([$a]),
|
||||
];
|
||||
}
|
||||
|
||||
@ -60,9 +64,7 @@ final class BySocialActionFilterTest extends AbstractFilterTest
|
||||
|
||||
public function getQueryBuilders(): array
|
||||
{
|
||||
if (null === self::$kernel) {
|
||||
self::bootKernel();
|
||||
}
|
||||
self::bootKernel();
|
||||
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
|
||||
|
@ -46,9 +46,7 @@ final class EmergencyFilterTest extends AbstractFilterTest
|
||||
|
||||
public function getQueryBuilders(): array
|
||||
{
|
||||
if (null === self::$kernel) {
|
||||
self::bootKernel();
|
||||
}
|
||||
self::bootKernel();
|
||||
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
|
||||
|
@ -39,12 +39,14 @@ final class LocationTypeFilterTest extends AbstractFilterTest
|
||||
|
||||
public function getFormData(): array
|
||||
{
|
||||
self::bootKernel();
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
|
||||
$array = $em->createQueryBuilder()
|
||||
->from(LocationType::class, 'lt')
|
||||
->select('lt')
|
||||
->getQuery()
|
||||
->setMaxResults(1)
|
||||
->getResult();
|
||||
|
||||
$data = [];
|
||||
@ -60,9 +62,7 @@ final class LocationTypeFilterTest extends AbstractFilterTest
|
||||
|
||||
public function getQueryBuilders(): array
|
||||
{
|
||||
if (null === self::$kernel) {
|
||||
self::bootKernel();
|
||||
}
|
||||
self::bootKernel();
|
||||
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
|
||||
|
@ -46,9 +46,7 @@ final class SentReceivedFilterTest extends AbstractFilterTest
|
||||
|
||||
public function getQueryBuilders(): array
|
||||
{
|
||||
if (null === self::$kernel) {
|
||||
self::bootKernel();
|
||||
}
|
||||
self::bootKernel();
|
||||
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
|
||||
|
@ -39,12 +39,14 @@ final class UserFilterTest extends AbstractFilterTest
|
||||
|
||||
public function getFormData(): array
|
||||
{
|
||||
self::bootKernel();
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
|
||||
$array = $em->createQueryBuilder()
|
||||
->from(User::class, 'u')
|
||||
->select('u')
|
||||
->getQuery()
|
||||
->setMaxResults(1)
|
||||
->getResult();
|
||||
|
||||
$data = [];
|
||||
@ -60,9 +62,7 @@ final class UserFilterTest extends AbstractFilterTest
|
||||
|
||||
public function getQueryBuilders(): array
|
||||
{
|
||||
if (null === self::$kernel) {
|
||||
self::bootKernel();
|
||||
}
|
||||
self::bootKernel();
|
||||
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
|
||||
|
@ -39,12 +39,14 @@ final class UserScopeFilterTest extends AbstractFilterTest
|
||||
|
||||
public function getFormData(): array
|
||||
{
|
||||
self::bootKernel();
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
|
||||
$array = $em->createQueryBuilder()
|
||||
->from(Scope::class, 's')
|
||||
->select('s')
|
||||
->getQuery()
|
||||
->setMaxResults(1)
|
||||
->getResult();
|
||||
|
||||
$data = [];
|
||||
@ -60,9 +62,7 @@ final class UserScopeFilterTest extends AbstractFilterTest
|
||||
|
||||
public function getQueryBuilders(): array
|
||||
{
|
||||
if (null === self::$kernel) {
|
||||
self::bootKernel();
|
||||
}
|
||||
self::bootKernel();
|
||||
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
|
||||
|
@ -13,6 +13,7 @@ namespace Chill\ActivityBundle\Tests\Export\Filter;
|
||||
|
||||
use Chill\ActivityBundle\Entity\Activity;
|
||||
use Chill\ActivityBundle\Export\Filter\ActivityDateFilter;
|
||||
use Chill\MainBundle\Service\RollingDate\RollingDate;
|
||||
use Chill\MainBundle\Test\Export\AbstractFilterTest;
|
||||
use DateTime;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
@ -41,24 +42,23 @@ final class ActivityDateFilterTest extends AbstractFilterTest
|
||||
{
|
||||
return [
|
||||
[
|
||||
'date_from' => DateTime::createFromFormat('Y-m-d', '2020-01-01'),
|
||||
'date_to' => DateTime::createFromFormat('Y-m-d', '2021-01-01'),
|
||||
'date_from' => new RollingDate(RollingDate::T_FIXED_DATE, \DateTimeImmutable::createFromFormat('Y-m-d', '2020-01-01')),
|
||||
'date_to' => new RollingDate(RollingDate::T_FIXED_DATE, \DateTimeImmutable::createFromFormat('Y-m-d', '2021-01-01')),
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function getQueryBuilders(): array
|
||||
public function getQueryBuilders(): iterable
|
||||
{
|
||||
if (null === self::$kernel) {
|
||||
self::bootKernel();
|
||||
}
|
||||
self::bootKernel();
|
||||
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
|
||||
return [
|
||||
yield
|
||||
$em->createQueryBuilder()
|
||||
->select('count(activity.id)')
|
||||
->from(Activity::class, 'activity'),
|
||||
];
|
||||
->from(Activity::class, 'activity');
|
||||
|
||||
self::ensureKernelShutdown();
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,9 @@ namespace Chill\ActivityBundle\Tests\Export\Filter;
|
||||
use Chill\ActivityBundle\Export\Filter\PersonFilters\ActivityReasonFilter;
|
||||
use Chill\MainBundle\Test\Export\AbstractFilterTest;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Prophecy\PhpUnit\ProphecyTrait;
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
@ -37,7 +39,7 @@ final class ActivityReasonFilterTest extends AbstractFilterTest
|
||||
|
||||
$request->getLocale()->willReturn('fr');
|
||||
|
||||
self::$container->get('request_stack')
|
||||
self::$container->get(RequestStack::class)
|
||||
->push($request->reveal());
|
||||
}
|
||||
|
||||
@ -48,12 +50,10 @@ final class ActivityReasonFilterTest extends AbstractFilterTest
|
||||
|
||||
public function getFormData()
|
||||
{
|
||||
if (null === self::$kernel) {
|
||||
self::bootKernel();
|
||||
}
|
||||
self::bootKernel();
|
||||
|
||||
$em = self::$kernel->getContainer()
|
||||
->get('doctrine.orm.entity_manager');
|
||||
$em = self::$container
|
||||
->get(EntityManagerInterface::class);
|
||||
|
||||
$reasons = $em->createQuery('SELECT reason '
|
||||
. 'FROM ChillActivityBundle:ActivityReason reason')
|
||||
@ -61,34 +61,31 @@ final class ActivityReasonFilterTest extends AbstractFilterTest
|
||||
|
||||
// generate an array of 5 different combination of results
|
||||
for ($i = 0; 5 > $i; ++$i) {
|
||||
$r[] = ['reasons' => new ArrayCollection(array_splice($reasons, ($i + 1) * -1))];
|
||||
yield ['reasons' => new ArrayCollection(array_splice($reasons, ($i + 1) * -1))];
|
||||
}
|
||||
|
||||
return $r;
|
||||
self::ensureKernelShutdown();
|
||||
}
|
||||
|
||||
public function getQueryBuilders()
|
||||
public function getQueryBuilders(): iterable
|
||||
{
|
||||
if (null === self::$kernel) {
|
||||
self::bootKernel();
|
||||
}
|
||||
self::bootKernel();
|
||||
|
||||
$em = self::$kernel->getContainer()
|
||||
->get('doctrine.orm.entity_manager');
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
|
||||
return [
|
||||
$em->createQueryBuilder()
|
||||
->select('count(activity.id)')
|
||||
->from('ChillActivityBundle:Activity', 'activity'),
|
||||
$em->createQueryBuilder()
|
||||
->select('count(activity.id)')
|
||||
->from('ChillActivityBundle:Activity', 'activity')
|
||||
->join('activity.reasons', 'reasons'),
|
||||
$em->createQueryBuilder()
|
||||
->select('count(activity.id)')
|
||||
->from('ChillActivityBundle:Activity', 'activity')
|
||||
->join('activity.reasons', 'reasons')
|
||||
->join('reasons.category', 'category'),
|
||||
];
|
||||
yield $em->createQueryBuilder()
|
||||
->select('count(activity.id)')
|
||||
->from('ChillActivityBundle:Activity', 'activity');
|
||||
yield $em->createQueryBuilder()
|
||||
->select('count(activity.id)')
|
||||
->from('ChillActivityBundle:Activity', 'activity')
|
||||
->join('activity.reasons', 'reasons');
|
||||
yield $em->createQueryBuilder()
|
||||
->select('count(activity.id)')
|
||||
->from('ChillActivityBundle:Activity', 'activity')
|
||||
->join('activity.reasons', 'reasons')
|
||||
->join('reasons.category', 'category');
|
||||
|
||||
self::ensureKernelShutdown();
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ use Chill\ActivityBundle\Entity\Activity;
|
||||
use Chill\ActivityBundle\Entity\ActivityType;
|
||||
use Chill\ActivityBundle\Export\Filter\ActivityTypeFilter;
|
||||
use Chill\MainBundle\Test\Export\AbstractFilterTest;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
/**
|
||||
@ -37,8 +38,10 @@ final class ActivityTypeFilterTest extends AbstractFilterTest
|
||||
return $this->filter;
|
||||
}
|
||||
|
||||
public function getFormData(): array
|
||||
public function getFormData(): iterable
|
||||
{
|
||||
self::bootKernel();
|
||||
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
|
||||
$array = $em->createQueryBuilder()
|
||||
@ -51,25 +54,24 @@ final class ActivityTypeFilterTest extends AbstractFilterTest
|
||||
|
||||
foreach ($array as $a) {
|
||||
$data[] = [
|
||||
'types' => $a,
|
||||
'types' => new ArrayCollection([$a]),
|
||||
];
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function getQueryBuilders(): array
|
||||
public function getQueryBuilders(): iterable
|
||||
{
|
||||
if (null === self::$kernel) {
|
||||
self::bootKernel();
|
||||
}
|
||||
self::bootKernel();
|
||||
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
|
||||
return [
|
||||
yield
|
||||
$em->createQueryBuilder()
|
||||
->select('count(activity.id)')
|
||||
->from(Activity::class, 'activity'),
|
||||
];
|
||||
->from(Activity::class, 'activity');
|
||||
|
||||
self::ensureKernelShutdown();
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ use Chill\ActivityBundle\Entity\Activity;
|
||||
use Chill\ActivityBundle\Entity\ActivityReason;
|
||||
use Chill\ActivityBundle\Export\Filter\PersonFilters\ActivityReasonFilter;
|
||||
use Chill\MainBundle\Test\Export\AbstractFilterTest;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
/**
|
||||
@ -39,19 +40,21 @@ final class ActivityReasonFilterTest extends AbstractFilterTest
|
||||
|
||||
public function getFormData(): array
|
||||
{
|
||||
self::bootKernel();
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
|
||||
$array = $em->createQueryBuilder()
|
||||
->from(ActivityReason::class, 'ar')
|
||||
->select('ar')
|
||||
->getQuery()
|
||||
->setMaxResults(1)
|
||||
->getResult();
|
||||
|
||||
$data = [];
|
||||
|
||||
foreach ($array as $a) {
|
||||
$data[] = [
|
||||
'reasons' => $a,
|
||||
'reasons' => new ArrayCollection([$a]),
|
||||
];
|
||||
}
|
||||
|
||||
@ -60,9 +63,7 @@ final class ActivityReasonFilterTest extends AbstractFilterTest
|
||||
|
||||
public function getQueryBuilders(): array
|
||||
{
|
||||
if (null === self::$kernel) {
|
||||
self::bootKernel();
|
||||
}
|
||||
self::bootKernel();
|
||||
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
|
||||
|
@ -40,12 +40,14 @@ final class PersonHavingActivityBetweenDateFilterTest extends AbstractFilterTest
|
||||
|
||||
public function getFormData(): array
|
||||
{
|
||||
self::bootKernel();
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
|
||||
$array = $em->createQueryBuilder()
|
||||
->from(ActivityReason::class, 'ar')
|
||||
->select('ar')
|
||||
->getQuery()
|
||||
->setMaxResults(1)
|
||||
->getResult();
|
||||
|
||||
$data = [];
|
||||
|
@ -12,8 +12,13 @@ declare(strict_types=1);
|
||||
namespace Chill\ActivityBundle\Tests\Export\Filter;
|
||||
|
||||
use Chill\ActivityBundle\Export\Filter\PersonFilters\PersonHavingActivityBetweenDateFilter;
|
||||
use Chill\ActivityBundle\Repository\ActivityReasonRepository;
|
||||
use Chill\MainBundle\Test\Export\AbstractFilterTest;
|
||||
use DateTime;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
use function array_slice;
|
||||
|
||||
/**
|
||||
@ -35,7 +40,7 @@ final class PersonHavingActivityBetweenDateFilterTest extends AbstractFilterTest
|
||||
|
||||
$request->getLocale()->willReturn('fr');
|
||||
|
||||
self::$container->get('request_stack')
|
||||
self::$container->get(RequestStack::class)
|
||||
->push($request->reveal());
|
||||
}
|
||||
|
||||
@ -65,26 +70,24 @@ final class PersonHavingActivityBetweenDateFilterTest extends AbstractFilterTest
|
||||
|
||||
public function getQueryBuilders()
|
||||
{
|
||||
if (null === self::$kernel) {
|
||||
self::bootKernel();
|
||||
}
|
||||
self::bootKernel();
|
||||
|
||||
$em = self::$kernel->getContainer()
|
||||
->get('doctrine.orm.entity_manager');
|
||||
$em = self::$container
|
||||
->get(EntityManagerInterface::class);
|
||||
|
||||
return [
|
||||
$em->createQueryBuilder()
|
||||
->select('count(person.id)')
|
||||
->from('ChillPersonBundle:Person', 'person')
|
||||
// add a fake where clause
|
||||
->where('person.id > 0'),
|
||||
$em->createQueryBuilder()
|
||||
->select('count(person.id)')
|
||||
->from('ChillActivityBundle:Activity', 'activity')
|
||||
->join('activity.person', 'person')
|
||||
// add a fake where clause
|
||||
->where('person.id > 0'),
|
||||
];
|
||||
yield $em->createQueryBuilder()
|
||||
->select('count(person.id)')
|
||||
->from('ChillPersonBundle:Person', 'person')
|
||||
// add a fake where clause
|
||||
->where('person.id > 0');
|
||||
yield $em->createQueryBuilder()
|
||||
->select('count(person.id)')
|
||||
->from('ChillActivityBundle:Activity', 'activity')
|
||||
->join('activity.person', 'person')
|
||||
// add a fake where clause
|
||||
->where('person.id > 0');
|
||||
|
||||
self::ensureKernelShutdown();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -94,12 +97,14 @@ final class PersonHavingActivityBetweenDateFilterTest extends AbstractFilterTest
|
||||
*/
|
||||
private function getActivityReasons()
|
||||
{
|
||||
if (null === self::$kernel) {
|
||||
self::bootKernel();
|
||||
}
|
||||
self::bootKernel();
|
||||
|
||||
return self::$kernel->getContainer()
|
||||
->get('chill_activity.repository.reason')
|
||||
->findAll();
|
||||
$managerRegistry = self::$container->get(ManagerRegistry::class);
|
||||
$requestStack = new RequestStack();
|
||||
$requestStack->push(new Request());
|
||||
|
||||
$repository = new ActivityReasonRepository($managerRegistry, $requestStack);
|
||||
|
||||
return $repository->findAll();
|
||||
}
|
||||
}
|
||||
|
@ -63,9 +63,7 @@ final class BetweenDatesFilterTest extends AbstractFilterTest
|
||||
|
||||
public function getQueryBuilders(): array
|
||||
{
|
||||
if (null === self::$kernel) {
|
||||
self::bootKernel();
|
||||
}
|
||||
self::bootKernel();
|
||||
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
|
||||
|
@ -50,32 +50,24 @@ final class JobFilterTest extends AbstractFilterTest
|
||||
return $this->filter;
|
||||
}
|
||||
|
||||
public function getFormData(): array
|
||||
public function getFormData(): iterable
|
||||
{
|
||||
self::bootKernel();
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
|
||||
$array = $em->createQueryBuilder()
|
||||
->from(UserJob::class, 'uj')
|
||||
->select('uj')
|
||||
->getQuery()
|
||||
->setMaxResults(1)
|
||||
->getResult();
|
||||
|
||||
$data = [];
|
||||
|
||||
foreach ($array as $a) {
|
||||
$data[] = [
|
||||
'job' => $a,
|
||||
];
|
||||
}
|
||||
|
||||
return $data;
|
||||
yield ['job' => $array];
|
||||
}
|
||||
|
||||
public function getQueryBuilders(): array
|
||||
{
|
||||
if (null === self::$kernel) {
|
||||
self::bootKernel();
|
||||
}
|
||||
self::bootKernel();
|
||||
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
|
||||
@ -83,7 +75,6 @@ final class JobFilterTest extends AbstractFilterTest
|
||||
$em->createQueryBuilder()
|
||||
->select('cal.id')
|
||||
->from(Calendar::class, 'cal')
|
||||
->join('cal.user', 'caluser'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -52,12 +52,14 @@ final class ScopeFilterTest extends AbstractFilterTest
|
||||
|
||||
public function getFormData(): array
|
||||
{
|
||||
self::bootKernel();
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
|
||||
$array = $em->createQueryBuilder()
|
||||
->from(Scope::class, 's')
|
||||
->select('s')
|
||||
->getQuery()
|
||||
->setMaxResults(1)
|
||||
->getResult();
|
||||
|
||||
$data = [];
|
||||
@ -73,9 +75,7 @@ final class ScopeFilterTest extends AbstractFilterTest
|
||||
|
||||
public function getQueryBuilders(): array
|
||||
{
|
||||
if (null === self::$kernel) {
|
||||
self::bootKernel();
|
||||
}
|
||||
self::bootKernel();
|
||||
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
|
||||
@ -83,7 +83,6 @@ final class ScopeFilterTest extends AbstractFilterTest
|
||||
$em->createQueryBuilder()
|
||||
->select('cal.id')
|
||||
->from(Calendar::class, 'cal')
|
||||
->join('cal.user', 'caluser'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -23,8 +23,6 @@ use function is_string;
|
||||
|
||||
/**
|
||||
* Helper to test filters.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
abstract class AbstractFilterTest extends KernelTestCase
|
||||
{
|
||||
@ -50,18 +48,45 @@ abstract class AbstractFilterTest extends KernelTestCase
|
||||
*/
|
||||
public function dataProviderAliasDidNotDisappears()
|
||||
{
|
||||
$datas = $this->getFormData();
|
||||
|
||||
foreach ($this->getQueryBuilders() as $qb) {
|
||||
foreach ($this->getFormData() as $data) {
|
||||
yield [clone $qb, $data];
|
||||
if ([] === $datas) {
|
||||
yield [clone $qb, []];
|
||||
} else {
|
||||
foreach ($datas as $data) {
|
||||
yield [clone $qb, $data];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function dataProviderAlterQuery()
|
||||
{
|
||||
$datas = $this->getFormData();
|
||||
|
||||
foreach ($this->getQueryBuilders() as $qb) {
|
||||
foreach ($this->getFormData() as $data) {
|
||||
yield [$qb, $data];
|
||||
if ([] === $datas) {
|
||||
yield [clone $qb, []];
|
||||
} else {
|
||||
foreach ($datas as $data) {
|
||||
yield [clone $qb, $data];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function dataProvideQueryExecution(): iterable
|
||||
{
|
||||
$datas = $this->getFormData();
|
||||
|
||||
foreach ($this->getQueryBuilders() as $qb) {
|
||||
if ([] === $datas) {
|
||||
yield [clone $qb, []];
|
||||
} else {
|
||||
foreach ($datas as $data) {
|
||||
yield [clone $qb, $data];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -108,10 +133,8 @@ abstract class AbstractFilterTest extends KernelTestCase
|
||||
* Compare aliases array before and after that filter alter query.
|
||||
*
|
||||
* @dataProvider dataProviderAliasDidNotDisappears
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testAliasDidNotDisappears(QueryBuilder $qb, array $data)
|
||||
public function testAliasDidNotDisappears(QueryBuilder $qb, array $data): void
|
||||
{
|
||||
$aliases = $qb->getAllAliases();
|
||||
|
||||
@ -131,9 +154,8 @@ abstract class AbstractFilterTest extends KernelTestCase
|
||||
*
|
||||
* @dataProvider dataProviderAlterQuery
|
||||
*
|
||||
* @param type $data
|
||||
*/
|
||||
public function testAlterQuery(QueryBuilder $query, $data)
|
||||
public function testAlterQuery(QueryBuilder $query, array $data)
|
||||
{
|
||||
// retains informations about query
|
||||
$nbOfFrom = $query->getDQLPart('from') !== null ?
|
||||
@ -164,6 +186,18 @@ abstract class AbstractFilterTest extends KernelTestCase
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider dataProvideQueryExecution
|
||||
*/
|
||||
public function testQueryExecution(QueryBuilder $qb, mixed $data): void
|
||||
{
|
||||
$this->getFilter()->alterQuery($qb, $data);
|
||||
|
||||
$actual = $qb->getQuery()->getResult();
|
||||
|
||||
self::assertIsArray($actual);
|
||||
}
|
||||
|
||||
public function testApplyOn()
|
||||
{
|
||||
$filter = $this->getFilter();
|
||||
|
@ -79,7 +79,7 @@ class ReferrerFilter implements FilterInterface
|
||||
}
|
||||
public function getFormDefaultData(): array
|
||||
{
|
||||
return ['date_calc' => new RollingDate(RollingDate::T_TODAY)];
|
||||
return ['date_calc' => new RollingDate(RollingDate::T_TODAY), 'accepted_referrers' => []];
|
||||
}
|
||||
|
||||
public function describeAction($data, $format = 'string'): array
|
||||
|
@ -11,7 +11,9 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\PersonBundle\Tests\Export\Filter\AccompanyingCourseFilters;
|
||||
|
||||
use Chill\MainBundle\Service\RollingDate\RollingDate;
|
||||
use Chill\MainBundle\Test\Export\AbstractFilterTest;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\ActiveOnDateFilter;
|
||||
use DateTime;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
@ -40,22 +42,20 @@ final class ActiveOnDateFilterTest extends AbstractFilterTest
|
||||
{
|
||||
return [
|
||||
[
|
||||
'on_date' => DateTime::createFromFormat('Y-m-d', '2022-05-01'),
|
||||
'on_date' => new RollingDate(RollingDate::T_FIXED_DATE, \DateTimeImmutable::createFromFormat('Y-m-d', '2022-05-01')),
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function getQueryBuilders(): array
|
||||
{
|
||||
if (null === self::$kernel) {
|
||||
self::bootKernel();
|
||||
}
|
||||
self::bootKernel();
|
||||
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
|
||||
return [
|
||||
$em->createQueryBuilder()
|
||||
->from('ChillPersonBundle:AccompanyingPeriod', 'acp')
|
||||
->from(AccompanyingPeriod::class, 'acp')
|
||||
->select('acp.id'),
|
||||
];
|
||||
}
|
||||
|
@ -11,7 +11,9 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\PersonBundle\Tests\Export\Filter\AccompanyingCourseFilters;
|
||||
|
||||
use Chill\MainBundle\Service\RollingDate\RollingDate;
|
||||
use Chill\MainBundle\Test\Export\AbstractFilterTest;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\ActiveOneDayBetweenDatesFilter;
|
||||
use DateTime;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
@ -40,24 +42,22 @@ final class ActiveOneDayBetweenDatesFilterTest extends AbstractFilterTest
|
||||
{
|
||||
return [
|
||||
[
|
||||
'date_from' => DateTime::createFromFormat('Y-m-d', '2022-05-01'),
|
||||
'date_to' => DateTime::createFromFormat('Y-m-d', '2022-06-01'),
|
||||
'date_from' => new RollingDate(RollingDate::T_FIXED_DATE, \DateTimeImmutable::createFromFormat('Y-m-d', '2022-05-01')),
|
||||
'date_to' => new RollingDate(RollingDate::T_FIXED_DATE, \DateTimeImmutable::createFromFormat('Y-m-d', '2022-06-01')),
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function getQueryBuilders(): array
|
||||
{
|
||||
if (null === self::$kernel) {
|
||||
self::bootKernel();
|
||||
}
|
||||
self::bootKernel();
|
||||
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
|
||||
return [
|
||||
$em->createQueryBuilder()
|
||||
->from('ChillPersonBundle:AccompanyingPeriod', 'acp')
|
||||
->select('acp.id'),
|
||||
->from(AccompanyingPeriod::class, 'acp')
|
||||
->select('count(distinct acp)'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -38,12 +38,14 @@ final class AdministrativeLocationFilterTest extends AbstractFilterTest
|
||||
|
||||
public function getFormData(): array
|
||||
{
|
||||
self::bootKernel();
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
|
||||
$array = $em->createQueryBuilder()
|
||||
->from(Location::class, 'l')
|
||||
->select('l')
|
||||
->getQuery()
|
||||
->setMaxResults(1)
|
||||
->getResult();
|
||||
|
||||
$data = [];
|
||||
@ -57,9 +59,7 @@ final class AdministrativeLocationFilterTest extends AbstractFilterTest
|
||||
|
||||
public function getQueryBuilders(): array
|
||||
{
|
||||
if (null === self::$kernel) {
|
||||
self::bootKernel();
|
||||
}
|
||||
self::bootKernel();
|
||||
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
|
||||
|
@ -12,6 +12,7 @@ declare(strict_types=1);
|
||||
namespace Chill\PersonBundle\Tests\Export\Filter\AccompanyingCourseFilters;
|
||||
|
||||
use Chill\MainBundle\Test\Export\AbstractFilterTest;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\ClosingMotive;
|
||||
use Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\ClosingMotiveFilter;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
@ -38,6 +39,7 @@ final class ClosingMotiveFilterTest extends AbstractFilterTest
|
||||
|
||||
public function getFormData(): array
|
||||
{
|
||||
self::bootKernel();
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
|
||||
$array = $em->createQueryBuilder()
|
||||
@ -57,16 +59,14 @@ final class ClosingMotiveFilterTest extends AbstractFilterTest
|
||||
|
||||
public function getQueryBuilders(): array
|
||||
{
|
||||
if (null === self::$kernel) {
|
||||
self::bootKernel();
|
||||
}
|
||||
self::bootKernel();
|
||||
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
|
||||
return [
|
||||
$em->createQueryBuilder()
|
||||
->select('acp.id')
|
||||
->from('ChillPersonBundle:AccompanyingPeriod', 'acp'),
|
||||
->from(AccompanyingPeriod::class, 'acp'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -45,9 +45,7 @@ final class ConfidentialFilterTest extends AbstractFilterTest
|
||||
|
||||
public function getQueryBuilders(): array
|
||||
{
|
||||
if (null === self::$kernel) {
|
||||
self::bootKernel();
|
||||
}
|
||||
self::bootKernel();
|
||||
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
|
||||
|
@ -38,16 +38,14 @@ final class EmergencyFilterTest extends AbstractFilterTest
|
||||
public function getFormData(): array
|
||||
{
|
||||
return [
|
||||
['accepted_emergencies' => true],
|
||||
['accepted_emergencies' => false],
|
||||
['accepted_emergency' => true],
|
||||
['accepted_emergency' => false],
|
||||
];
|
||||
}
|
||||
|
||||
public function getQueryBuilders(): array
|
||||
{
|
||||
if (null === self::$kernel) {
|
||||
self::bootKernel();
|
||||
}
|
||||
self::bootKernel();
|
||||
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
|
||||
|
@ -38,12 +38,14 @@ final class EvaluationFilterTest extends AbstractFilterTest
|
||||
|
||||
public function getFormData(): array
|
||||
{
|
||||
self::bootKernel();
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
|
||||
$array = $em->createQueryBuilder()
|
||||
->from(Evaluation::class, 'ev')
|
||||
->select('ev')
|
||||
->getQuery()
|
||||
->setMaxResults(1)
|
||||
->getResult();
|
||||
|
||||
$data = [];
|
||||
@ -57,9 +59,7 @@ final class EvaluationFilterTest extends AbstractFilterTest
|
||||
|
||||
public function getQueryBuilders(): array
|
||||
{
|
||||
if (null === self::$kernel) {
|
||||
self::bootKernel();
|
||||
}
|
||||
self::bootKernel();
|
||||
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
|
||||
|
@ -11,7 +11,11 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\PersonBundle\Tests\Export\Filter\AccompanyingCourseFilters;
|
||||
|
||||
use Chill\MainBundle\Entity\GeographicalUnit;
|
||||
use Chill\MainBundle\Repository\GeographicalUnitRepositoryInterface;
|
||||
use Chill\MainBundle\Service\RollingDate\RollingDate;
|
||||
use Chill\MainBundle\Test\Export\AbstractFilterTest;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\GeographicalUnitStatFilter;
|
||||
use DateTime;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
@ -38,25 +42,28 @@ final class GeographicalUnitStatFilterTest extends AbstractFilterTest
|
||||
|
||||
public function getFormData(): array
|
||||
{
|
||||
self::bootKernel();
|
||||
$repo = self::$container->get(GeographicalUnitRepositoryInterface::class);
|
||||
|
||||
$units = $repo->findAll();
|
||||
|
||||
return [
|
||||
[
|
||||
'date' => DateTime::createFromFormat('Y-m-d', '2022-05-01'),
|
||||
'accepted_loctype' => 'center',
|
||||
'date_calc' => new RollingDate(RollingDate::T_TODAY),
|
||||
'units' => $units
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function getQueryBuilders(): array
|
||||
{
|
||||
if (null === self::$kernel) {
|
||||
self::bootKernel();
|
||||
}
|
||||
self::bootKernel();
|
||||
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
|
||||
return [
|
||||
$em->createQueryBuilder()
|
||||
->from('ChillPersonBundle:AccompanyingPeriod', 'acp')
|
||||
->from(AccompanyingPeriod::class, 'acp')
|
||||
->select('acp.id'),
|
||||
];
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ declare(strict_types=1);
|
||||
namespace Chill\PersonBundle\Tests\Export\Filter\AccompanyingCourseFilters;
|
||||
|
||||
use Chill\MainBundle\Test\Export\AbstractFilterTest;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\IntensityFilter;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
@ -45,16 +46,14 @@ final class IntensityFilterTest extends AbstractFilterTest
|
||||
|
||||
public function getQueryBuilders(): array
|
||||
{
|
||||
if (null === self::$kernel) {
|
||||
self::bootKernel();
|
||||
}
|
||||
self::bootKernel();
|
||||
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
|
||||
return [
|
||||
$em->createQueryBuilder()
|
||||
->select('acp.id')
|
||||
->from('ChillPersonBundle:AccompanyingPeriod', 'acp'),
|
||||
->from(AccompanyingPeriod::class, 'acp'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,9 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\PersonBundle\Tests\Export\Filter\AccompanyingCourseFilters;
|
||||
|
||||
use Chill\MainBundle\Service\RollingDate\RollingDate;
|
||||
use Chill\MainBundle\Test\Export\AbstractFilterTest;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\OpenBetweenDatesFilter;
|
||||
use DateTime;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
@ -40,23 +42,21 @@ final class OpenBetweenDatesFilterTest extends AbstractFilterTest
|
||||
{
|
||||
return [
|
||||
[
|
||||
'date_from' => DateTime::createFromFormat('Y-m-d', '2022-05-01'),
|
||||
'date_to' => DateTime::createFromFormat('Y-m-d', '2022-06-01'),
|
||||
'date_from' => new RollingDate(RollingDate::T_YEAR_PREVIOUS_START),
|
||||
'date_to' => new RollingDate(RollingDate::T_TODAY),
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function getQueryBuilders(): array
|
||||
{
|
||||
if (null === self::$kernel) {
|
||||
self::bootKernel();
|
||||
}
|
||||
self::bootKernel();
|
||||
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
|
||||
return [
|
||||
$em->createQueryBuilder()
|
||||
->from('ChillPersonBundle:AccompanyingPeriod', 'acp')
|
||||
->from(AccompanyingPeriod::class, 'acp')
|
||||
->select('acp.id'),
|
||||
];
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ declare(strict_types=1);
|
||||
namespace Chill\PersonBundle\Tests\Export\Filter\AccompanyingCourseFilters;
|
||||
|
||||
use Chill\MainBundle\Test\Export\AbstractFilterTest;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\Origin;
|
||||
use Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\OriginFilter;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
@ -38,12 +39,14 @@ final class OriginFilterTest extends AbstractFilterTest
|
||||
|
||||
public function getFormData(): array
|
||||
{
|
||||
self::bootKernel();
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
|
||||
$array = $em->createQueryBuilder()
|
||||
->from(Origin::class, 'o')
|
||||
->select('o')
|
||||
->getQuery()
|
||||
->setMaxResults(1)
|
||||
->getResult();
|
||||
|
||||
$data = [];
|
||||
@ -57,16 +60,14 @@ final class OriginFilterTest extends AbstractFilterTest
|
||||
|
||||
public function getQueryBuilders(): array
|
||||
{
|
||||
if (null === self::$kernel) {
|
||||
self::bootKernel();
|
||||
}
|
||||
self::bootKernel();
|
||||
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
|
||||
return [
|
||||
$em->createQueryBuilder()
|
||||
->select('acp.id')
|
||||
->from('ChillPersonBundle:AccompanyingPeriod', 'acp'),
|
||||
->from(AccompanyingPeriod::class, 'acp'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,11 @@ declare(strict_types=1);
|
||||
namespace Chill\PersonBundle\Tests\Export\Filter\AccompanyingCourseFilters;
|
||||
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Chill\MainBundle\Service\RollingDate\RollingDate;
|
||||
use Chill\MainBundle\Test\Export\AbstractFilterTest;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use Chill\PersonBundle\Entity\Person\PersonCenterHistory;
|
||||
use Chill\PersonBundle\Export\Export\CountAccompanyingPeriodWork;
|
||||
use Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\ReferrerFilter;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
@ -38,42 +42,46 @@ final class ReferrerFilterTest extends AbstractFilterTest
|
||||
|
||||
public function getFormData(): array
|
||||
{
|
||||
self:self::bootKernel();
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
|
||||
$array = $em->createQueryBuilder()
|
||||
->from(User::class, 'u')
|
||||
->select('u')
|
||||
->getQuery()
|
||||
->setMaxResults(1)
|
||||
->getResult();
|
||||
|
||||
$data = [];
|
||||
|
||||
foreach ($array as $u) {
|
||||
$data[] = ['accepted_referrers' => $u];
|
||||
$data[] = ['accepted_referrers' => $u, 'date_calc' => new RollingDate(RollingDate::T_TODAY)];
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function getQueryBuilders(): array
|
||||
public function getQueryBuilders(): iterable
|
||||
{
|
||||
if (null === self::$kernel) {
|
||||
self::bootKernel();
|
||||
}
|
||||
self::bootKernel();
|
||||
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
|
||||
return [
|
||||
$em->createQueryBuilder()
|
||||
->from('ChillPersonBundle:AccompanyingPeriod', 'acp')
|
||||
->select('acp.id'),
|
||||
$em->createQueryBuilder()
|
||||
->from('ChillPersonBundle:AccompanyingPeriod\AccompanyingPeriodWork', 'acpw')
|
||||
->select('acpw.id'),
|
||||
$em->createQueryBuilder()
|
||||
->from('ChillPersonBundle:AccompanyingPeriod\AccompanyingPeriodWork', 'acpw')
|
||||
->join('acpw.referrers', 'acpwuser')
|
||||
->select('acpwuser.id'),
|
||||
];
|
||||
yield $em->createQueryBuilder()
|
||||
->from(AccompanyingPeriod::class, 'acp')
|
||||
->select('acp.id');
|
||||
|
||||
$qb = $em->createQueryBuilder();
|
||||
$qb
|
||||
->from(AccompanyingPeriod\AccompanyingPeriodWork::class, 'acpw')
|
||||
->join('acpw.accompanyingPeriod', 'acp')
|
||||
->join('acp.participations', 'acppart')
|
||||
->join('acppart.person', 'person')
|
||||
;
|
||||
|
||||
$qb->select('COUNT(DISTINCT acpw.id) as export_result');
|
||||
|
||||
yield $qb;
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ declare(strict_types=1);
|
||||
namespace Chill\PersonBundle\Tests\Export\Filter\AccompanyingCourseFilters;
|
||||
|
||||
use Chill\MainBundle\Test\Export\AbstractFilterTest;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\RequestorFilter;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
@ -47,15 +48,13 @@ final class RequestorFilterTest extends AbstractFilterTest
|
||||
|
||||
public function getQueryBuilders(): array
|
||||
{
|
||||
if (null === self::$kernel) {
|
||||
self::bootKernel();
|
||||
}
|
||||
self::bootKernel();
|
||||
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
|
||||
return [
|
||||
$em->createQueryBuilder()
|
||||
->from('ChillPersonBundle:AccompanyingPeriod', 'acp')
|
||||
->from(AccompanyingPeriod::class, 'acp')
|
||||
->select('acp.id'),
|
||||
];
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ declare(strict_types=1);
|
||||
namespace Chill\PersonBundle\Tests\Export\Filter\AccompanyingCourseFilters;
|
||||
|
||||
use Chill\MainBundle\Test\Export\AbstractFilterTest;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use Chill\PersonBundle\Entity\SocialWork\SocialAction;
|
||||
use Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\SocialActionFilter;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
@ -36,36 +37,30 @@ final class SocialActionFilterTest extends AbstractFilterTest
|
||||
return $this->filter;
|
||||
}
|
||||
|
||||
public function getFormData(): array
|
||||
public function getFormData(): iterable
|
||||
{
|
||||
self::bootKernel();
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
|
||||
$array = $em->createQueryBuilder()
|
||||
->from(SocialAction::class, 'sa')
|
||||
->select('sa')
|
||||
->getQuery()
|
||||
->setMaxResults(1)
|
||||
->getResult();
|
||||
|
||||
$data = [];
|
||||
|
||||
foreach ($array as $a) {
|
||||
$data[] = ['accepted_socialactions' => $a];
|
||||
}
|
||||
|
||||
return $data;
|
||||
yield ['accepted_socialactions' => $array];
|
||||
}
|
||||
|
||||
public function getQueryBuilders(): array
|
||||
{
|
||||
if (null === self::$kernel) {
|
||||
self::bootKernel();
|
||||
}
|
||||
self::bootKernel();
|
||||
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
|
||||
return [
|
||||
$em->createQueryBuilder()
|
||||
->from('ChillPersonBundle:AccompanyingPeriod', 'acp')
|
||||
->from(AccompanyingPeriod::class, 'acp')
|
||||
->select('acp.id'),
|
||||
];
|
||||
}
|
||||
|
@ -12,8 +12,10 @@ declare(strict_types=1);
|
||||
namespace Chill\PersonBundle\Tests\Export\Filter\AccompanyingCourseFilters;
|
||||
|
||||
use Chill\MainBundle\Test\Export\AbstractFilterTest;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use Chill\PersonBundle\Entity\SocialWork\SocialIssue;
|
||||
use Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\SocialIssueFilter;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
/**
|
||||
@ -36,37 +38,31 @@ final class SocialIssueFilterTest extends AbstractFilterTest
|
||||
return $this->filter;
|
||||
}
|
||||
|
||||
public function getFormData(): array
|
||||
public function getFormData(): iterable
|
||||
{
|
||||
self::bootKernel();
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
|
||||
$array = $em->createQueryBuilder()
|
||||
->from(SocialIssue::class, 'si')
|
||||
->select('si')
|
||||
->getQuery()
|
||||
->setMaxResults(1)
|
||||
->getResult();
|
||||
|
||||
$data = [];
|
||||
|
||||
foreach ($array as $i) {
|
||||
$data[] = ['accepted_socialissues' => $i];
|
||||
}
|
||||
|
||||
return $data;
|
||||
yield ['accepted_socialissues' => new ArrayCollection($array)];
|
||||
}
|
||||
|
||||
public function getQueryBuilders(): array
|
||||
{
|
||||
if (null === self::$kernel) {
|
||||
self::bootKernel();
|
||||
}
|
||||
self::bootKernel();
|
||||
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
|
||||
return [
|
||||
$em->createQueryBuilder()
|
||||
->select('acp.id')
|
||||
->from('ChillPersonBundle:AccompanyingPeriod', 'acp'),
|
||||
->from(AccompanyingPeriod::class, 'acp'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -11,9 +11,11 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\PersonBundle\Tests\Export\Filter\AccompanyingCourseFilters;
|
||||
|
||||
use Chill\MainBundle\Service\RollingDate\RollingDate;
|
||||
use Chill\MainBundle\Test\Export\AbstractFilterTest;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\StepFilterOnDate;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
@ -27,7 +29,7 @@ final class StepFilterTest extends AbstractFilterTest
|
||||
{
|
||||
self::bootKernel();
|
||||
|
||||
$this->filter = self::$container->get('chill.person.export.filter_step');
|
||||
$this->filter = self::$container->get(StepFilterOnDate::class);
|
||||
}
|
||||
|
||||
public function getFilter()
|
||||
@ -35,29 +37,29 @@ final class StepFilterTest extends AbstractFilterTest
|
||||
return $this->filter;
|
||||
}
|
||||
|
||||
public function getFormData(): array
|
||||
public function getFormData(): iterable
|
||||
{
|
||||
return [
|
||||
['accepted_steps' => AccompanyingPeriod::STEP_DRAFT],
|
||||
['accepted_steps' => AccompanyingPeriod::STEP_CONFIRMED],
|
||||
['accepted_steps' => AccompanyingPeriod::STEP_CONFIRMED_INACTIVE_LONG],
|
||||
['accepted_steps' => AccompanyingPeriod::STEP_CONFIRMED_INACTIVE_SHORT],
|
||||
['accepted_steps' => AccompanyingPeriod::STEP_CLOSED],
|
||||
];
|
||||
foreach ([
|
||||
['accepted_steps_multi' => [AccompanyingPeriod::STEP_DRAFT]],
|
||||
['accepted_steps_multi' => [AccompanyingPeriod::STEP_CONFIRMED]],
|
||||
['accepted_steps_multi' => [AccompanyingPeriod::STEP_CONFIRMED_INACTIVE_LONG]],
|
||||
['accepted_steps_multi' => [AccompanyingPeriod::STEP_CONFIRMED_INACTIVE_SHORT]],
|
||||
['accepted_steps_multi' => [AccompanyingPeriod::STEP_CLOSED]],
|
||||
] as $d) {
|
||||
yield ['calc_date' => new RollingDate(RollingDate::T_TODAY), ...$d] ;
|
||||
}
|
||||
}
|
||||
|
||||
public function getQueryBuilders(): array
|
||||
{
|
||||
if (null === self::$kernel) {
|
||||
self::bootKernel();
|
||||
}
|
||||
self::bootKernel();
|
||||
|
||||
$em = self::$container->get('doctrine.orm.entity_manager');
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
|
||||
return [
|
||||
$em->createQueryBuilder()
|
||||
->select('acp.id')
|
||||
->from('ChillPersonBundle:AccompanyingPeriod', 'acp'),
|
||||
->from(AccompanyingPeriod::class, 'acp'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -11,15 +11,19 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\PersonBundle\Tests\Export\Filter\AccompanyingCourseFilters;
|
||||
|
||||
use Chill\MainBundle\Entity\UserJob;
|
||||
use Chill\MainBundle\Service\RollingDate\RollingDate;
|
||||
use Chill\MainBundle\Test\Export\AbstractFilterTest;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\UserJobFilter;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @coversNothing
|
||||
*/
|
||||
final class CurrentUserJobFilterTest extends AbstractFilterTest
|
||||
final class UserJobFilterTest extends AbstractFilterTest
|
||||
{
|
||||
private UserJobFilter $filter;
|
||||
|
||||
@ -27,7 +31,7 @@ final class CurrentUserJobFilterTest extends AbstractFilterTest
|
||||
{
|
||||
self::bootKernel();
|
||||
|
||||
$this->filter = self::$container->get('chill.person.export.filter_userjob');
|
||||
$this->filter = self::$container->get(UserJobFilter::class);
|
||||
}
|
||||
|
||||
public function getFilter()
|
||||
@ -35,23 +39,30 @@ final class CurrentUserJobFilterTest extends AbstractFilterTest
|
||||
return $this->filter;
|
||||
}
|
||||
|
||||
public function getFormData(): array
|
||||
public function getFormData(): iterable
|
||||
{
|
||||
return [];
|
||||
self::bootKernel();
|
||||
$jobs = self::$container->get(EntityManagerInterface::class)
|
||||
->createQuery('SELECT j FROM ' . UserJob::class . ' j')
|
||||
->setMaxResults(1)
|
||||
->getResult();
|
||||
|
||||
yield [
|
||||
'jobs' => new ArrayCollection($jobs),
|
||||
'date_calc' => new RollingDate(RollingDate::T_TODAY)
|
||||
];
|
||||
}
|
||||
|
||||
public function getQueryBuilders(): array
|
||||
{
|
||||
if (null === self::$kernel) {
|
||||
self::bootKernel();
|
||||
}
|
||||
self::bootKernel();
|
||||
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
|
||||
return [
|
||||
$em->createQueryBuilder()
|
||||
->select('acp.id')
|
||||
->from('ChillPersonBundle:AccompanyingPeriod', 'acp'),
|
||||
->from(AccompanyingPeriod::class, 'acp'),
|
||||
];
|
||||
}
|
||||
}
|
@ -11,15 +11,19 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\PersonBundle\Tests\Export\Filter\AccompanyingCourseFilters;
|
||||
|
||||
use Chill\MainBundle\Entity\Scope;
|
||||
use Chill\MainBundle\Service\RollingDate\RollingDate;
|
||||
use Chill\MainBundle\Test\Export\AbstractFilterTest;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\UserScopeFilter;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @coversNothing
|
||||
*/
|
||||
final class CurrentUserScopeFilterTest extends AbstractFilterTest
|
||||
final class UserScopeFilterTest extends AbstractFilterTest
|
||||
{
|
||||
private UserScopeFilter $filter;
|
||||
|
||||
@ -27,7 +31,7 @@ final class CurrentUserScopeFilterTest extends AbstractFilterTest
|
||||
{
|
||||
self::bootKernel();
|
||||
|
||||
$this->filter = self::$container->get('chill.person.export.filter_userscope');
|
||||
$this->filter = self::$container->get(UserScopeFilter::class);
|
||||
}
|
||||
|
||||
public function getFilter()
|
||||
@ -37,21 +41,30 @@ final class CurrentUserScopeFilterTest extends AbstractFilterTest
|
||||
|
||||
public function getFormData(): array
|
||||
{
|
||||
return [];
|
||||
self::bootKernel();
|
||||
$scopes = self::$container->get(EntityManagerInterface::class)
|
||||
->createQuery('SELECT s FROM ' . Scope::class . ' s')
|
||||
->setMaxResults(1)
|
||||
->getResult();
|
||||
|
||||
return [
|
||||
[
|
||||
'date_calc' => new RollingDate(RollingDate::T_TODAY),
|
||||
'scopes' => new ArrayCollection($scopes),
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
public function getQueryBuilders(): array
|
||||
{
|
||||
if (null === self::$kernel) {
|
||||
self::bootKernel();
|
||||
}
|
||||
self::bootKernel();
|
||||
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
|
||||
return [
|
||||
$em->createQueryBuilder()
|
||||
->select('acp.id')
|
||||
->from('ChillPersonBundle:AccompanyingPeriod', 'acp'),
|
||||
->from(AccompanyingPeriod::class, 'acp'),
|
||||
];
|
||||
}
|
||||
}
|
@ -39,12 +39,14 @@ final class EvaluationTypeFilterTest extends AbstractFilterTest
|
||||
|
||||
public function getFormData(): array
|
||||
{
|
||||
self::bootKernel();
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
|
||||
$array = $em->createQueryBuilder()
|
||||
->from(Evaluation::class, 'e')
|
||||
->select('e')
|
||||
->getQuery()
|
||||
->setMaxResults(1)
|
||||
->getResult();
|
||||
|
||||
$data = [];
|
||||
@ -60,18 +62,16 @@ final class EvaluationTypeFilterTest extends AbstractFilterTest
|
||||
|
||||
public function getQueryBuilders(): array
|
||||
{
|
||||
if (null === self::$kernel) {
|
||||
self::bootKernel();
|
||||
}
|
||||
self::bootKernel();
|
||||
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
|
||||
return [
|
||||
$em->createQueryBuilder()
|
||||
->select('workeval.id')
|
||||
->select('eval.id')
|
||||
->from(AccompanyingPeriod::class, 'acp')
|
||||
->join('acp.works', 'acpw')
|
||||
->join('acpw.accompanyingPeriodWorkEvaluations', 'workeval'),
|
||||
->join('acpw.accompanyingPeriodWorkEvaluations', 'eval'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -46,9 +46,7 @@ final class MaxDateFilterTest extends AbstractFilterTest
|
||||
|
||||
public function getQueryBuilders(): array
|
||||
{
|
||||
if (null === self::$kernel) {
|
||||
self::bootKernel();
|
||||
}
|
||||
self::bootKernel();
|
||||
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
|
||||
|
@ -11,9 +11,11 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\PersonBundle\Tests\Export\Filter\HouseholdFilters;
|
||||
|
||||
use Chill\MainBundle\Service\RollingDate\RollingDate;
|
||||
use Chill\MainBundle\Test\Export\AbstractFilterTest;
|
||||
use Chill\PersonBundle\Entity\Household\Household;
|
||||
use Chill\PersonBundle\Entity\Household\HouseholdCompositionType;
|
||||
use Chill\PersonBundle\Entity\Person\PersonCenterHistory;
|
||||
use Chill\PersonBundle\Export\Filter\HouseholdFilters\CompositionFilter;
|
||||
use DateTime;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
@ -40,12 +42,14 @@ final class CompositionFilterTest extends AbstractFilterTest
|
||||
|
||||
public function getFormData(): array
|
||||
{
|
||||
self::bootKernel();
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
|
||||
$array = $em->createQueryBuilder()
|
||||
->from(HouseholdCompositionType::class, 'r')
|
||||
->select('r')
|
||||
->getQuery()
|
||||
->setMaxResults(1)
|
||||
->getResult();
|
||||
|
||||
$data = [];
|
||||
@ -53,25 +57,33 @@ final class CompositionFilterTest extends AbstractFilterTest
|
||||
foreach ($array as $r) {
|
||||
$data[] = [
|
||||
'accepted_composition' => $r,
|
||||
'on_date' => DateTime::createFromFormat('Y-m-d', '2022-05-01'),
|
||||
'on_date' => new RollingDate(RollingDate::T_TODAY),
|
||||
];
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function getQueryBuilders(): array
|
||||
public function getQueryBuilders(): iterable
|
||||
{
|
||||
if (null === self::$kernel) {
|
||||
self::bootKernel();
|
||||
}
|
||||
self::bootKernel();
|
||||
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
$qb = $em->createQueryBuilder();
|
||||
$qb
|
||||
->from(Household::class, 'household')
|
||||
->join('household.members', 'hmember')
|
||||
->join('hmember.person', 'person')
|
||||
->join('person.accompanyingPeriodParticipations', 'acppart')
|
||||
->join('acppart.accompanyingPeriod', 'acp')
|
||||
->andWhere('acppart.startDate != acppart.endDate OR acppart.endDate IS NULL')
|
||||
->andWhere('hmember.startDate <= :count_household_at_date AND (hmember.endDate IS NULL OR hmember.endDate > :count_household_at_date)')
|
||||
->setParameter('count_household_at_date', new \DateTimeImmutable('today'));
|
||||
|
||||
return [
|
||||
$em->createQueryBuilder()
|
||||
->select('h.id')
|
||||
->from(Household::class, 'h'),
|
||||
];
|
||||
$qb
|
||||
->select('COUNT(DISTINCT household.id) AS household_export_result')
|
||||
->addSelect('COUNT(DISTINCT acp.id) AS acp_export_result');
|
||||
|
||||
yield $qb;
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\PersonBundle\Tests\Export\Filter\PersonFilters;
|
||||
|
||||
use Chill\MainBundle\Service\RollingDate\RollingDate;
|
||||
use Chill\MainBundle\Test\Export\AbstractFilterTest;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\PersonBundle\Export\Filter\PersonFilters\AgeFilter;
|
||||
@ -43,28 +44,21 @@ final class AgeFilterTest extends AbstractFilterTest
|
||||
[
|
||||
'min_age' => '18',
|
||||
'max_age' => '60',
|
||||
'date_calc' => DateTime::createFromFormat('Y-m-d', '2020-05-01'),
|
||||
],
|
||||
[ // ça devrait faire boum !
|
||||
'min_age' => '35',
|
||||
'max_age' => '30',
|
||||
'date_calc' => DateTime::createFromFormat('Y-m-d', '2020-05-01'),
|
||||
'date_calc' => new RollingDate(RollingDate::T_TODAY),
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function getQueryBuilders(): array
|
||||
{
|
||||
if (null === self::$kernel) {
|
||||
self::bootKernel();
|
||||
}
|
||||
self::bootKernel();
|
||||
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
|
||||
return [
|
||||
$em->createQueryBuilder()
|
||||
->select('p.id')
|
||||
->from(Person::class, 'p'),
|
||||
->select('person.id')
|
||||
->from(Person::class, 'person'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -11,9 +11,12 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\PersonBundle\Tests\Export\Filter\PersonFilters;
|
||||
|
||||
use Chill\MainBundle\Service\RollingDate\RollingDate;
|
||||
use Chill\MainBundle\Test\Export\AbstractFilterTest;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\PersonBundle\Export\Filter\PersonFilters\BirthdateFilter;
|
||||
use DateTime;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
@ -39,35 +42,28 @@ final class BirthdateFilterTest extends AbstractFilterTest
|
||||
{
|
||||
return [
|
||||
[
|
||||
'date_from' => DateTime::createFromFormat('Y-m-d', '2000-01-01'),
|
||||
'date_to' => DateTime::createFromFormat('Y-m-d', '2010-01-01'),
|
||||
'date_from' => new RollingDate(RollingDate::T_YEAR_PREVIOUS_START),
|
||||
'date_to' => new RollingDate(RollingDate::T_TODAY),
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function getQueryBuilders()
|
||||
{
|
||||
if (null === self::$kernel) {
|
||||
self::bootKernel();
|
||||
}
|
||||
self::bootKernel();
|
||||
|
||||
$em = self::$container
|
||||
->get('doctrine.orm.entity_manager');
|
||||
->get(EntityManagerInterface::class);
|
||||
|
||||
return [
|
||||
$em->createQueryBuilder()
|
||||
->select('p.firstName')
|
||||
->from('ChillPersonBundle:Person', 'p'),
|
||||
->select('person.firstName')
|
||||
->from(Person::class, 'person'),
|
||||
$em->createQueryBuilder()
|
||||
->select('p.firstName')
|
||||
->from('ChillPersonBundle:Person', 'p')
|
||||
->select('count(DISTINCT person)')
|
||||
->from(Person::class, 'person')
|
||||
// add a dummy where clause
|
||||
->where('p.firstname IS NOT NULL'),
|
||||
$em->createQueryBuilder()
|
||||
->select('count(IDENTITY(p))')
|
||||
->from('ChillPersonBundle:Person', 'p')
|
||||
// add a dummy where clause
|
||||
->where('p.firstname IS NOT NULL'),
|
||||
->where('person.firstName IS NOT NULL'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\PersonBundle\Tests\Export\Filter\PersonFilters;
|
||||
|
||||
use Chill\MainBundle\Service\RollingDate\RollingDate;
|
||||
use Chill\MainBundle\Test\Export\AbstractFilterTest;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\PersonBundle\Export\Filter\PersonFilters\DeadOrAliveFilter;
|
||||
@ -42,27 +43,25 @@ final class DeadOrAliveFilterTest extends AbstractFilterTest
|
||||
return [
|
||||
[
|
||||
'person_state' => 'alive',
|
||||
'date_calc' => DateTime::createFromFormat('Y-m-d', '2021-05-01'),
|
||||
'date_calc' => new RollingDate(RollingDate::T_TODAY),
|
||||
],
|
||||
[
|
||||
'person_state' => 'deceased',
|
||||
'date_calc' => DateTime::createFromFormat('Y-m-d', '2021-05-01'),
|
||||
'date_calc' => new RollingDate(RollingDate::T_TODAY),
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function getQueryBuilders(): array
|
||||
{
|
||||
if (null === self::$kernel) {
|
||||
self::bootKernel();
|
||||
}
|
||||
self::bootKernel();
|
||||
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
|
||||
return [
|
||||
$em->createQueryBuilder()
|
||||
->select('p.id')
|
||||
->from(Person::class, 'p'),
|
||||
->select('person.id')
|
||||
->from(Person::class, 'person'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\PersonBundle\Tests\Export\Filter\PersonFilters;
|
||||
|
||||
use Chill\MainBundle\Service\RollingDate\RollingDate;
|
||||
use Chill\MainBundle\Test\Export\AbstractFilterTest;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\PersonBundle\Export\Filter\PersonFilters\DeathdateFilter;
|
||||
@ -41,24 +42,22 @@ final class DeathdateFilterTest extends AbstractFilterTest
|
||||
{
|
||||
return [
|
||||
[
|
||||
'date_from' => DateTime::createFromFormat('Y-m-d', '2020-05-01'),
|
||||
'date_to' => DateTime::createFromFormat('Y-m-d', '2022-05-01'),
|
||||
'date_from' => new RollingDate(RollingDate::T_YEAR_PREVIOUS_START),
|
||||
'date_to' => new RollingDate(RollingDate::T_TODAY),
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function getQueryBuilders(): array
|
||||
{
|
||||
if (null === self::$kernel) {
|
||||
self::bootKernel();
|
||||
}
|
||||
self::bootKernel();
|
||||
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
|
||||
return [
|
||||
$em->createQueryBuilder()
|
||||
->select('p.id')
|
||||
->from(Person::class, 'p'),
|
||||
->select('person.id')
|
||||
->from(Person::class, 'person'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ namespace Chill\PersonBundle\Tests\Export\Filter\PersonFilters;
|
||||
use Chill\MainBundle\Test\Export\AbstractFilterTest;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\PersonBundle\Export\Filter\PersonFilters\GenderFilter;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
@ -52,17 +53,15 @@ final class GenderFilterTest extends AbstractFilterTest
|
||||
|
||||
public function getQueryBuilders()
|
||||
{
|
||||
if (null === self::$kernel) {
|
||||
self::bootKernel();
|
||||
}
|
||||
self::bootKernel();
|
||||
|
||||
$em = self::$container
|
||||
->get('doctrine.orm.entity_manager');
|
||||
->get(EntityManagerInterface::class);
|
||||
|
||||
return [
|
||||
$em->createQueryBuilder()
|
||||
->select('p.firstName')
|
||||
->from('ChillPersonBundle:Person', 'p'),
|
||||
->select('person.firstName')
|
||||
->from(Person::class, 'person')
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\PersonBundle\Tests\Export\Filter\PersonFilters;
|
||||
|
||||
use Chill\MainBundle\Service\RollingDate\RollingDate;
|
||||
use Chill\MainBundle\Test\Export\AbstractFilterTest;
|
||||
use Chill\PersonBundle\Entity\MaritalStatus;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
@ -40,12 +41,14 @@ final class MaritalStatusFilterTest extends AbstractFilterTest
|
||||
|
||||
public function getFormData(): array
|
||||
{
|
||||
self::bootKernel();
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
|
||||
$array = $em->createQueryBuilder()
|
||||
->from(MaritalStatus::class, 'm')
|
||||
->select('m')
|
||||
->getQuery()
|
||||
->setMaxResults(1)
|
||||
->getResult();
|
||||
|
||||
$data = [];
|
||||
@ -53,7 +56,6 @@ final class MaritalStatusFilterTest extends AbstractFilterTest
|
||||
foreach ($array as $m) {
|
||||
$data[] = [
|
||||
'maritalStatus' => $m,
|
||||
'calc_date' => DateTime::createFromFormat('Y-m-d', '2022-05-01'),
|
||||
];
|
||||
}
|
||||
|
||||
@ -62,16 +64,14 @@ final class MaritalStatusFilterTest extends AbstractFilterTest
|
||||
|
||||
public function getQueryBuilders(): array
|
||||
{
|
||||
if (null === self::$kernel) {
|
||||
self::bootKernel();
|
||||
}
|
||||
self::bootKernel();
|
||||
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
|
||||
return [
|
||||
$em->createQueryBuilder()
|
||||
->select('p.id')
|
||||
->from(Person::class, 'p'),
|
||||
->select('count(person)')
|
||||
->from(Person::class, 'person'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -39,9 +39,10 @@ final class NationalityFilterTest extends AbstractFilterTest
|
||||
|
||||
public function getFormData(): array
|
||||
{
|
||||
self::bootKernel();
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
|
||||
$countries = $em->getRepository(Country::class)->findAll();
|
||||
$countries = array_slice($em->getRepository(Country::class)->findAll(), 0, 1);
|
||||
|
||||
$data = [];
|
||||
|
||||
@ -56,16 +57,14 @@ final class NationalityFilterTest extends AbstractFilterTest
|
||||
|
||||
public function getQueryBuilders(): array
|
||||
{
|
||||
if (null === self::$kernel) {
|
||||
self::bootKernel();
|
||||
}
|
||||
self::bootKernel();
|
||||
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
|
||||
return [
|
||||
$em->createQueryBuilder()
|
||||
->select('p.id')
|
||||
->from(Person::class, 'p'),
|
||||
->select('count(person)')
|
||||
->from(Person::class, 'person'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\PersonBundle\Tests\Export\Filter\PersonFilters;
|
||||
|
||||
use Chill\MainBundle\Service\RollingDate\RollingDate;
|
||||
use Chill\MainBundle\Test\Export\AbstractFilterTest;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\PersonBundle\Entity\Person\ResidentialAddress;
|
||||
@ -42,20 +43,22 @@ final class ResidentialAddressAtThirdpartyFilterTest extends AbstractFilterTest
|
||||
|
||||
public function getFormData(): array
|
||||
{
|
||||
self::bootKernel();
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
|
||||
$array = $em->createQueryBuilder()
|
||||
->from(ThirdPartyCategory::class, 'tpc')
|
||||
->select('tpc')
|
||||
->getQuery()
|
||||
->setMaxResults(1)
|
||||
->getResult();
|
||||
|
||||
$data = [];
|
||||
|
||||
foreach ($array as $r) {
|
||||
$data[] = [
|
||||
'thirdparty_cat' => $r,
|
||||
'date_calc' => DateTime::createFromFormat('Y-m-d', '2022-05-01'),
|
||||
'thirdparty_cat' => [$r],
|
||||
'date_calc' => new RollingDate(RollingDate::T_TODAY),
|
||||
];
|
||||
}
|
||||
|
||||
@ -64,18 +67,15 @@ final class ResidentialAddressAtThirdpartyFilterTest extends AbstractFilterTest
|
||||
|
||||
public function getQueryBuilders(): array
|
||||
{
|
||||
if (null === self::$kernel) {
|
||||
self::bootKernel();
|
||||
}
|
||||
self::bootKernel();
|
||||
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
|
||||
return [
|
||||
$em->createQueryBuilder()
|
||||
->select('p.id')
|
||||
->from(Person::class, 'p')
|
||||
->join(ResidentialAddress::class, 'resaddr', Expr\Join::WITH, 'resaddr.person = p')
|
||||
->join('p.center', 'center')
|
||||
->select('person.id')
|
||||
->from(Person::class, 'person')
|
||||
->join(ResidentialAddress::class, 'resaddr', Expr\Join::WITH, 'resaddr.person = person')
|
||||
->join('resaddr.hostThirdParty', 'tparty')
|
||||
->join('tparty.categories', 'tpartycat'),
|
||||
];
|
||||
|
@ -11,6 +11,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\PersonBundle\Tests\Export\Filter\PersonFilters;
|
||||
|
||||
use Chill\MainBundle\Service\RollingDate\RollingDate;
|
||||
use Chill\MainBundle\Test\Export\AbstractFilterTest;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\PersonBundle\Export\Filter\PersonFilters\ResidentialAddressAtUserFilter;
|
||||
@ -39,14 +40,14 @@ final class ResidentialAddressAtUserFilterTest extends AbstractFilterTest
|
||||
|
||||
public function getFormData(): array
|
||||
{
|
||||
return [];
|
||||
return [
|
||||
['date_calc' => new RollingDate(RollingDate::T_TODAY)]
|
||||
];
|
||||
}
|
||||
|
||||
public function getQueryBuilders(): array
|
||||
{
|
||||
if (null === self::$kernel) {
|
||||
self::bootKernel();
|
||||
}
|
||||
self::bootKernel();
|
||||
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
|
||||
|
@ -11,8 +11,11 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\PersonBundle\Tests\Export\Filter\SocialWorkFilters;
|
||||
|
||||
use Chill\MainBundle\Entity\UserJob;
|
||||
use Chill\MainBundle\Test\Export\AbstractFilterTest;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork;
|
||||
use Chill\PersonBundle\Export\Filter\SocialWorkFilters\JobFilter;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
/**
|
||||
@ -37,21 +40,30 @@ final class JobFilterTest extends AbstractFilterTest
|
||||
|
||||
public function getFormData(): array
|
||||
{
|
||||
return [];
|
||||
self::bootKernel();
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
|
||||
$jobs = $em->createQuery('SELECT j FROM ' . UserJob::class . ' j')
|
||||
->setMaxResults(1)
|
||||
->getResult();
|
||||
|
||||
return [
|
||||
[
|
||||
'job' => new ArrayCollection($jobs)
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
public function getQueryBuilders(): array
|
||||
{
|
||||
if (null === self::$kernel) {
|
||||
self::bootKernel();
|
||||
}
|
||||
self::bootKernel();
|
||||
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
|
||||
return [
|
||||
$em->createQueryBuilder()
|
||||
->select('acpw.id')
|
||||
->from('ChillPersonBundle:AccompanyingPeriodWork', 'acpw'),
|
||||
->from(AccompanyingPeriodWork::class, 'acpw'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -39,9 +39,10 @@ final class ReferrerFilterTest extends AbstractFilterTest
|
||||
|
||||
public function getFormData(): array
|
||||
{
|
||||
self::bootKernel();
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
|
||||
$users = $em->getRepository(User::class)->findAll();
|
||||
$users = array_slice($em->getRepository(User::class)->findAll(), 0, 1);
|
||||
|
||||
$data = [];
|
||||
|
||||
@ -56,9 +57,7 @@ final class ReferrerFilterTest extends AbstractFilterTest
|
||||
|
||||
public function getQueryBuilders(): array
|
||||
{
|
||||
if (null === self::$kernel) {
|
||||
self::bootKernel();
|
||||
}
|
||||
self::bootKernel();
|
||||
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
|
||||
|
@ -11,7 +11,9 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\PersonBundle\Tests\Export\Filter\SocialWorkFilters;
|
||||
|
||||
use Chill\MainBundle\Entity\Scope;
|
||||
use Chill\MainBundle\Test\Export\AbstractFilterTest;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork;
|
||||
use Chill\PersonBundle\Export\Filter\SocialWorkFilters\ScopeFilter;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
@ -37,21 +39,30 @@ final class ScopeFilterTest extends AbstractFilterTest
|
||||
|
||||
public function getFormData(): array
|
||||
{
|
||||
return [];
|
||||
self::bootKernel();
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
|
||||
$scopes = $em->createQuery('SELECT s FROM ' . Scope::class . ' s')
|
||||
->setMaxResults(1)
|
||||
->getResult();
|
||||
|
||||
return [
|
||||
[
|
||||
'scope' => $scopes
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
public function getQueryBuilders(): array
|
||||
{
|
||||
if (null === self::$kernel) {
|
||||
self::bootKernel();
|
||||
}
|
||||
self::bootKernel();
|
||||
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
|
||||
return [
|
||||
$em->createQueryBuilder()
|
||||
->select('acpw.id')
|
||||
->from('ChillPersonBundle:AccompanyingPeriodWork', 'acpw'),
|
||||
->from(AccompanyingPeriodWork::class, 'acpw'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\ReportBundle\Tests\Export\Filter;
|
||||
|
||||
use Chill\MainBundle\Service\RollingDate\RollingDate;
|
||||
use Chill\MainBundle\Test\Export\AbstractFilterTest;
|
||||
use Chill\ReportBundle\Entity\Report;
|
||||
use Chill\ReportBundle\Export\Filter\ReportDateFilter;
|
||||
@ -29,7 +30,7 @@ final class ReportDateFilterTest extends AbstractFilterTest
|
||||
{
|
||||
self::bootKernel();
|
||||
|
||||
$this->filter = self::$container->get('chill.report.export.filter_date');
|
||||
$this->filter = self::$container->get(ReportDateFilter::class);
|
||||
}
|
||||
|
||||
public function getFilter()
|
||||
@ -41,17 +42,15 @@ final class ReportDateFilterTest extends AbstractFilterTest
|
||||
{
|
||||
return [
|
||||
[
|
||||
'date_from' => DateTime::createFromFormat('Y-m-d', '2021-07-01'),
|
||||
'date_to' => DateTime::createFromFormat('Y-m-d', '2022-07-01'),
|
||||
'date_from' => new RollingDate(RollingDate::T_YEAR_PREVIOUS_START),
|
||||
'date_to' => new RollingDate(RollingDate::T_TODAY),
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function getQueryBuilders(): array
|
||||
{
|
||||
if (null === self::$kernel) {
|
||||
self::bootKernel();
|
||||
}
|
||||
self::bootKernel();
|
||||
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
|
||||
|
@ -53,3 +53,4 @@ CHILL_REPORT_LISTS: Liste des rapports
|
||||
Filter by report's date: Filtrer par date de rapport
|
||||
Report is after this date: Rapports après cette date
|
||||
Report is before this date: Rapports avant cette date
|
||||
"Filtered by report's date: between %date_from% and %date_to%": "Filtré par date du rapport: entre le %date_from% et le %date_to%"
|
||||
|
Loading…
x
Reference in New Issue
Block a user