fix tests implementing AbstractAggregatorTest

This commit is contained in:
Julien Fastré 2023-09-01 15:07:37 +02:00
parent a197a6b418
commit 37c1dfb0ba
Signed by: julienfastre
GPG Key ID: BDE2190974723FCB
53 changed files with 215 additions and 212 deletions

View File

@ -42,6 +42,9 @@
<testsuite name="WopiBundle">
<directory suffix="Test.php">src/Bundle/ChillWopiBundle/tests/</directory>
</testsuite>
<testsuite name="ActivityBundle">
<directory suffix="Test.php">src/Bundle/ChillActivityBundle/Tests/</directory>
</testsuite>
</testsuites>
<listeners>

View File

@ -45,9 +45,7 @@ final class BySocialActionAggregatorTest extends AbstractAggregatorTest
public function getQueryBuilders(): array
{
if (null === self::$kernel) {
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'),
];
}
}

View File

@ -45,18 +45,16 @@ final class BySocialIssueAggregatorTest extends AbstractAggregatorTest
public function getQueryBuilders(): array
{
if (null === self::$kernel) {
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'),
];
}
}

View File

@ -45,9 +45,7 @@ final class ByThirdpartyAggregatorTest extends AbstractAggregatorTest
public function getQueryBuilders(): array
{
if (null === self::$kernel) {
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'),
];
}
}

View File

@ -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();
}
$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'),
];
}
}

View File

@ -53,9 +53,7 @@ final class DateAggregatorTest extends AbstractAggregatorTest
public function getQueryBuilders(): array
{
if (null === self::$kernel) {
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'),
];
}
}

View File

@ -45,9 +45,7 @@ final class LocationTypeAggregatorTest extends AbstractAggregatorTest
public function getQueryBuilders(): array
{
if (null === self::$kernel) {
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'),
];
}
}

View File

@ -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();
}
$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'),
];
}
}

View File

@ -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();
}
$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'),
];
}

View File

@ -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();
}
$em = self::$container->get(EntityManagerInterface::class);
return [
$em->createQueryBuilder()
->select('count(activity.id)')
->from('ChillActivityBundle:Activity', 'activity'),
->from(Activity::class, 'activity'),
];
}
}

View File

@ -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();
}
$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'),
];

View File

@ -52,9 +52,7 @@ final class AgentAggregatorTest extends AbstractAggregatorTest
public function getQueryBuilders(): array
{
if (null === self::$kernel) {
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'),
];
}
}

View File

@ -52,9 +52,7 @@ final class CancelReasonAggregatorTest extends AbstractAggregatorTest
public function getQueryBuilders(): array
{
if (null === self::$kernel) {
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'),
];
}
}

View File

@ -52,9 +52,7 @@ final class JobAggregatorTest extends AbstractAggregatorTest
public function getQueryBuilders(): array
{
if (null === self::$kernel) {
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'),
];
}
}

View File

@ -52,9 +52,7 @@ final class LocationAggregatorTest extends AbstractAggregatorTest
public function getQueryBuilders(): array
{
if (null === self::$kernel) {
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'),
];
}
}

View File

@ -52,9 +52,7 @@ final class LocationTypeAggregatorTest extends AbstractAggregatorTest
public function getQueryBuilders(): array
{
if (null === self::$kernel) {
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'),
];
}
}

View File

@ -52,9 +52,7 @@ final class MonthYearAggregatorTest extends AbstractAggregatorTest
public function getQueryBuilders(): array
{
if (null === self::$kernel) {
self::bootKernel();
}
$em = self::$container->get(EntityManagerInterface::class);

View File

@ -52,9 +52,7 @@ final class ScopeAggregatorTest extends AbstractAggregatorTest
public function getQueryBuilders(): array
{
if (null === self::$kernel) {
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'),
];
}
}

View File

