[Export] Feature: create a aggregator for referrer's main scope on

aggregator
This commit is contained in:
2022-10-05 14:57:15 +02:00
parent 491570a21c
commit 8a740a25da
4 changed files with 212 additions and 1 deletions

View File

@@ -0,0 +1,63 @@
<?php
namespace Export\Aggregator\AccompanyingCourseAggregators;
use Chill\MainBundle\Entity\Scope;
use Chill\MainBundle\Repository\ScopeRepositoryInterface;
use Chill\MainBundle\Templating\TranslatableStringHelper;
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\ReferrerScopeAggregator;
use Doctrine\ORM\EntityManagerInterface;
use Prophecy\Argument;
use Prophecy\PhpUnit\ProphecyTrait;
class ReferrerScopeAggregatorTest extends AbstractAggregatorTest
{
use ProphecyTrait;
public function getAggregator()
{
$translatableStringHelper = $this->prophesize(TranslatableStringHelperInterface::class);
$translatableStringHelper->localize(Argument::type('array'))->willReturn('localized');
$scopeRepository = $this->prophesize(ScopeRepositoryInterface::class);
$scopeRepository->find(Argument::type('int'))->willReturn(
(new Scope())->setName(['fr' => 'scope'])
);
return new ReferrerScopeAggregator(
$scopeRepository->reveal(),
$translatableStringHelper->reveal()
);
}
public function getFormData()
{
return [
[
'date_calc' => new \DateTimeImmutable('now')
]
];
}
public function getQueryBuilders()
{
if (null === self::$kernel) {
self::bootKernel();
}
$em = self::$container->get(EntityManagerInterface::class);
return [
$em->createQueryBuilder()
->select('count(acp.id)')
->from(AccompanyingPeriod::class, 'acp')
->join('acp.scopes', 'acpscope')
,
];
}
}