Merge branch '179-remove-filter-by-center-in-exports' into 'master'

Resolve "Export: permettre de ne pas filtrer les résultats par centre"

Closes #179

See merge request Chill-Projet/chill-bundles!599
This commit is contained in:
2023-10-24 13:18:03 +00:00
48 changed files with 1168 additions and 412 deletions

View File

@@ -11,8 +11,8 @@ declare(strict_types=1);
namespace Chill\ActivityBundle\Export\Export\LinkedToACP;
use Chill\ActivityBundle\Entity\Activity;
use Chill\ActivityBundle\Export\Declarations;
use Chill\ActivityBundle\Repository\ActivityRepository;
use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter;
use Chill\MainBundle\Export\AccompanyingCourseExportHelper;
use Chill\MainBundle\Export\ExportInterface;
@@ -21,19 +21,19 @@ use Chill\MainBundle\Export\GroupedExportInterface;
use Chill\PersonBundle\Entity\AccompanyingPeriodParticipation;
use Chill\PersonBundle\Entity\Person\PersonCenterHistory;
use Chill\PersonBundle\Export\Declarations as PersonDeclarations;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\Query;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\Form\FormBuilderInterface;
class AvgActivityDuration implements ExportInterface, GroupedExportInterface
{
protected EntityRepository $repository;
private readonly bool $filterStatsByCenters;
public function __construct(
EntityManagerInterface $em,
private readonly ActivityRepository $activityRepository,
ParameterBagInterface $parameterBag,
) {
$this->repository = $em->getRepository(Activity::class);
$this->filterStatsByCenters = $parameterBag->get('chill_main')['acl']['filter_stats_by_center'];
}
public function buildForm(FormBuilderInterface $builder) {}
@@ -91,23 +91,25 @@ class AvgActivityDuration implements ExportInterface, GroupedExportInterface
{
$centers = array_map(static fn ($el) => $el['center'], $acl);
$qb = $this->repository->createQueryBuilder('activity');
$qb = $this->activityRepository->createQueryBuilder('activity');
$qb
->join('activity.accompanyingPeriod', 'acp')
->select('AVG(activity.durationTime) as export_avg_activity_duration')
->andWhere($qb->expr()->isNotNull('activity.durationTime'));
$qb
->andWhere(
$qb->expr()->exists(
'SELECT 1 FROM '.AccompanyingPeriodParticipation::class.' acl_count_part
if ($this->filterStatsByCenters) {
$qb
->andWhere(
$qb->expr()->exists(
'SELECT 1 FROM '.AccompanyingPeriodParticipation::class.' acl_count_part
JOIN '.PersonCenterHistory::class.' acl_count_person_history WITH IDENTITY(acl_count_person_history.person) = IDENTITY(acl_count_part.person)
WHERE acl_count_part.accompanyingPeriod = acp.id AND acl_count_person_history.center IN (:authorized_centers)
'
)
)
)
->setParameter('authorized_centers', $centers);
->setParameter('authorized_centers', $centers);
}
AccompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb);

View File

@@ -24,16 +24,21 @@ use Chill\PersonBundle\Export\Declarations as PersonDeclarations;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\Query;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\Form\FormBuilderInterface;
class AvgActivityVisitDuration implements ExportInterface, GroupedExportInterface
{
protected EntityRepository $repository;
private readonly bool $filterStatsByCenters;
public function __construct(
EntityManagerInterface $em,
ParameterBagInterface $parameterBag,
) {
$this->repository = $em->getRepository(Activity::class);
$this->filterStatsByCenters = $parameterBag->get('chill_main')['acl']['filter_stats_by_center'];
}
public function buildForm(FormBuilderInterface $builder)
@@ -101,16 +106,18 @@ class AvgActivityVisitDuration implements ExportInterface, GroupedExportInterfac
->select('AVG(activity.travelTime) as export_avg_activity_visit_duration')
->andWhere($qb->expr()->isNotNull('activity.travelTime'));
$qb
->andWhere(
$qb->expr()->exists(
'SELECT 1 FROM '.AccompanyingPeriodParticipation::class.' acl_count_part
if ($this->filterStatsByCenters) {
$qb
->andWhere(
$qb->expr()->exists(
'SELECT 1 FROM '.AccompanyingPeriodParticipation::class.' acl_count_part
JOIN '.PersonCenterHistory::class.' acl_count_person_history WITH IDENTITY(acl_count_person_history.person) = IDENTITY(acl_count_part.person)
WHERE acl_count_part.accompanyingPeriod = acp.id AND acl_count_person_history.center IN (:authorized_centers)
'
)
)
)
->setParameter('authorized_centers', $centers);
->setParameter('authorized_centers', $centers);
}
AccompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb);

View File

@@ -24,16 +24,21 @@ use Chill\PersonBundle\Export\Declarations as PersonDeclarations;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\Query;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\Form\FormBuilderInterface;
class CountActivity implements ExportInterface, GroupedExportInterface
{
protected EntityRepository $repository;
private readonly bool $filterStatsByCenters;
public function __construct(
EntityManagerInterface $em,
ParameterBagInterface $parameterBag,
) {
$this->repository = $em->getRepository(Activity::class);
$this->filterStatsByCenters = $parameterBag->get('chill_main')['acl']['filter_stats_by_center'];
}
public function buildForm(FormBuilderInterface $builder) {}
@@ -95,16 +100,18 @@ class CountActivity implements ExportInterface, GroupedExportInterface
->createQueryBuilder('activity')
->join('activity.accompanyingPeriod', 'acp');
$qb
->andWhere(
$qb->expr()->exists(
'SELECT 1 FROM '.AccompanyingPeriodParticipation::class.' acl_count_part
if ($this->filterStatsByCenters) {
$qb
->andWhere(
$qb->expr()->exists(
'SELECT 1 FROM '.AccompanyingPeriodParticipation::class.' acl_count_part
JOIN '.PersonCenterHistory::class.' acl_count_person_history WITH IDENTITY(acl_count_person_history.person) = IDENTITY(acl_count_part.person)
WHERE acl_count_part.accompanyingPeriod = acp.id AND acl_count_person_history.center IN (:authorized_centers)
'
)
)
)
->setParameter('authorized_centers', $centers);
->setParameter('authorized_centers', $centers);
}
AccompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb);

View File

@@ -22,11 +22,21 @@ use Chill\MainBundle\Export\Helper\TranslatableStringExportLabelHelper;
use Chill\MainBundle\Export\ListInterface;
use Chill\PersonBundle\Entity\Person\PersonCenterHistory;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\Form\FormBuilderInterface;
class ListActivity implements ListInterface, GroupedExportInterface
{
public function __construct(private readonly ListActivityHelper $helper, private readonly EntityManagerInterface $entityManager, private readonly TranslatableStringExportLabelHelper $translatableStringExportLabelHelper) {}
private readonly bool $filterStatsByCenters;
public function __construct(
private readonly ListActivityHelper $helper,
private readonly EntityManagerInterface $entityManager,
private readonly TranslatableStringExportLabelHelper $translatableStringExportLabelHelper,
ParameterBagInterface $parameterBag,
) {
$this->filterStatsByCenters = $parameterBag->get('chill_main')['acl']['filter_stats_by_center'];
}
public function buildForm(FormBuilderInterface $builder)
{
@@ -107,21 +117,27 @@ class ListActivity implements ListInterface, GroupedExportInterface
->join('activity.accompanyingPeriod', 'acp')
->leftJoin('acp.participations', 'acppart')
->leftJoin('acppart.person', 'person')
->andWhere('acppart.startDate != acppart.endDate OR acppart.endDate IS NULL')
->andWhere(
$qb->expr()->exists(
'SELECT 1
->andWhere('acppart.startDate != acppart.endDate OR acppart.endDate IS NULL');
if ($this->filterStatsByCenters) {
$qb
->andWhere(
$qb->expr()->exists(
'SELECT 1
FROM '.PersonCenterHistory::class.' acl_count_person_history
WHERE acl_count_person_history.person = person
AND acl_count_person_history.center IN (:authorized_centers)
'
)
)
)
->setParameter('authorized_centers', $centers);
}
$qb
// some grouping are necessary
->addGroupBy('acp.id')
->addOrderBy('activity.date')
->addOrderBy('activity.id')
->setParameter('authorized_centers', $centers);
->addOrderBy('activity.id');
$this->helper->addSelect($qb);

View File

@@ -24,16 +24,20 @@ use Chill\PersonBundle\Export\Declarations as PersonDeclarations;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\Query;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\Form\FormBuilderInterface;
class SumActivityDuration implements ExportInterface, GroupedExportInterface
{
protected EntityRepository $repository;
private readonly bool $filterStatsByCenters;
public function __construct(
EntityManagerInterface $em,
ParameterBagInterface $parameterBag,
) {
$this->repository = $em->getRepository(Activity::class);
$this->filterStatsByCenters = $parameterBag->get('chill_main')['acl']['filter_stats_by_center'];
}
public function buildForm(FormBuilderInterface $builder)
@@ -101,16 +105,18 @@ class SumActivityDuration implements ExportInterface, GroupedExportInterface
$qb->select('SUM(activity.durationTime) as export_sum_activity_duration')
->andWhere($qb->expr()->isNotNull('activity.durationTime'));
$qb
->andWhere(
$qb->expr()->exists(
'SELECT 1 FROM '.AccompanyingPeriodParticipation::class.' acl_count_part
if ($this->filterStatsByCenters) {
$qb
->andWhere(
$qb->expr()->exists(
'SELECT 1 FROM '.AccompanyingPeriodParticipation::class.' acl_count_part
JOIN '.PersonCenterHistory::class.' acl_count_person_history WITH IDENTITY(acl_count_person_history.person) = IDENTITY(acl_count_part.person)
WHERE acl_count_part.accompanyingPeriod = acp.id AND acl_count_person_history.center IN (:authorized_centers)
'
)
)
)
->setParameter('authorized_centers', $centers);
->setParameter('authorized_centers', $centers);
}
AccompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb);

View File

@@ -24,16 +24,20 @@ use Chill\PersonBundle\Export\Declarations as PersonDeclarations;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\Query;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\Form\FormBuilderInterface;
class SumActivityVisitDuration implements ExportInterface, GroupedExportInterface
{
protected EntityRepository $repository;
private readonly bool $filterStatsByCenters;
public function __construct(
EntityManagerInterface $em,
ParameterBagInterface $parameterBag,
) {
$this->repository = $em->getRepository(Activity::class);
$this->filterStatsByCenters = $parameterBag->get('chill_main')['acl']['filter_stats_by_center'];
}
public function buildForm(FormBuilderInterface $builder)
@@ -101,16 +105,18 @@ class SumActivityVisitDuration implements ExportInterface, GroupedExportInterfac
$qb->select('SUM(activity.travelTime) as export_sum_activity_visit_duration')
->andWhere($qb->expr()->isNotNull('activity.travelTime'));
$qb
->andWhere(
$qb->expr()->exists(
'SELECT 1 FROM '.AccompanyingPeriodParticipation::class.' acl_count_part
if ($this->filterStatsByCenters) {
$qb
->andWhere(
$qb->expr()->exists(
'SELECT 1 FROM '.AccompanyingPeriodParticipation::class.' acl_count_part
JOIN '.PersonCenterHistory::class.' acl_count_person_history WITH IDENTITY(acl_count_person_history.person) = IDENTITY(acl_count_part.person)
WHERE acl_count_part.accompanyingPeriod = acp.id AND acl_count_person_history.center IN (:authorized_centers)
'
)
)
)
->setParameter('authorized_centers', $centers);
->setParameter('authorized_centers', $centers);
}
AccompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb);

View File

@@ -19,11 +19,19 @@ use Chill\MainBundle\Export\FormatterInterface;
use Chill\MainBundle\Export\GroupedExportInterface;
use Chill\PersonBundle\Export\Declarations as PersonDeclarations;
use Doctrine\ORM\Query;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\Form\FormBuilderInterface;
class CountActivity implements ExportInterface, GroupedExportInterface
{
public function __construct(protected ActivityRepository $activityRepository) {}
private readonly bool $filterStatsByCenters;
public function __construct(
private readonly ActivityRepository $activityRepository,
ParameterBagInterface $parameterBag,
) {
$this->filterStatsByCenters = $parameterBag->get('chill_main')['acl']['filter_stats_by_center'];
}
public function buildForm(FormBuilderInterface $builder) {}
@@ -82,23 +90,25 @@ class CountActivity implements ExportInterface, GroupedExportInterface
$qb = $this->activityRepository
->createQueryBuilder('activity')
->join('activity.person', 'person')
->join('person.centerHistory', 'centerHistory');
->join('activity.person', 'person');
$qb->select('COUNT(activity.id) as export_count_activity');
$qb
->where(
$qb->expr()->andX(
$qb->expr()->lte('centerHistory.startDate', 'activity.date'),
$qb->expr()->orX(
$qb->expr()->isNull('centerHistory.endDate'),
$qb->expr()->gt('centerHistory.endDate', 'activity.date')
if ($this->filterStatsByCenters) {
$qb
->join('person.centerHistory', 'centerHistory')
->where(
$qb->expr()->andX(
$qb->expr()->lte('centerHistory.startDate', 'activity.date'),
$qb->expr()->orX(
$qb->expr()->isNull('centerHistory.endDate'),
$qb->expr()->gt('centerHistory.endDate', 'activity.date')
)
)
)
)
->andWhere($qb->expr()->in('centerHistory.center', ':centers'))
->setParameter('centers', $centers);
->andWhere($qb->expr()->in('centerHistory.center', ':centers'))
->setParameter('centers', $centers);
}
return $qb;
}

View File

@@ -23,6 +23,7 @@ use Chill\PersonBundle\Export\Declarations as PersonDeclarations;
use Doctrine\DBAL\Exception\InvalidArgumentException;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Query;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Validator\Constraints\Callback;
@@ -44,8 +45,17 @@ class ListActivity implements ListInterface, GroupedExportInterface
'person_lastname',
'person_id',
];
private readonly bool $filterStatsByCenters;
public function __construct(protected EntityManagerInterface $entityManager, protected TranslatorInterface $translator, protected TranslatableStringHelperInterface $translatableStringHelper, private readonly ActivityRepository $activityRepository) {}
public function __construct(
protected EntityManagerInterface $entityManager,
protected TranslatorInterface $translator,
protected TranslatableStringHelperInterface $translatableStringHelper,
private readonly ActivityRepository $activityRepository,
ParameterBagInterface $parameterBag,
) {
$this->filterStatsByCenters = $parameterBag->get('chill_main')['acl']['filter_stats_by_center'];
}
public function buildForm(FormBuilderInterface $builder)
{
@@ -188,20 +198,22 @@ class ListActivity implements ListInterface, GroupedExportInterface
$qb
->from('ChillActivityBundle:Activity', 'activity')
->join('activity.person', 'actperson')
->join('actperson.centerHistory', 'centerHistory');
->join('activity.person', 'actperson');
$qb->where(
$qb->expr()->andX(
$qb->expr()->lte('centerHistory.startDate', 'activity.date'),
$qb->expr()->orX(
$qb->expr()->isNull('centerHistory.endDate'),
$qb->expr()->gt('centerHistory.endDate', 'activity.date')
if ($this->filterStatsByCenters) {
$qb->join('actperson.centerHistory', 'centerHistory');
$qb->where(
$qb->expr()->andX(
$qb->expr()->lte('centerHistory.startDate', 'activity.date'),
$qb->expr()->orX(
$qb->expr()->isNull('centerHistory.endDate'),
$qb->expr()->gt('centerHistory.endDate', 'activity.date')
)
)
)
)
->andWhere($qb->expr()->in('centerHistory.center', ':centers'))
->setParameter('centers', $centers);
->andWhere($qb->expr()->in('centerHistory.center', ':centers'))
->setParameter('centers', $centers);
}
foreach ($this->fields as $f) {
if (\in_array($f, $data['fields'], true)) {

View File

@@ -20,6 +20,7 @@ use Chill\MainBundle\Export\FormatterInterface;
use Chill\MainBundle\Export\GroupedExportInterface;
use Chill\PersonBundle\Export\Declarations as PersonDeclarations;
use Doctrine\ORM\Query;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\Form\FormBuilderInterface;
/**
@@ -30,17 +31,21 @@ use Symfony\Component\Form\FormBuilderInterface;
class StatActivityDuration implements ExportInterface, GroupedExportInterface
{
final public const SUM = 'sum';
private readonly bool $filterStatsByCenters;
/**
* @param string $action the stat to perform
*/
public function __construct(
private readonly ActivityRepository $activityRepository,
ParameterBagInterface $parameterBag,
/**
* The action for this report.
*/
protected string $action = 'sum'
) {}
) {
$this->filterStatsByCenters = $parameterBag->get('chill_main')['acl']['filter_stats_by_center'];
}
public function buildForm(FormBuilderInterface $builder) {}
@@ -119,21 +124,23 @@ class StatActivityDuration implements ExportInterface, GroupedExportInterface
}
$qb->select($select)
->join('activity.person', 'person')
->join('person.centerHistory', 'centerHistory');
->join('activity.person', 'person');
$qb
->where(
$qb->expr()->andX(
$qb->expr()->lte('centerHistory.startDate', 'activity.date'),
$qb->expr()->orX(
$qb->expr()->isNull('centerHistory.endDate'),
$qb->expr()->gt('centerHistory.endDate', 'activity.date')
if ($this->filterStatsByCenters) {
$qb
->join('person.centerHistory', 'centerHistory')
->where(
$qb->expr()->andX(
$qb->expr()->lte('centerHistory.startDate', 'activity.date'),
$qb->expr()->orX(
$qb->expr()->isNull('centerHistory.endDate'),
$qb->expr()->gt('centerHistory.endDate', 'activity.date')
)
)
)
)
->andWhere($qb->expr()->in('centerHistory.center', ':centers'))
->setParameter('centers', $centers);
->andWhere($qb->expr()->in('centerHistory.center', ':centers'))
->setParameter('centers', $centers);
}
return $qb;
}

View File

@@ -12,6 +12,7 @@ declare(strict_types=1);
namespace Chill\ActivityBundle\Tests\Export\Export\LinkedToACP;
use Chill\ActivityBundle\Export\Export\LinkedToACP\AvgActivityDuration;
use Chill\ActivityBundle\Repository\ActivityRepository;
use Chill\MainBundle\Test\Export\AbstractExportTest;
/**
@@ -21,18 +22,17 @@ use Chill\MainBundle\Test\Export\AbstractExportTest;
*/
final class AvgActivityDurationTest extends AbstractExportTest
{
private AvgActivityDuration $export;
protected function setUp(): void
{
self::bootKernel();
$this->export = self::$container->get('chill.activity.export.avg_activity_duration_linked_to_acp');
}
public function getExport()
{
return $this->export;
$activityRepository = self::$container->get(ActivityRepository::class);
yield new AvgActivityDuration($activityRepository, $this->getParameters(true));
yield new AvgActivityDuration($activityRepository, $this->getParameters(false));
}
public function getFormData(): array

View File

@@ -13,6 +13,7 @@ namespace Chill\ActivityBundle\Tests\Export\Export\LinkedToACP;
use Chill\ActivityBundle\Export\Export\LinkedToACP\AvgActivityVisitDuration;
use Chill\MainBundle\Test\Export\AbstractExportTest;
use Doctrine\ORM\EntityManagerInterface;
/**
* @internal
@@ -21,18 +22,17 @@ use Chill\MainBundle\Test\Export\AbstractExportTest;
*/
final class AvgActivityVisitDurationTest extends AbstractExportTest
{
private AvgActivityVisitDuration $export;
protected function setUp(): void
{
self::bootKernel();
$this->export = self::$container->get('chill.activity.export.avg_activity_visit_duration_linked_to_acp');
}
public function getExport()
{
return $this->export;
$em = self::$container->get(EntityManagerInterface::class);
yield new AvgActivityVisitDuration($em, $this->getParameters(true));
yield new AvgActivityVisitDuration($em, $this->getParameters(false));
}
public function getFormData(): array

View File

@@ -13,6 +13,7 @@ namespace Chill\ActivityBundle\Tests\Export\Export\LinkedToACP;
use Chill\ActivityBundle\Export\Export\LinkedToACP\CountActivity;
use Chill\MainBundle\Test\Export\AbstractExportTest;
use Doctrine\ORM\EntityManagerInterface;
/**
* @internal
@@ -21,18 +22,17 @@ use Chill\MainBundle\Test\Export\AbstractExportTest;
*/
final class CountActivityTest extends AbstractExportTest
{
private CountActivity $export;
protected function setUp(): void
{
self::bootKernel();
$this->export = self::$container->get('chill.activity.export.count_activity_linked_to_acp');
}
public function getExport()
{
return $this->export;
$em = self::$container->get(EntityManagerInterface::class);
yield new CountActivity($em, $this->getParameters(true));
yield new CountActivity($em, $this->getParameters(false));
}
public function getFormData(): array

View File

@@ -13,6 +13,7 @@ namespace Chill\ActivityBundle\Tests\Export\Export\LinkedToACP;
use Chill\ActivityBundle\Export\Export\LinkedToACP\SumActivityDuration;
use Chill\MainBundle\Test\Export\AbstractExportTest;
use Doctrine\ORM\EntityManagerInterface;
/**
* @internal
@@ -21,18 +22,17 @@ use Chill\MainBundle\Test\Export\AbstractExportTest;
*/
final class SumActivityDurationTest extends AbstractExportTest
{
private SumActivityDuration $export;
protected function setUp(): void
{
self::bootKernel();
$this->export = self::$container->get('chill.activity.export.sum_activity_duration_linked_to_acp');
}
public function getExport()
{
return $this->export;
$em = self::$container->get(EntityManagerInterface::class);
yield new SumActivityDuration($em, $this->getParameters(true));
yield new SumActivityDuration($em, $this->getParameters(false));
}
public function getFormData(): array

View File

@@ -13,6 +13,7 @@ namespace Chill\ActivityBundle\Tests\Export\Export\LinkedToACP;
use Chill\ActivityBundle\Export\Export\LinkedToACP\SumActivityVisitDuration;
use Chill\MainBundle\Test\Export\AbstractExportTest;
use Doctrine\ORM\EntityManagerInterface;
/**
* @internal
@@ -32,7 +33,10 @@ final class SumActivityVisitDurationTest extends AbstractExportTest
public function getExport()
{
return $this->export;
$em = self::$container->get(EntityManagerInterface::class);
yield new SumActivityVisitDuration($em, $this->getParameters(true));
yield new SumActivityVisitDuration($em, $this->getParameters(false));
}
public function getFormData(): array

View File

@@ -12,6 +12,7 @@ declare(strict_types=1);
namespace Chill\ActivityBundle\Tests\Export\Export\LinkedToPerson;
use Chill\ActivityBundle\Export\Export\LinkedToPerson\CountActivity;
use Chill\ActivityBundle\Repository\ActivityRepository;
use Chill\MainBundle\Test\Export\AbstractExportTest;
/**
@@ -21,18 +22,17 @@ use Chill\MainBundle\Test\Export\AbstractExportTest;
*/
final class CountActivityTest extends AbstractExportTest
{
private CountActivity $export;
protected function setUp(): void
{
self::bootKernel();
$this->export = self::$container->get('chill.activity.export.count_activity_linked_to_person');
}
public function getExport()
{
return $this->export;
$activityRepository = self::$container->get(ActivityRepository::class);
yield new CountActivity($activityRepository, $this->getParameters(true));
yield new CountActivity($activityRepository, $this->getParameters(false));
}
public function getFormData(): array

View File

@@ -12,8 +12,12 @@ declare(strict_types=1);
namespace Chill\ActivityBundle\Tests\Export\Export\LinkedToPerson;
use Chill\ActivityBundle\Export\Export\LinkedToPerson\ListActivity;
use Chill\ActivityBundle\Repository\ActivityRepository;
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
use Chill\MainBundle\Test\Export\AbstractExportTest;
use Doctrine\ORM\EntityManagerInterface;
use Prophecy\PhpUnit\ProphecyTrait;
use Symfony\Contracts\Translation\TranslatorInterface;
/**
* @internal
@@ -24,14 +28,12 @@ final class ListActivityTest extends AbstractExportTest
{
use ProphecyTrait;
private ListActivity $export;
private readonly ListActivity $export;
protected function setUp(): void
{
self::bootKernel();
$this->export = self::$container->get('chill.activity.export.list_activity_linked_to_person');
$request = $this->prophesize()
->willExtend(\Symfony\Component\HttpFoundation\Request::class);
@@ -43,7 +45,26 @@ final class ListActivityTest extends AbstractExportTest
public function getExport()
{
return $this->export;
$em = self::$container->get(EntityManagerInterface::class);
$translator = self::$container->get(TranslatorInterface::class);
$translatableStringHelper = self::$container->get(TranslatableStringHelperInterface::class);
$activityRepository = self::$container->get(ActivityRepository::class);
yield new ListActivity(
$em,
$translator,
$translatableStringHelper,
$activityRepository,
$this->getParameters(true)
);
yield new ListActivity(
$em,
$translator,
$translatableStringHelper,
$activityRepository,
$this->getParameters(false)
);
}
public function getFormData()

View File

@@ -12,6 +12,7 @@ declare(strict_types=1);
namespace Chill\ActivityBundle\Tests\Export\Export\LinkedToPerson;
use Chill\ActivityBundle\Export\Export\LinkedToPerson\StatActivityDuration;
use Chill\ActivityBundle\Repository\ActivityRepository;
use Chill\MainBundle\Test\Export\AbstractExportTest;
/**
@@ -23,18 +24,18 @@ use Chill\MainBundle\Test\Export\AbstractExportTest;
*/
final class StatActivityDurationTest extends AbstractExportTest
{
private StatActivityDuration $export;
private readonly StatActivityDuration $export;
protected function setUp(): void
{
self::bootKernel();
$this->export = self::$container->get('chill.activity.export.sum_activity_duration_linked_to_person');
}
public function getExport()
{
return $this->export;
$activityRepository = self::$container->get(ActivityRepository::class);
yield new StatActivityDuration($activityRepository, $this->getParameters(true), 'sum');
yield new StatActivityDuration($activityRepository, $this->getParameters(false), 'sum');
}
public function getFormData(): array