@ -24,8 +24,6 @@ use function is_string;
/**
* Helper which creates a set of test for aggregators.
*
* @internal
*/
abstract class AbstractAggregatorTest extends KernelTestCase
{
@ -34,31 +32,76 @@ 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) {
if ([] === $datas) {
yield [clone $qb, []];
} else {
foreach ($this->getFormData() as $data) {
yield [clone $qb, $data];
}
}
}
}
/**
* provide data for `testAlterQuery`.
*/
public function dataProviderAlterQuery()
{
$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];
}
}
}
}
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];
}
}
}
}
/**
* prepare data for `testGetQueryKeys`.
*/
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,12 +111,22 @@ 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) {
if ([] === $datas) {
yield [clone $qb, []];
} else {
foreach ($datas as $data) {
yield [clone $qb, $data];
}
}
}
}
/**
* Create an aggregator instance which will be used in tests.
@ -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.
*

View File

@ -45,9 +45,7 @@ final class AdministrativeLocationAggregatorTest extends AbstractAggregatorTest
public function getQueryBuilders(): array
{
if (null === self::$kernel) {
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'),
];
}
}

View File

@ -45,9 +45,7 @@ final class ClosingMotiveAggregatorTest extends AbstractAggregatorTest
public function getQueryBuilders(): array
{
if (null === self::$kernel) {
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'),
];
}
}

View File

@ -45,9 +45,7 @@ final class ConfidentialAggregatorTest extends AbstractAggregatorTest
public function getQueryBuilders(): array
{
if (null === self::$kernel) {
self::bootKernel();
}
$em = self::$container->get(EntityManagerInterface::class);

View File

@ -47,9 +47,7 @@ final class DurationAggregatorTest extends AbstractAggregatorTest
public function getQueryBuilders(): array
{
if (null === self::$kernel) {
self::bootKernel();
}
$em = self::$container->get(EntityManagerInterface::class);

View File

@ -45,9 +45,7 @@ final class EmergencyAggregatorTest extends AbstractAggregatorTest
public function getQueryBuilders(): array
{
if (null === self::$kernel) {
self::bootKernel();
}
$em = self::$container->get(EntityManagerInterface::class);

View File

@ -45,9 +45,7 @@ final class EvaluationAggregatorTest extends AbstractAggregatorTest
public function getQueryBuilders(): array
{
if (null === self::$kernel) {
self::bootKernel();
}
$em = self::$container->get(EntityManagerInterface::class);

View File

@ -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]
];
}

View File

@ -45,9 +45,7 @@ final class IntensityAggregatorTest extends AbstractAggregatorTest
public function getQueryBuilders(): array
{
if (null === self::$kernel) {
self::bootKernel();
}
$em = self::$container->get(EntityManagerInterface::class);

View File

@ -45,9 +45,7 @@ final class OriginAggregatorTest extends AbstractAggregatorTest
public function getQueryBuilders(): array
{
if (null === self::$kernel) {
self::bootKernel();
}
$em = self::$container->get(EntityManagerInterface::class);

View File

@ -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();
}
$em = self::$container->get(EntityManagerInterface::class);

View File

@ -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();
}
$em = self::$container->get(EntityManagerInterface::class);

View File

@ -45,9 +45,7 @@ final class RequestorAggregatorTest extends AbstractAggregatorTest
public function getQueryBuilders(): array
{
if (null === self::$kernel) {
self::bootKernel();
}
$em = self::$container->get(EntityManagerInterface::class);

View File

@ -45,9 +45,7 @@ final class ScopeAggregatorTest extends AbstractAggregatorTest
public function getQueryBuilders(): array
{
if (null === self::$kernel) {
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')
];
}
}

View File

@ -45,9 +45,7 @@ final class SocialActionAggregatorTest extends AbstractAggregatorTest
public function getQueryBuilders(): array
{
if (null === self::$kernel) {
self::bootKernel();
}
$em = self::$container->get(EntityManagerInterface::class);

View File

@ -45,9 +45,7 @@ final class SocialIssueAggregatorTest extends AbstractAggregatorTest
public function getQueryBuilders(): array
{
if (null === self::$kernel) {
self::bootKernel();
}
$em = self::$container->get(EntityManagerInterface::class);

View File

@ -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();
}
$em = self::$container->get(EntityManagerInterface::class);

View File

@ -45,9 +45,7 @@ final class UserJobAggregatorTest extends AbstractAggregatorTest
public function getQueryBuilders(): array
{
if (null === self::$kernel) {
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')
];
}
}

View File

@ -45,9 +45,7 @@ final class EvaluationTypeAggregatorTest extends AbstractAggregatorTest
public function getQueryBuilders(): array
{
if (null === self::$kernel) {
self::bootKernel();
}
$em = self::$container->get(EntityManagerInterface::class);

View File

@ -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();
}
$em = self::$container->get(EntityManagerInterface::class);

View File

@ -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();
}
$em = self::$container->get(EntityManagerInterface::class);

View File

@ -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();
}
$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'),
];
}
}

View File

@ -46,9 +46,7 @@ final class CountryOfBirthAggregatorTest extends AbstractAggregatorTest
public function getQueryBuilders(): array
{
if (null === self::$kernel) {
self::bootKernel();
}
$em = self::$container->get(EntityManagerInterface::class);

View File

@ -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();
}
$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'),
];
}
}

View File

@ -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();
}
$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')
];
}
}

View File

@ -45,9 +45,7 @@ final class MaritalStatusAggregatorTest extends AbstractAggregatorTest
public function getQueryBuilders(): array
{
if (null === self::$kernel) {
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')
];
}
}

View File

@ -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();
}
$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'),
];
}
}

View File

@ -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();
}
$em = self::$container
->get('doctrine.orm.entity_manager');
->get(EntityManagerInterface::class);
return [
$em->createQueryBuilder()

View File

@ -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();
}
$em = self::$container
->get('doctrine.orm.entity_manager');
->get(EntityManagerInterface::class);
return [
$em->createQueryBuilder()

View File

@ -45,9 +45,7 @@ final class GoalResultAggregatorTest extends AbstractAggregatorTest
public function getQueryBuilders(): array
{
if (null === self::$kernel) {
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')
];
}
}

View File

@ -45,9 +45,7 @@ final class JobAggregatorTest extends AbstractAggregatorTest
public function getQueryBuilders(): array
{
if (null === self::$kernel) {
self::bootKernel();
}
$em = self::$container->get(EntityManagerInterface::class);

View File

@ -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();
}
$em = self::$container
->get('doctrine.orm.entity_manager');
->get(EntityManagerInterface::class);
return [
$em->createQueryBuilder()

View File

@ -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();
}
$em = self::$container
->get('doctrine.orm.entity_manager');
->get(EntityManagerInterface::class);
return [
$em->createQueryBuilder()

View File

@ -45,9 +45,7 @@ final class ScopeAggregatorTest extends AbstractAggregatorTest
public function getQueryBuilders(): array
{
if (null === self::$kernel) {
self::bootKernel();
}
$em = self::$container->get(EntityManagerInterface::class);

View File

@ -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: