diff --git a/phpunit.xml.dist b/phpunit.xml.dist index ce379b425..0dcf355d3 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -42,6 +42,9 @@ src/Bundle/ChillWopiBundle/tests/ + + src/Bundle/ChillActivityBundle/Tests/ + diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/BySocialActionAggregatorTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/BySocialActionAggregatorTest.php index 7f6c76332..657c9441e 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/BySocialActionAggregatorTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/BySocialActionAggregatorTest.php @@ -45,9 +45,7 @@ final class BySocialActionAggregatorTest extends AbstractAggregatorTest public function getQueryBuilders(): array { - if (null === self::$kernel) { - self::bootKernel(); - } + self::bootKernel(); $em = self::$container->get(EntityManagerInterface::class); @@ -55,8 +53,8 @@ final class BySocialActionAggregatorTest extends AbstractAggregatorTest $em->createQueryBuilder() ->select('count(activity.id)') ->from(Activity::class, 'activity') - ->join('activity.accompanyingPeriod', 'acp') - ->join('activity.socialActions', 'actsocialaction'), + ->leftJoin('activity.accompanyingPeriod', 'acp') + ->leftJoin('activity.socialActions', 'actsocialaction'), ]; } } diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/BySocialIssueAggregatorTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/BySocialIssueAggregatorTest.php index c8374d370..86c999cf3 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/BySocialIssueAggregatorTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/BySocialIssueAggregatorTest.php @@ -45,18 +45,16 @@ final class BySocialIssueAggregatorTest extends AbstractAggregatorTest public function getQueryBuilders(): array { - if (null === self::$kernel) { - self::bootKernel(); - } + self::bootKernel(); $em = self::$container->get(EntityManagerInterface::class); return [ $em->createQueryBuilder() - ->select('count(activity.id)') + ->select('count(activity)') ->from(Activity::class, 'activity') - ->join('activity.accompanyingPeriod', 'acp') - ->join('activity.socialIssues', 'actsocialissue'), + ->leftJoin('activity.accompanyingPeriod', 'acp') + ->leftJoin('activity.socialIssues', 'actsocialissue'), ]; } } diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/ByThirdpartyAggregatorTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/ByThirdpartyAggregatorTest.php index e3bbde25f..4711733ef 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/ByThirdpartyAggregatorTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/ByThirdpartyAggregatorTest.php @@ -45,9 +45,7 @@ final class ByThirdpartyAggregatorTest extends AbstractAggregatorTest public function getQueryBuilders(): array { - if (null === self::$kernel) { - self::bootKernel(); - } + self::bootKernel(); $em = self::$container->get(EntityManagerInterface::class); @@ -55,8 +53,8 @@ final class ByThirdpartyAggregatorTest extends AbstractAggregatorTest $em->createQueryBuilder() ->select('count(activity.id)') ->from(Activity::class, 'activity') - ->join('activity.accompanyingPeriod', 'acp') - ->join('activity.thirdParties', 'acttparty'), + ->leftJoin('activity.accompanyingPeriod', 'acp') + ->leftJoin('activity.thirdParties', 'acttparty'), ]; } } diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/ByUserAggregatorTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/ByUserAggregatorTest.php index ff4f42ec4..44a62e9f8 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/ByUserAggregatorTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/ByUserAggregatorTest.php @@ -28,7 +28,7 @@ final class ByUserAggregatorTest extends AbstractAggregatorTest { self::bootKernel(); - $this->aggregator = self::$container->get('chill.activity.export.byuser_aggregator'); + $this->aggregator = self::$container->get(ByCreatorAggregator::class); } public function getAggregator() @@ -45,9 +45,7 @@ final class ByUserAggregatorTest extends AbstractAggregatorTest public function getQueryBuilders(): array { - if (null === self::$kernel) { - self::bootKernel(); - } + self::bootKernel(); $em = self::$container->get(EntityManagerInterface::class); @@ -55,8 +53,8 @@ final class ByUserAggregatorTest extends AbstractAggregatorTest $em->createQueryBuilder() ->select('count(activity.id)') ->from(Activity::class, 'activity') - ->join('activity.accompanyingPeriod', 'acp') - ->join('activity.users', 'actusers'), + ->leftJoin('activity.accompanyingPeriod', 'acp') + ->leftJoin('activity.users', 'actusers'), ]; } } diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/DateAggregatorTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/DateAggregatorTest.php index feb5ed970..b39a501de 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/DateAggregatorTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/DateAggregatorTest.php @@ -53,9 +53,7 @@ final class DateAggregatorTest extends AbstractAggregatorTest public function getQueryBuilders(): array { - if (null === self::$kernel) { - self::bootKernel(); - } + self::bootKernel(); $em = self::$container->get(EntityManagerInterface::class); @@ -63,7 +61,7 @@ final class DateAggregatorTest extends AbstractAggregatorTest $em->createQueryBuilder() ->select('count(activity.id)') ->from(Activity::class, 'activity') - ->join('activity.accompanyingPeriod', 'acp'), + ->leftJoin('activity.accompanyingPeriod', 'acp'), ]; } } diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/LocationTypeAggregatorTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/LocationTypeAggregatorTest.php index c384eb772..b26008cf9 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/LocationTypeAggregatorTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/LocationTypeAggregatorTest.php @@ -45,9 +45,7 @@ final class LocationTypeAggregatorTest extends AbstractAggregatorTest public function getQueryBuilders(): array { - if (null === self::$kernel) { - self::bootKernel(); - } + self::bootKernel(); $em = self::$container->get(EntityManagerInterface::class); @@ -55,8 +53,8 @@ final class LocationTypeAggregatorTest extends AbstractAggregatorTest $em->createQueryBuilder() ->select('count(activity.id)') ->from(Activity::class, 'activity') - ->join('activity.accompanyingPeriod', 'acp') - ->join('activity.location', 'actloc'), + ->leftJoin('activity.accompanyingPeriod', 'acp') + ->leftJoin('activity.location', 'actloc'), ]; } } diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/UserScopeAggregatorTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/UserScopeAggregatorTest.php index 1265804f9..18f7f9080 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/UserScopeAggregatorTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/UserScopeAggregatorTest.php @@ -28,7 +28,7 @@ final class UserScopeAggregatorTest extends AbstractAggregatorTest { self::bootKernel(); - $this->aggregator = self::$container->get('chill.activity.export.userscope_aggregator'); + $this->aggregator = self::$container->get(CreatorScopeAggregator::class); } public function getAggregator() @@ -45,9 +45,7 @@ final class UserScopeAggregatorTest extends AbstractAggregatorTest public function getQueryBuilders(): array { - if (null === self::$kernel) { - self::bootKernel(); - } + self::bootKernel(); $em = self::$container->get(EntityManagerInterface::class); @@ -55,8 +53,8 @@ final class UserScopeAggregatorTest extends AbstractAggregatorTest $em->createQueryBuilder() ->select('count(activity.id)') ->from(Activity::class, 'activity') - ->join('activity.accompanyingPeriod', 'acp') - ->join('activity.user', 'actuser'), + ->leftJoin('activity.accompanyingPeriod', 'acp') + ->leftJoin('activity.user', 'actuser'), ]; } } diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ActivityTypeAggregatorTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ActivityTypeAggregatorTest.php index 31633b9a3..7fbe4a91d 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ActivityTypeAggregatorTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ActivityTypeAggregatorTest.php @@ -11,6 +11,8 @@ declare(strict_types=1); namespace Chill\ActivityBundle\Tests\Export\Aggregator; +use Chill\ActivityBundle\Entity\Activity; +use Chill\ActivityBundle\Entity\ActivityType; use Chill\ActivityBundle\Export\Aggregator\ActivityTypeAggregator; use Chill\MainBundle\Test\Export\AbstractAggregatorTest; use Doctrine\ORM\EntityManagerInterface; @@ -32,7 +34,7 @@ final class ActivityTypeAggregatorTest extends AbstractAggregatorTest { self::bootKernel(); - $this->aggregator = self::$container->get('chill.activity.export.type_aggregator'); + $this->aggregator = self::$container->get(ActivityTypeAggregator::class); $request = $this->prophesize() ->willExtend(\Symfony\Component\HttpFoundation\Request::class); @@ -57,19 +59,17 @@ final class ActivityTypeAggregatorTest extends AbstractAggregatorTest public function getQueryBuilders() { - if (null === self::$kernel) { - self::bootKernel(); - } + self::bootKernel(); $em = self::$container->get(EntityManagerInterface::class); return [ $em->createQueryBuilder() ->select('count(activity.id)') - ->from('ChillActivityBundle:Activity', 'activity'), + ->from(Activity::class, 'activity'), $em->createQueryBuilder() ->select('count(activity.id)') - ->from('ChillActivityBundle:Activity', 'activity') + ->from(Activity::class, 'activity') ->join('activity.activityType', 'acttype'), ]; } diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ActivityUserAggregatorTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ActivityUserAggregatorTest.php index 06542aa41..a0df16868 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ActivityUserAggregatorTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ActivityUserAggregatorTest.php @@ -11,6 +11,7 @@ declare(strict_types=1); namespace Chill\ActivityBundle\Tests\Export\Aggregator; +use Chill\ActivityBundle\Entity\Activity; use Chill\ActivityBundle\Export\Aggregator\ActivityUserAggregator; use Chill\MainBundle\Test\Export\AbstractAggregatorTest; use Doctrine\ORM\EntityManagerInterface; @@ -57,16 +58,14 @@ final class ActivityUserAggregatorTest extends AbstractAggregatorTest public function getQueryBuilders(): array { - if (null === self::$kernel) { - self::bootKernel(); - } + self::bootKernel(); $em = self::$container->get(EntityManagerInterface::class); return [ $em->createQueryBuilder() ->select('count(activity.id)') - ->from('ChillActivityBundle:Activity', 'activity'), + ->from(Activity::class, 'activity'), ]; } } diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/PersonAggregators/ActivityReasonAggregatorTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/PersonAggregators/ActivityReasonAggregatorTest.php index 0a61e983f..426a3929f 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/PersonAggregators/ActivityReasonAggregatorTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/PersonAggregators/ActivityReasonAggregatorTest.php @@ -11,6 +11,7 @@ declare(strict_types=1); namespace Chill\ActivityBundle\Tests\Export\Aggregator\PersonAggregators; +use Chill\ActivityBundle\Entity\Activity; use Chill\ActivityBundle\Export\Aggregator\PersonAggregators\ActivityReasonAggregator; use Chill\MainBundle\Test\Export\AbstractAggregatorTest; use Doctrine\ORM\EntityManagerInterface; @@ -30,7 +31,7 @@ final class ActivityReasonAggregatorTest extends AbstractAggregatorTest { self::bootKernel(); - $this->aggregator = self::$container->get('chill.activity.export.reason_aggregator'); + $this->aggregator = self::$container->get(ActivityReasonAggregator::class); $request = $this->prophesize() ->willExtend(\Symfony\Component\HttpFoundation\Request::class); @@ -56,23 +57,21 @@ final class ActivityReasonAggregatorTest extends AbstractAggregatorTest public function getQueryBuilders(): array { - if (null === self::$kernel) { - self::bootKernel(); - } + self::bootKernel(); $em = self::$container->get(EntityManagerInterface::class); return [ $em->createQueryBuilder() ->select('count(activity.id)') - ->from('ChillActivityBundle:Activity', 'activity'), + ->from(Activity::class, 'activity'), $em->createQueryBuilder() ->select('count(activity.id)') - ->from('ChillActivityBundle:Activity', 'activity') + ->from(Activity::class, 'activity') ->join('activity.reasons', 'actreasons'), $em->createQueryBuilder() ->select('count(activity.id)') - ->from('ChillActivityBundle:Activity', 'activity') + ->from(Activity::class, 'activity') ->join('activity.reasons', 'actreasons') ->join('actreasons.category', 'actreasoncat'), ]; diff --git a/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/AgentAggregatorTest.php b/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/AgentAggregatorTest.php index 5859b29e1..c1a71218e 100644 --- a/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/AgentAggregatorTest.php +++ b/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/AgentAggregatorTest.php @@ -52,9 +52,7 @@ final class AgentAggregatorTest extends AbstractAggregatorTest public function getQueryBuilders(): array { - if (null === self::$kernel) { - self::bootKernel(); - } + self::bootKernel(); $em = self::$container->get(EntityManagerInterface::class); @@ -62,7 +60,6 @@ final class AgentAggregatorTest extends AbstractAggregatorTest $em->createQueryBuilder() ->select('count(cal.id)') ->from(Calendar::class, 'cal') - ->join('cal.mainUser', 'caluser'), ]; } } diff --git a/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/CancelReasonAggregatorTest.php b/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/CancelReasonAggregatorTest.php index f89ce1c2e..ec769f3b1 100644 --- a/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/CancelReasonAggregatorTest.php +++ b/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/CancelReasonAggregatorTest.php @@ -52,9 +52,7 @@ final class CancelReasonAggregatorTest extends AbstractAggregatorTest public function getQueryBuilders(): array { - if (null === self::$kernel) { - self::bootKernel(); - } + self::bootKernel(); $em = self::$container->get(EntityManagerInterface::class); @@ -62,7 +60,6 @@ final class CancelReasonAggregatorTest extends AbstractAggregatorTest $em->createQueryBuilder() ->select('count(cal.id)') ->from(Calendar::class, 'cal') - ->join('cal.cancelReason', 'calcancel'), ]; } } diff --git a/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/JobAggregatorTest.php b/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/JobAggregatorTest.php index cc697e472..8dda425f7 100644 --- a/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/JobAggregatorTest.php +++ b/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/JobAggregatorTest.php @@ -52,9 +52,7 @@ final class JobAggregatorTest extends AbstractAggregatorTest public function getQueryBuilders(): array { - if (null === self::$kernel) { - self::bootKernel(); - } + self::bootKernel(); $em = self::$container->get(EntityManagerInterface::class); @@ -62,7 +60,6 @@ final class JobAggregatorTest extends AbstractAggregatorTest $em->createQueryBuilder() ->select('count(cal.id)') ->from(Calendar::class, 'cal') - ->join('cal.mainUser', 'caluser'), ]; } } diff --git a/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/LocationAggregatorTest.php b/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/LocationAggregatorTest.php index 72f254d3b..7756c2d69 100644 --- a/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/LocationAggregatorTest.php +++ b/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/LocationAggregatorTest.php @@ -52,9 +52,7 @@ final class LocationAggregatorTest extends AbstractAggregatorTest public function getQueryBuilders(): array { - if (null === self::$kernel) { - self::bootKernel(); - } + self::bootKernel(); $em = self::$container->get(EntityManagerInterface::class); @@ -62,7 +60,6 @@ final class LocationAggregatorTest extends AbstractAggregatorTest $em->createQueryBuilder() ->select('count(cal.id)') ->from(Calendar::class, 'cal') - ->join('cal.location', 'calloc'), ]; } } diff --git a/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/LocationTypeAggregatorTest.php b/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/LocationTypeAggregatorTest.php index 42a1c8809..a69c9d9b1 100644 --- a/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/LocationTypeAggregatorTest.php +++ b/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/LocationTypeAggregatorTest.php @@ -52,9 +52,7 @@ final class LocationTypeAggregatorTest extends AbstractAggregatorTest public function getQueryBuilders(): array { - if (null === self::$kernel) { - self::bootKernel(); - } + self::bootKernel(); $em = self::$container->get(EntityManagerInterface::class); @@ -62,7 +60,6 @@ final class LocationTypeAggregatorTest extends AbstractAggregatorTest $em->createQueryBuilder() ->select('count(cal.id)') ->from(Calendar::class, 'cal') - ->join('cal.location', 'calloc'), ]; } } diff --git a/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/MonthYearAggregatorTest.php b/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/MonthYearAggregatorTest.php index 0c4c0b17e..f2840aa98 100644 --- a/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/MonthYearAggregatorTest.php +++ b/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/MonthYearAggregatorTest.php @@ -52,9 +52,7 @@ final class MonthYearAggregatorTest extends AbstractAggregatorTest public function getQueryBuilders(): array { - if (null === self::$kernel) { - self::bootKernel(); - } + self::bootKernel(); $em = self::$container->get(EntityManagerInterface::class); diff --git a/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/ScopeAggregatorTest.php b/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/ScopeAggregatorTest.php index ea1304381..c9a2b9e5c 100644 --- a/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/ScopeAggregatorTest.php +++ b/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/ScopeAggregatorTest.php @@ -52,9 +52,7 @@ final class ScopeAggregatorTest extends AbstractAggregatorTest public function getQueryBuilders(): array { - if (null === self::$kernel) { - self::bootKernel(); - } + self::bootKernel(); $em = self::$container->get(EntityManagerInterface::class); @@ -62,7 +60,6 @@ final class ScopeAggregatorTest extends AbstractAggregatorTest $em->createQueryBuilder() ->select('count(cal.id)') ->from(Calendar::class, 'cal') - ->join('cal.mainUser', 'caluser'), ]; } } diff --git a/src/Bundle/ChillMainBundle/Test/Export/AbstractAggregatorTest.php b/src/Bundle/ChillMainBundle/Test/Export/AbstractAggregatorTest.php index 99a75582f..e8917b064 100644 --- a/src/Bundle/ChillMainBundle/Test/Export/AbstractAggregatorTest.php +++ b/src/Bundle/ChillMainBundle/Test/Export/AbstractAggregatorTest.php @@ -24,8 +24,6 @@ use function is_string; /** * Helper which creates a set of test for aggregators. - * - * @internal */ abstract class AbstractAggregatorTest extends KernelTestCase { @@ -34,9 +32,19 @@ abstract class AbstractAggregatorTest extends KernelTestCase */ public function dataProviderAliasDidNotDisappears() { + $datas = $this->getFormData(); + + if (!is_array($datas)) { + $datas = iterator_to_array($datas); + } + foreach ($this->getQueryBuilders() as $qb) { - foreach ($this->getFormData() as $data) { - yield [clone $qb, $data]; + if ([] === $datas) { + yield [clone $qb, []]; + } else { + foreach ($this->getFormData() as $data) { + yield [clone $qb, $data]; + } } } } @@ -46,9 +54,38 @@ abstract class AbstractAggregatorTest extends KernelTestCase */ public function dataProviderAlterQuery() { + $datas = $this->getFormData(); + + if (!is_array($datas)) { + $datas = iterator_to_array($datas); + } + foreach ($this->getQueryBuilders() as $qb) { - foreach ($this->getFormData() as $data) { - yield [clone $qb, $data]; + if ([] === $datas) { + yield [clone $qb, []]; + } else { + foreach ($this->getFormData() as $data) { + yield [clone $qb, $data]; + } + } + } + } + + public function dataProviderQueryExecution(): iterable + { + $datas = $this->getFormData(); + + if (!is_array($datas)) { + $datas = iterator_to_array($datas); + } + + foreach ($this->getQueryBuilders() as $qb) { + if ([] === $datas) { + yield [clone $qb, []]; + } else { + foreach ($this->getFormData() as $data) { + yield [clone $qb, $data]; + } } } } @@ -58,7 +95,13 @@ abstract class AbstractAggregatorTest extends KernelTestCase */ public function dataProviderGetQueryKeys() { - foreach ($this->getFormData() as $data) { + $datas = $this->getFormData(); + + if (!is_array($datas)) { + $datas = iterator_to_array($datas); + } + + foreach ($datas as $data) { yield [$data]; } } @@ -68,9 +111,19 @@ abstract class AbstractAggregatorTest extends KernelTestCase */ public function dataProviderGetResultsAndLabels() { + $datas = $this->getFormData(); + + if (!is_array($datas)) { + $datas = iterator_to_array($datas); + } + 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]; + } } } } @@ -129,6 +182,19 @@ abstract class AbstractAggregatorTest extends KernelTestCase } } + /** + * @return void + * @dataProvider dataProviderQueryExecution + */ + public function testQueryExecution(QueryBuilder $qb, array $data): void + { + $this->getAggregator()->alterQuery($qb, $data); + + $actual = $qb->getQuery()->getResult(); + + self::assertIsArray($actual); + } + /** * test the alteration of query by the filter. * diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/AdministrativeLocationAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/AdministrativeLocationAggregatorTest.php index 3528c2e8d..433ed4831 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/AdministrativeLocationAggregatorTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/AdministrativeLocationAggregatorTest.php @@ -45,9 +45,7 @@ final class AdministrativeLocationAggregatorTest extends AbstractAggregatorTest public function getQueryBuilders(): array { - if (null === self::$kernel) { - self::bootKernel(); - } + self::bootKernel(); $em = self::$container->get(EntityManagerInterface::class); @@ -55,7 +53,6 @@ final class AdministrativeLocationAggregatorTest extends AbstractAggregatorTest $em->createQueryBuilder() ->select('count(acp.id)') ->from(AccompanyingPeriod::class, 'acp') - ->join('acp.administrativeLocation', 'acploc'), ]; } } diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/ClosingMotiveAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/ClosingMotiveAggregatorTest.php index f807a7dc5..6393d446d 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/ClosingMotiveAggregatorTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/ClosingMotiveAggregatorTest.php @@ -45,9 +45,7 @@ final class ClosingMotiveAggregatorTest extends AbstractAggregatorTest public function getQueryBuilders(): array { - if (null === self::$kernel) { - self::bootKernel(); - } + self::bootKernel(); $em = self::$container->get(EntityManagerInterface::class); @@ -55,7 +53,6 @@ final class ClosingMotiveAggregatorTest extends AbstractAggregatorTest $em->createQueryBuilder() ->select('count(acp.id)') ->from(AccompanyingPeriod::class, 'acp') - ->join('acp.closingMotive', 'acpmotive'), ]; } } diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/ConfidentialAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/ConfidentialAggregatorTest.php index 479a6b331..2d998841a 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/ConfidentialAggregatorTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/ConfidentialAggregatorTest.php @@ -45,9 +45,7 @@ final class ConfidentialAggregatorTest extends AbstractAggregatorTest public function getQueryBuilders(): array { - if (null === self::$kernel) { - self::bootKernel(); - } + self::bootKernel(); $em = self::$container->get(EntityManagerInterface::class); diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/DurationAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/DurationAggregatorTest.php index 15f4796d2..de3f16811 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/DurationAggregatorTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/DurationAggregatorTest.php @@ -47,9 +47,7 @@ final class DurationAggregatorTest extends AbstractAggregatorTest public function getQueryBuilders(): array { - if (null === self::$kernel) { - self::bootKernel(); - } + self::bootKernel(); $em = self::$container->get(EntityManagerInterface::class); diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/EmergencyAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/EmergencyAggregatorTest.php index 1814ddc76..fb3712521 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/EmergencyAggregatorTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/EmergencyAggregatorTest.php @@ -45,9 +45,7 @@ final class EmergencyAggregatorTest extends AbstractAggregatorTest public function getQueryBuilders(): array { - if (null === self::$kernel) { - self::bootKernel(); - } + self::bootKernel(); $em = self::$container->get(EntityManagerInterface::class); diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/EvaluationAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/EvaluationAggregatorTest.php index e9f129a92..664f9e8a9 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/EvaluationAggregatorTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/EvaluationAggregatorTest.php @@ -45,9 +45,7 @@ final class EvaluationAggregatorTest extends AbstractAggregatorTest public function getQueryBuilders(): array { - if (null === self::$kernel) { - self::bootKernel(); - } + self::bootKernel(); $em = self::$container->get(EntityManagerInterface::class); diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/GeographicalUnitStatAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/GeographicalUnitStatAggregatorTest.php index dc7ccaad7..d4093bcea 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/GeographicalUnitStatAggregatorTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/GeographicalUnitStatAggregatorTest.php @@ -11,6 +11,8 @@ declare(strict_types=1); namespace Chill\PersonBundle\Tests\Export\Aggregator\AccompanyingCourseAggregators; +use Chill\MainBundle\Repository\GeographicalUnitLayerLayerRepository; +use Chill\MainBundle\Service\RollingDate\RollingDate; use Chill\MainBundle\Test\Export\AbstractAggregatorTest; use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\GeographicalUnitStatAggregator; @@ -39,9 +41,12 @@ final class GeographicalUnitStatAggregatorTest extends AbstractAggregatorTest public function getFormData(): array { - // TODO: add geographical unit stat into fixtures and provide a level + self::bootKernel(); + $repository = self::$container->get(GeographicalUnitLayerLayerRepository::class); + $levels = $repository->findAll(); + return [ - ['date_calc' => new DateTimeImmutable('today'), 'level' => null], + ['date_calc' => new RollingDate(RollingDate::T_TODAY), 'level' => $levels] ]; } diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/IntensityAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/IntensityAggregatorTest.php index 5fb341807..c2e55b84d 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/IntensityAggregatorTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/IntensityAggregatorTest.php @@ -45,9 +45,7 @@ final class IntensityAggregatorTest extends AbstractAggregatorTest public function getQueryBuilders(): array { - if (null === self::$kernel) { - self::bootKernel(); - } + self::bootKernel(); $em = self::$container->get(EntityManagerInterface::class); diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/OriginAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/OriginAggregatorTest.php index a8615c1d9..d06df71a2 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/OriginAggregatorTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/OriginAggregatorTest.php @@ -45,9 +45,7 @@ final class OriginAggregatorTest extends AbstractAggregatorTest public function getQueryBuilders(): array { - if (null === self::$kernel) { - self::bootKernel(); - } + self::bootKernel(); $em = self::$container->get(EntityManagerInterface::class); diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/ReferrerAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/ReferrerAggregatorTest.php index e60130a6f..ef99670e3 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/ReferrerAggregatorTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/ReferrerAggregatorTest.php @@ -11,6 +11,7 @@ declare(strict_types=1); namespace Chill\PersonBundle\Tests\Export\Aggregator\AccompanyingCourseAggregators; +use Chill\MainBundle\Service\RollingDate\RollingDate; use Chill\MainBundle\Test\Export\AbstractAggregatorTest; use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\ReferrerAggregator; @@ -40,15 +41,13 @@ final class ReferrerAggregatorTest extends AbstractAggregatorTest public function getFormData(): array { return [ - ['date_calc' => new DateTimeImmutable('now')], + ['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); diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/ReferrerScopeAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/ReferrerScopeAggregatorTest.php index 09d5f99df..6e17b2059 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/ReferrerScopeAggregatorTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/ReferrerScopeAggregatorTest.php @@ -56,16 +56,14 @@ final class ReferrerScopeAggregatorTest extends AbstractAggregatorTest { return [ [ - 'date_calc' => new DateTimeImmutable('now'), + 'date_calc' => new RollingDate(RollingDate::T_TODAY) ], ]; } public function getQueryBuilders() { - if (null === self::$kernel) { - self::bootKernel(); - } + self::bootKernel(); $em = self::$container->get(EntityManagerInterface::class); diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/RequestorAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/RequestorAggregatorTest.php index c1cc710f3..6b03a6716 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/RequestorAggregatorTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/RequestorAggregatorTest.php @@ -45,9 +45,7 @@ final class RequestorAggregatorTest extends AbstractAggregatorTest public function getQueryBuilders(): array { - if (null === self::$kernel) { - self::bootKernel(); - } + self::bootKernel(); $em = self::$container->get(EntityManagerInterface::class); diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/ScopeAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/ScopeAggregatorTest.php index 648577aa9..596ee4342 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/ScopeAggregatorTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/ScopeAggregatorTest.php @@ -45,9 +45,7 @@ final class ScopeAggregatorTest extends AbstractAggregatorTest public function getQueryBuilders(): array { - if (null === self::$kernel) { - self::bootKernel(); - } + self::bootKernel(); $em = self::$container->get(EntityManagerInterface::class); @@ -56,6 +54,9 @@ final class ScopeAggregatorTest extends AbstractAggregatorTest ->select('count(acp.id)') ->from(AccompanyingPeriod::class, 'acp') ->join('acp.scopes', 'acpscope'), + $em->createQueryBuilder() + ->select('count(acp.id)') + ->from(AccompanyingPeriod::class, 'acp') ]; } } diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/SocialActionAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/SocialActionAggregatorTest.php index c0a6fdd79..271303ab7 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/SocialActionAggregatorTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/SocialActionAggregatorTest.php @@ -45,9 +45,7 @@ final class SocialActionAggregatorTest extends AbstractAggregatorTest public function getQueryBuilders(): array { - if (null === self::$kernel) { - self::bootKernel(); - } + self::bootKernel(); $em = self::$container->get(EntityManagerInterface::class); diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/SocialIssueAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/SocialIssueAggregatorTest.php index 3d37aefde..c33c3586b 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/SocialIssueAggregatorTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/SocialIssueAggregatorTest.php @@ -45,9 +45,7 @@ final class SocialIssueAggregatorTest extends AbstractAggregatorTest public function getQueryBuilders(): array { - if (null === self::$kernel) { - self::bootKernel(); - } + self::bootKernel(); $em = self::$container->get(EntityManagerInterface::class); diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/StepAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/StepAggregatorTest.php index 2a51c7fa0..f733e0fab 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/StepAggregatorTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/StepAggregatorTest.php @@ -11,6 +11,7 @@ declare(strict_types=1); namespace Chill\PersonBundle\Tests\Export\Aggregator\AccompanyingCourseAggregators; +use Chill\MainBundle\Service\RollingDate\RollingDate; use Chill\MainBundle\Test\Export\AbstractAggregatorTest; use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\StepAggregator; @@ -41,16 +42,14 @@ final class StepAggregatorTest extends AbstractAggregatorTest { return [ [ - 'on_date' => DateTime::createFromFormat('Y-m-d', '2022-01-01'), + 'on_date' => new RollingDate(RollingDate::T_TODAY) ], ]; } public function getQueryBuilders(): array { - if (null === self::$kernel) { - self::bootKernel(); - } + self::bootKernel(); $em = self::$container->get(EntityManagerInterface::class); diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/UserJobAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/UserJobAggregatorTest.php index 1ed748e32..3b692f782 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/UserJobAggregatorTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/UserJobAggregatorTest.php @@ -45,9 +45,7 @@ final class UserJobAggregatorTest extends AbstractAggregatorTest public function getQueryBuilders(): array { - if (null === self::$kernel) { - self::bootKernel(); - } + self::bootKernel(); $em = self::$container->get(EntityManagerInterface::class); @@ -56,6 +54,9 @@ final class UserJobAggregatorTest extends AbstractAggregatorTest ->select('count(acp.id)') ->from(AccompanyingPeriod::class, 'acp') ->join('acp.job', 'acpjob'), + $em->createQueryBuilder() + ->select('count(acp.id)') + ->from(AccompanyingPeriod::class, 'acp') ]; } } diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/EvaluationAggregators/EvaluationTypeAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/EvaluationAggregators/EvaluationTypeAggregatorTest.php index b6dc51d2a..299a30a5f 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/EvaluationAggregators/EvaluationTypeAggregatorTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/EvaluationAggregators/EvaluationTypeAggregatorTest.php @@ -45,9 +45,7 @@ final class EvaluationTypeAggregatorTest extends AbstractAggregatorTest public function getQueryBuilders(): array { - if (null === self::$kernel) { - self::bootKernel(); - } + self::bootKernel(); $em = self::$container->get(EntityManagerInterface::class); diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/HouseholdAggregators/ChildrenNumberAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/HouseholdAggregators/ChildrenNumberAggregatorTest.php index edba49f90..4611871a5 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/HouseholdAggregators/ChildrenNumberAggregatorTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/HouseholdAggregators/ChildrenNumberAggregatorTest.php @@ -11,6 +11,7 @@ declare(strict_types=1); namespace Chill\PersonBundle\Tests\Export\Aggregator\HouseholdAggregators; +use Chill\MainBundle\Service\RollingDate\RollingDate; use Chill\MainBundle\Test\Export\AbstractAggregatorTest; use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Export\Aggregator\HouseholdAggregators\ChildrenNumberAggregator; @@ -41,16 +42,14 @@ final class ChildrenNumberAggregatorTest extends AbstractAggregatorTest { return [ [ - 'on_date' => DateTime::createFromFormat('Y-m-d', '2022-07-01'), + 'on_date' => new RollingDate(RollingDate::T_TODAY) ], ]; } public function getQueryBuilders(): array { - if (null === self::$kernel) { - self::bootKernel(); - } + self::bootKernel(); $em = self::$container->get(EntityManagerInterface::class); diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/HouseholdAggregators/CompositionAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/HouseholdAggregators/CompositionAggregatorTest.php index 48ff92784..d9dc6ef2b 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/HouseholdAggregators/CompositionAggregatorTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/HouseholdAggregators/CompositionAggregatorTest.php @@ -11,6 +11,7 @@ declare(strict_types=1); namespace Chill\PersonBundle\Tests\Export\Aggregator\HouseholdAggregators; +use Chill\MainBundle\Service\RollingDate\RollingDate; use Chill\MainBundle\Test\Export\AbstractAggregatorTest; use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Export\Aggregator\HouseholdAggregators\CompositionAggregator; @@ -41,16 +42,14 @@ final class CompositionAggregatorTest extends AbstractAggregatorTest { return [ [ - 'on_date' => DateTime::createFromFormat('Y-m-d', '2022-07-01'), + 'on_date' => new RollingDate(RollingDate::T_TODAY) ], ]; } public function getQueryBuilders(): array { - if (null === self::$kernel) { - self::bootKernel(); - } + self::bootKernel(); $em = self::$container->get(EntityManagerInterface::class); diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/PersonAggregators/AgeAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/PersonAggregators/AgeAggregatorTest.php index 42d03e54c..c0b234990 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/PersonAggregators/AgeAggregatorTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/PersonAggregators/AgeAggregatorTest.php @@ -11,9 +11,12 @@ declare(strict_types=1); namespace Chill\PersonBundle\Tests\Export\Aggregator\PersonAggregators; +use Chill\MainBundle\Service\RollingDate\RollingDate; use Chill\MainBundle\Test\Export\AbstractAggregatorTest; +use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Export\Aggregator\PersonAggregators\AgeAggregator; use DateTime; +use Doctrine\ORM\EntityManagerInterface; /** * @internal @@ -39,24 +42,22 @@ final class AgeAggregatorTest extends AbstractAggregatorTest { return [ [ - 'date_age_calculation' => DateTime::createFromFormat('Y-m-d', '2016-06-16'), + 'date_age_calculation' => 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('count(person.id)') - ->from('ChillPersonBundle:Person', 'person'), + ->from(Person::class, 'person'), ]; } } diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/PersonAggregators/CountryOfBirthAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/PersonAggregators/CountryOfBirthAggregatorTest.php index eb8980372..eb6d0b2a9 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/PersonAggregators/CountryOfBirthAggregatorTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/PersonAggregators/CountryOfBirthAggregatorTest.php @@ -46,9 +46,7 @@ final class CountryOfBirthAggregatorTest extends AbstractAggregatorTest public function getQueryBuilders(): array { - if (null === self::$kernel) { - self::bootKernel(); - } + self::bootKernel(); $em = self::$container->get(EntityManagerInterface::class); diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/PersonAggregators/GenderAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/PersonAggregators/GenderAggregatorTest.php index 83b051bee..d5b256362 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/PersonAggregators/GenderAggregatorTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/PersonAggregators/GenderAggregatorTest.php @@ -12,7 +12,9 @@ declare(strict_types=1); namespace Chill\PersonBundle\Tests\Export\Aggregator\PersonAggregators; use Chill\MainBundle\Test\Export\AbstractAggregatorTest; +use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Export\Aggregator\PersonAggregators\GenderAggregator; +use Doctrine\ORM\EntityManagerInterface; /** * @internal @@ -43,17 +45,15 @@ final class GenderAggregatorTest extends AbstractAggregatorTest 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('count(person.id)') - ->from('ChillPersonBundle:Person', 'person'), + ->from(Person::class, 'person'), ]; } } diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/PersonAggregators/HouseholdPositionAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/PersonAggregators/HouseholdPositionAggregatorTest.php index 393a00bfe..609e95bfb 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/PersonAggregators/HouseholdPositionAggregatorTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/PersonAggregators/HouseholdPositionAggregatorTest.php @@ -11,6 +11,7 @@ declare(strict_types=1); namespace Chill\PersonBundle\Tests\Export\Aggregator\PersonAggregators; +use Chill\MainBundle\Service\RollingDate\RollingDate; use Chill\MainBundle\Test\Export\AbstractAggregatorTest; use Chill\PersonBundle\Entity\Household\HouseholdMember; use Chill\PersonBundle\Entity\Person; @@ -43,16 +44,14 @@ final class HouseholdPositionAggregatorTest extends AbstractAggregatorTest { return [ [ - 'date_position' => DateTime::createFromFormat('Y-m-d', '2022-07-01'), + 'date_position' => new RollingDate(RollingDate::T_TODAY) ], ]; } public function getQueryBuilders(): array { - if (null === self::$kernel) { - self::bootKernel(); - } + self::bootKernel(); $em = self::$container->get(EntityManagerInterface::class); @@ -60,8 +59,10 @@ final class HouseholdPositionAggregatorTest extends AbstractAggregatorTest $em->createQueryBuilder() ->select('count(person.id)') ->from(Person::class, 'person') - ->join(HouseholdMember::class, 'householdmember', Expr\Join::WITH, 'householdmember.person = person') - ->join('person.center', 'center'), + ->join(HouseholdMember::class, 'householdmember', Expr\Join::WITH, 'householdmember.person = person'), + $em->createQueryBuilder() + ->select('count(person.id)') + ->from(Person::class, 'person') ]; } } diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/PersonAggregators/MaritalStatusAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/PersonAggregators/MaritalStatusAggregatorTest.php index e379fd09a..1dc66e0ae 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/PersonAggregators/MaritalStatusAggregatorTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/PersonAggregators/MaritalStatusAggregatorTest.php @@ -45,9 +45,7 @@ final class MaritalStatusAggregatorTest extends AbstractAggregatorTest public function getQueryBuilders(): array { - if (null === self::$kernel) { - self::bootKernel(); - } + self::bootKernel(); $em = self::$container->get(EntityManagerInterface::class); @@ -56,6 +54,9 @@ final class MaritalStatusAggregatorTest extends AbstractAggregatorTest ->select('count(person.id)') ->from(Person::class, 'person') ->join('person.maritalStatus', 'personmarital'), + $em->createQueryBuilder() + ->select('count(person.id)') + ->from(Person::class, 'person') ]; } } diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/PersonAggregators/NationalityAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/PersonAggregators/NationalityAggregatorTest.php index 0c93be59c..5e27b13d1 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/PersonAggregators/NationalityAggregatorTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/PersonAggregators/NationalityAggregatorTest.php @@ -12,7 +12,9 @@ declare(strict_types=1); namespace Chill\PersonBundle\Tests\Export\Aggregator\PersonAggregators; use Chill\MainBundle\Test\Export\AbstractAggregatorTest; +use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Export\Aggregator\PersonAggregators\NationalityAggregator; +use Doctrine\ORM\EntityManagerInterface; /** * @internal @@ -44,17 +46,15 @@ final class NationalityAggregatorTest extends AbstractAggregatorTest 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('count(person.id)') - ->from('ChillPersonBundle:Person', 'person'), + ->from(Person::class, 'person'), ]; } } diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/ActionTypeAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/ActionTypeAggregatorTest.php index 79eda3f4c..f6d3d5b8c 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/ActionTypeAggregatorTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/ActionTypeAggregatorTest.php @@ -14,6 +14,7 @@ namespace Chill\PersonBundle\Tests\Export\Aggregator\SocialWorkAggregators; use Chill\MainBundle\Test\Export\AbstractAggregatorTest; use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork; use Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators\ActionTypeAggregator; +use Doctrine\ORM\EntityManagerInterface; /** * @internal @@ -44,12 +45,10 @@ final class ActionTypeAggregatorTest extends AbstractAggregatorTest public function getQueryBuilders(): array { - if (null === self::$kernel) { - self::bootKernel(); - } + self::bootKernel(); $em = self::$container - ->get('doctrine.orm.entity_manager'); + ->get(EntityManagerInterface::class); return [ $em->createQueryBuilder() diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/GoalAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/GoalAggregatorTest.php index 356e9b0e0..45a586c32 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/GoalAggregatorTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/GoalAggregatorTest.php @@ -14,6 +14,7 @@ namespace Chill\PersonBundle\Tests\Export\Aggregator\SocialWorkAggregators; use Chill\MainBundle\Test\Export\AbstractAggregatorTest; use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork; use Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators\GoalAggregator; +use Doctrine\ORM\EntityManagerInterface; /** * @internal @@ -44,12 +45,10 @@ final class GoalAggregatorTest extends AbstractAggregatorTest public function getQueryBuilders(): array { - if (null === self::$kernel) { - self::bootKernel(); - } + self::bootKernel(); $em = self::$container - ->get('doctrine.orm.entity_manager'); + ->get(EntityManagerInterface::class); return [ $em->createQueryBuilder() diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/GoalResultAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/GoalResultAggregatorTest.php index a32a7f396..52493e786 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/GoalResultAggregatorTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/GoalResultAggregatorTest.php @@ -45,9 +45,7 @@ final class GoalResultAggregatorTest extends AbstractAggregatorTest public function getQueryBuilders(): array { - if (null === self::$kernel) { - self::bootKernel(); - } + self::bootKernel(); $em = self::$container->get(EntityManagerInterface::class); @@ -58,6 +56,11 @@ final class GoalResultAggregatorTest extends AbstractAggregatorTest ->join('acp.works', 'acpw') ->join('acpw.goals', 'goal') ->join('goal.results', 'goalresult'), + $em->createQueryBuilder() + ->select('count(acp.id)') + ->from(AccompanyingPeriod::class, 'acp') + ->join('acp.works', 'acpw') + ->join('acpw.goals', 'goal') ]; } } diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/JobAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/JobAggregatorTest.php index 0b5b4af60..39cc20083 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/JobAggregatorTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/JobAggregatorTest.php @@ -45,9 +45,7 @@ final class JobAggregatorTest extends AbstractAggregatorTest public function getQueryBuilders(): array { - if (null === self::$kernel) { - self::bootKernel(); - } + self::bootKernel(); $em = self::$container->get(EntityManagerInterface::class); diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/ReferrerAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/ReferrerAggregatorTest.php index 24b01de26..21f185469 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/ReferrerAggregatorTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/ReferrerAggregatorTest.php @@ -14,6 +14,7 @@ namespace Chill\PersonBundle\Tests\Export\Aggregator\SocialWorkAggregators; use Chill\MainBundle\Test\Export\AbstractAggregatorTest; use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork; use Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators\ReferrerAggregator; +use Doctrine\ORM\EntityManagerInterface; /** * @internal @@ -27,7 +28,7 @@ final class ReferrerAggregatorTest extends AbstractAggregatorTest { self::bootKernel(); - $this->aggregator = self::$container->get('chill.person.export.aggregator_referrer'); + $this->aggregator = self::$container->get(ReferrerAggregator::class); } public function getAggregator() @@ -44,12 +45,10 @@ final class ReferrerAggregatorTest extends AbstractAggregatorTest public function getQueryBuilders(): array { - if (null === self::$kernel) { - self::bootKernel(); - } + self::bootKernel(); $em = self::$container - ->get('doctrine.orm.entity_manager'); + ->get(EntityManagerInterface::class); return [ $em->createQueryBuilder() diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/ResultAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/ResultAggregatorTest.php index 9df19d7d2..dee9e3785 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/ResultAggregatorTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/ResultAggregatorTest.php @@ -14,6 +14,7 @@ namespace Chill\PersonBundle\Tests\Export\Aggregator\SocialWorkAggregators; use Chill\MainBundle\Test\Export\AbstractAggregatorTest; use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork; use Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators\ResultAggregator; +use Doctrine\ORM\EntityManagerInterface; /** * @internal @@ -44,12 +45,10 @@ final class ResultAggregatorTest extends AbstractAggregatorTest public function getQueryBuilders(): array { - if (null === self::$kernel) { - self::bootKernel(); - } + self::bootKernel(); $em = self::$container - ->get('doctrine.orm.entity_manager'); + ->get(EntityManagerInterface::class); return [ $em->createQueryBuilder() diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/ScopeAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/ScopeAggregatorTest.php index 875b40e3f..9a31d88bc 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/ScopeAggregatorTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/ScopeAggregatorTest.php @@ -45,9 +45,7 @@ final class ScopeAggregatorTest extends AbstractAggregatorTest public function getQueryBuilders(): array { - if (null === self::$kernel) { - self::bootKernel(); - } + self::bootKernel(); $em = self::$container->get(EntityManagerInterface::class); diff --git a/src/Bundle/ChillPersonBundle/config/services/exports_social_actions.yaml b/src/Bundle/ChillPersonBundle/config/services/exports_social_actions.yaml index 5f6c2690d..c0e6abc4b 100644 --- a/src/Bundle/ChillPersonBundle/config/services/exports_social_actions.yaml +++ b/src/Bundle/ChillPersonBundle/config/services/exports_social_actions.yaml @@ -82,8 +82,7 @@ services: tags: - { name: chill.export_aggregator, alias: social_work_actions_treatingagent_job_aggregator } - chill.person.export.aggregator_treatingagent: - class: Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators\ReferrerAggregator + Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators\ReferrerAggregator: autowire: true autoconfigure: true tags: