Use dedicated FilterListAccompanyingPeriodHelper to filter confidential course in different lists

This commit is contained in:
Julien Fastré 2023-12-07 16:18:37 +01:00
parent 54606403b4
commit f0605c6b08
Signed by: julienfastre
GPG Key ID: BDE2190974723FCB
10 changed files with 73 additions and 185 deletions

View File

@ -20,23 +20,18 @@ use Chill\MainBundle\Export\AccompanyingCourseExportHelper;
use Chill\MainBundle\Export\GroupedExportInterface; use Chill\MainBundle\Export\GroupedExportInterface;
use Chill\MainBundle\Export\Helper\TranslatableStringExportLabelHelper; use Chill\MainBundle\Export\Helper\TranslatableStringExportLabelHelper;
use Chill\MainBundle\Export\ListInterface; use Chill\MainBundle\Export\ListInterface;
use Chill\PersonBundle\Entity\Person\PersonCenterHistory; use Chill\PersonBundle\Export\Helper\FilterListAccompanyingPeriodHelperInterface;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
class ListActivity implements ListInterface, GroupedExportInterface final readonly class ListActivity implements ListInterface, GroupedExportInterface
{ {
private readonly bool $filterStatsByCenters;
public function __construct( public function __construct(
private readonly ListActivityHelper $helper, private ListActivityHelper $helper,
private readonly EntityManagerInterface $entityManager, private EntityManagerInterface $entityManager,
private readonly TranslatableStringExportLabelHelper $translatableStringExportLabelHelper, private TranslatableStringExportLabelHelper $translatableStringExportLabelHelper,
ParameterBagInterface $parameterBag, private FilterListAccompanyingPeriodHelperInterface $filterListAccompanyingPeriodHelper,
) { ) {}
$this->filterStatsByCenters = $parameterBag->get('chill_main')['acl']['filter_stats_by_center'];
}
public function buildForm(FormBuilderInterface $builder) public function buildForm(FormBuilderInterface $builder)
{ {
@ -119,19 +114,7 @@ class ListActivity implements ListInterface, GroupedExportInterface
->leftJoin('acppart.person', 'person') ->leftJoin('acppart.person', 'person')
->andWhere('acppart.startDate != acppart.endDate OR acppart.endDate IS NULL'); ->andWhere('acppart.startDate != acppart.endDate OR acppart.endDate IS NULL');
if ($this->filterStatsByCenters) { $this->filterListAccompanyingPeriodHelper->addFilterAccompanyingPeriods($qb, $requiredModifiers, $acl, $data);
$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 $qb
// some grouping are necessary // some grouping are necessary

View File

@ -28,11 +28,11 @@ use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkGoal;
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkReferrerHistory; use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkReferrerHistory;
use Chill\PersonBundle\Entity\AccompanyingPeriod\UserHistory; use Chill\PersonBundle\Entity\AccompanyingPeriod\UserHistory;
use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Entity\Person;
use Chill\PersonBundle\Entity\Person\PersonCenterHistory;
use Chill\PersonBundle\Entity\SocialWork\Evaluation; use Chill\PersonBundle\Entity\SocialWork\Evaluation;
use Chill\PersonBundle\Entity\SocialWork\Goal; use Chill\PersonBundle\Entity\SocialWork\Goal;
use Chill\PersonBundle\Entity\SocialWork\Result; use Chill\PersonBundle\Entity\SocialWork\Result;
use Chill\PersonBundle\Export\Declarations; use Chill\PersonBundle\Export\Declarations;
use Chill\PersonBundle\Export\Helper\FilterListAccompanyingPeriodHelperInterface;
use Chill\PersonBundle\Export\Helper\LabelPersonHelper; use Chill\PersonBundle\Export\Helper\LabelPersonHelper;
use Chill\PersonBundle\Repository\SocialWork\SocialActionRepository; use Chill\PersonBundle\Repository\SocialWork\SocialActionRepository;
use Chill\PersonBundle\Repository\SocialWork\SocialIssueRepository; use Chill\PersonBundle\Repository\SocialWork\SocialIssueRepository;
@ -44,10 +44,9 @@ use Chill\ThirdPartyBundle\Export\Helper\LabelThirdPartyHelper;
use Doctrine\ORM\AbstractQuery; use Doctrine\ORM\AbstractQuery;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\QueryBuilder; use Doctrine\ORM\QueryBuilder;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
class ListAccompanyingPeriodWorkAssociatePersonOnAccompanyingPeriod implements ListInterface, GroupedExportInterface final readonly class ListAccompanyingPeriodWorkAssociatePersonOnAccompanyingPeriod implements ListInterface, GroupedExportInterface
{ {
private const FIELDS = [ private const FIELDS = [
'id', 'id',
@ -79,8 +78,6 @@ class ListAccompanyingPeriodWorkAssociatePersonOnAccompanyingPeriod implements L
'updatedBy', 'updatedBy',
]; ];
private readonly bool $filterStatsByCenters;
public function __construct( public function __construct(
private readonly EntityManagerInterface $entityManager, private readonly EntityManagerInterface $entityManager,
private readonly DateTimeHelper $dateTimeHelper, private readonly DateTimeHelper $dateTimeHelper,
@ -94,10 +91,8 @@ class ListAccompanyingPeriodWorkAssociatePersonOnAccompanyingPeriod implements L
private readonly RollingDateConverterInterface $rollingDateConverter, private readonly RollingDateConverterInterface $rollingDateConverter,
private readonly AggregateStringHelper $aggregateStringHelper, private readonly AggregateStringHelper $aggregateStringHelper,
private readonly SocialActionRepository $socialActionRepository, private readonly SocialActionRepository $socialActionRepository,
ParameterBagInterface $parameterBag, private readonly FilterListAccompanyingPeriodHelperInterface $filterListAccompanyingPeriodHelper,
) { ) {}
$this->filterStatsByCenters = $parameterBag->get('chill_main')['acl']['filter_stats_by_center'];
}
public function buildForm(FormBuilderInterface $builder) public function buildForm(FormBuilderInterface $builder)
{ {
@ -223,17 +218,7 @@ class ListAccompanyingPeriodWorkAssociatePersonOnAccompanyingPeriod implements L
->andWhere('acppart.startDate <= :calc_date AND (acppart.endDate > :calc_date OR acppart.endDate IS NULL)') ->andWhere('acppart.startDate <= :calc_date AND (acppart.endDate > :calc_date OR acppart.endDate IS NULL)')
->setParameter('calc_date', $this->rollingDateConverter->convert($calcDate)); ->setParameter('calc_date', $this->rollingDateConverter->convert($calcDate));
if ($this->filterStatsByCenters) { $this->filterListAccompanyingPeriodHelper->addFilterAccompanyingPeriods($qb, $requiredModifiers, $acl, $data);
$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);
}
AccompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb); AccompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb);

View File

@ -28,11 +28,11 @@ use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkGoal;
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkReferrerHistory; use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkReferrerHistory;
use Chill\PersonBundle\Entity\AccompanyingPeriod\UserHistory; use Chill\PersonBundle\Entity\AccompanyingPeriod\UserHistory;
use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Entity\Person;
use Chill\PersonBundle\Entity\Person\PersonCenterHistory;
use Chill\PersonBundle\Entity\SocialWork\Evaluation; use Chill\PersonBundle\Entity\SocialWork\Evaluation;
use Chill\PersonBundle\Entity\SocialWork\Goal; use Chill\PersonBundle\Entity\SocialWork\Goal;
use Chill\PersonBundle\Entity\SocialWork\Result; use Chill\PersonBundle\Entity\SocialWork\Result;
use Chill\PersonBundle\Export\Declarations; use Chill\PersonBundle\Export\Declarations;
use Chill\PersonBundle\Export\Helper\FilterListAccompanyingPeriodHelperInterface;
use Chill\PersonBundle\Export\Helper\LabelPersonHelper; use Chill\PersonBundle\Export\Helper\LabelPersonHelper;
use Chill\PersonBundle\Repository\SocialWork\SocialActionRepository; use Chill\PersonBundle\Repository\SocialWork\SocialActionRepository;
use Chill\PersonBundle\Repository\SocialWork\SocialIssueRepository; use Chill\PersonBundle\Repository\SocialWork\SocialIssueRepository;
@ -44,10 +44,9 @@ use Chill\ThirdPartyBundle\Export\Helper\LabelThirdPartyHelper;
use Doctrine\ORM\AbstractQuery; use Doctrine\ORM\AbstractQuery;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\QueryBuilder; use Doctrine\ORM\QueryBuilder;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
class ListAccompanyingPeriodWorkAssociatePersonOnWork implements ListInterface, GroupedExportInterface final readonly class ListAccompanyingPeriodWorkAssociatePersonOnWork implements ListInterface, GroupedExportInterface
{ {
private const FIELDS = [ private const FIELDS = [
'id', 'id',
@ -79,8 +78,6 @@ class ListAccompanyingPeriodWorkAssociatePersonOnWork implements ListInterface,
'updatedBy', 'updatedBy',
]; ];
private readonly bool $filterStatsByCenters;
public function __construct( public function __construct(
private readonly EntityManagerInterface $entityManager, private readonly EntityManagerInterface $entityManager,
private readonly DateTimeHelper $dateTimeHelper, private readonly DateTimeHelper $dateTimeHelper,
@ -94,10 +91,8 @@ class ListAccompanyingPeriodWorkAssociatePersonOnWork implements ListInterface,
private readonly RollingDateConverterInterface $rollingDateConverter, private readonly RollingDateConverterInterface $rollingDateConverter,
private readonly AggregateStringHelper $aggregateStringHelper, private readonly AggregateStringHelper $aggregateStringHelper,
private readonly SocialActionRepository $socialActionRepository, private readonly SocialActionRepository $socialActionRepository,
ParameterBagInterface $parameterBag, private FilterListAccompanyingPeriodHelperInterface $filterListAccompanyingPeriodHelper,
) { ) {}
$this->filterStatsByCenters = $parameterBag->get('chill_main')['acl']['filter_stats_by_center'];
}
public function buildForm(FormBuilderInterface $builder) public function buildForm(FormBuilderInterface $builder)
{ {
@ -218,17 +213,7 @@ class ListAccompanyingPeriodWorkAssociatePersonOnWork implements ListInterface,
->join('acpw.persons', 'person') ->join('acpw.persons', 'person')
; ;
if ($this->filterStatsByCenters) { $this->filterListAccompanyingPeriodHelper->addFilterAccompanyingPeriods($qb, $requiredModifiers, $acl, $data);
$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);
}
AccompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb); AccompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb);

View File

@ -26,8 +26,8 @@ use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface;
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluation; use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluation;
use Chill\PersonBundle\Entity\AccompanyingPeriod\UserHistory; use Chill\PersonBundle\Entity\AccompanyingPeriod\UserHistory;
use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Entity\Person;
use Chill\PersonBundle\Entity\Person\PersonCenterHistory;
use Chill\PersonBundle\Export\Declarations; use Chill\PersonBundle\Export\Declarations;
use Chill\PersonBundle\Export\Helper\FilterListAccompanyingPeriodHelperInterface;
use Chill\PersonBundle\Export\Helper\LabelPersonHelper; use Chill\PersonBundle\Export\Helper\LabelPersonHelper;
use Chill\PersonBundle\Repository\SocialWork\SocialActionRepository; use Chill\PersonBundle\Repository\SocialWork\SocialActionRepository;
use Chill\PersonBundle\Repository\SocialWork\SocialIssueRepository; use Chill\PersonBundle\Repository\SocialWork\SocialIssueRepository;
@ -37,10 +37,9 @@ use Chill\PersonBundle\Templating\Entity\SocialIssueRender;
use Doctrine\ORM\AbstractQuery; use Doctrine\ORM\AbstractQuery;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\QueryBuilder; use Doctrine\ORM\QueryBuilder;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
class ListEvaluation implements ListInterface, GroupedExportInterface final readonly class ListEvaluation implements ListInterface, GroupedExportInterface
{ {
private const FIELDS = [ private const FIELDS = [
'id', 'id',
@ -69,8 +68,6 @@ class ListEvaluation implements ListInterface, GroupedExportInterface
'updatedBy', 'updatedBy',
]; ];
private readonly bool $filterStatsByCenters;
public function __construct( public function __construct(
private readonly EntityManagerInterface $entityManager, private readonly EntityManagerInterface $entityManager,
private readonly SocialIssueRender $socialIssueRender, private readonly SocialIssueRender $socialIssueRender,
@ -83,10 +80,8 @@ class ListEvaluation implements ListInterface, GroupedExportInterface
private readonly TranslatableStringExportLabelHelper $translatableStringExportLabelHelper, private readonly TranslatableStringExportLabelHelper $translatableStringExportLabelHelper,
private readonly AggregateStringHelper $aggregateStringHelper, private readonly AggregateStringHelper $aggregateStringHelper,
private readonly RollingDateConverterInterface $rollingDateConverter, private readonly RollingDateConverterInterface $rollingDateConverter,
ParameterBagInterface $parameterBag, private FilterListAccompanyingPeriodHelperInterface $filterListAccompanyingPeriodHelper,
) { ) {}
$this->filterStatsByCenters = $parameterBag->get('chill_main')['acl']['filter_stats_by_center'];
}
public function buildForm(FormBuilderInterface $builder) public function buildForm(FormBuilderInterface $builder)
{ {
@ -211,17 +206,7 @@ class ListEvaluation implements ListInterface, GroupedExportInterface
->andWhere('acppart.startDate <= :calc_date AND (acppart.endDate > :calc_date OR acppart.endDate IS NULL)') ->andWhere('acppart.startDate <= :calc_date AND (acppart.endDate > :calc_date OR acppart.endDate IS NULL)')
->setParameter('calc_date', $this->rollingDateConverter->convert($calcDate)); ->setParameter('calc_date', $this->rollingDateConverter->convert($calcDate));
if ($this->filterStatsByCenters) { $this->filterListAccompanyingPeriodHelper->addFilterAccompanyingPeriods($qb, $requiredModifiers, $acl, $data);
$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);
}
AccompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb); AccompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb);

View File

@ -20,15 +20,14 @@ use Chill\MainBundle\Service\RollingDate\RollingDate;
use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface; use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface;
use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Entity\Person;
use Chill\PersonBundle\Entity\Person\PersonCenterHistory;
use Chill\PersonBundle\Export\Declarations; use Chill\PersonBundle\Export\Declarations;
use Chill\PersonBundle\Export\Helper\FilterListAccompanyingPeriodHelperInterface;
use Chill\PersonBundle\Export\Helper\ListAccompanyingPeriodHelper; use Chill\PersonBundle\Export\Helper\ListAccompanyingPeriodHelper;
use Chill\PersonBundle\Export\Helper\ListPersonHelper; use Chill\PersonBundle\Export\Helper\ListPersonHelper;
use Chill\PersonBundle\Security\Authorization\PersonVoter; use Chill\PersonBundle\Security\Authorization\PersonVoter;
use DateTimeImmutable; use DateTimeImmutable;
use Doctrine\ORM\AbstractQuery; use Doctrine\ORM\AbstractQuery;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
/** /**
@ -36,17 +35,13 @@ use Symfony\Component\Form\FormBuilderInterface;
*/ */
final readonly class ListPersonWithAccompanyingPeriodDetails implements ListInterface, GroupedExportInterface final readonly class ListPersonWithAccompanyingPeriodDetails implements ListInterface, GroupedExportInterface
{ {
private bool $filterStatsByCenters;
public function __construct( public function __construct(
private ListPersonHelper $listPersonHelper, private ListPersonHelper $listPersonHelper,
private ListAccompanyingPeriodHelper $listAccompanyingPeriodHelper, private ListAccompanyingPeriodHelper $listAccompanyingPeriodHelper,
private EntityManagerInterface $entityManager, private EntityManagerInterface $entityManager,
private RollingDateConverterInterface $rollingDateConverter, private RollingDateConverterInterface $rollingDateConverter,
ParameterBagInterface $parameterBag, private FilterListAccompanyingPeriodHelperInterface $filterListAccompanyingPeriodHelper,
) { ) {}
$this->filterStatsByCenters = $parameterBag->get('chill_main')['acl']['filter_stats_by_center'];
}
public function buildForm(FormBuilderInterface $builder) public function buildForm(FormBuilderInterface $builder)
{ {
@ -122,14 +117,7 @@ final readonly class ListPersonWithAccompanyingPeriodDetails implements ListInte
->join('acppart.accompanyingPeriod', 'acp') ->join('acppart.accompanyingPeriod', 'acp')
->andWhere($qb->expr()->neq('acp.step', "'".AccompanyingPeriod::STEP_DRAFT."'")); ->andWhere($qb->expr()->neq('acp.step', "'".AccompanyingPeriod::STEP_DRAFT."'"));
if ($this->filterStatsByCenters) { $this->filterListAccompanyingPeriodHelper->addFilterAccompanyingPeriods($qb, $requiredModifiers, $acl, $data);
$qb
->andWhere(
$qb->expr()->exists(
'SELECT 1 FROM '.PersonCenterHistory::class.' pch WHERE pch.person = person.id AND pch.center IN (:authorized_centers)'
)
)->setParameter('authorized_centers', $centers);
}
$this->listPersonHelper->addSelect($qb, ListPersonHelper::FIELDS, $this->rollingDateConverter->convert($data['address_date'])); $this->listPersonHelper->addSelect($qb, ListPersonHelper::FIELDS, $this->rollingDateConverter->convert($data['address_date']));
$this->listAccompanyingPeriodHelper->addSelectClauses($qb, $this->rollingDateConverter->convert($data['address_date'])); $this->listAccompanyingPeriodHelper->addSelectClauses($qb, $this->rollingDateConverter->convert($data['address_date']));

View File

@ -20,6 +20,7 @@ use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface;
use Chill\MainBundle\Test\Export\AbstractExportTest; use Chill\MainBundle\Test\Export\AbstractExportTest;
use Chill\PersonBundle\Export\Declarations; use Chill\PersonBundle\Export\Declarations;
use Chill\PersonBundle\Export\Export\ListAccompanyingPeriodWorkAssociatePersonOnAccompanyingPeriod; use Chill\PersonBundle\Export\Export\ListAccompanyingPeriodWorkAssociatePersonOnAccompanyingPeriod;
use Chill\PersonBundle\Export\Helper\FilterListAccompanyingPeriodHelperInterface;
use Chill\PersonBundle\Export\Helper\LabelPersonHelper; use Chill\PersonBundle\Export\Helper\LabelPersonHelper;
use Chill\PersonBundle\Repository\SocialWork\SocialActionRepository; use Chill\PersonBundle\Repository\SocialWork\SocialActionRepository;
use Chill\PersonBundle\Repository\SocialWork\SocialIssueRepository; use Chill\PersonBundle\Repository\SocialWork\SocialIssueRepository;
@ -27,6 +28,7 @@ use Chill\PersonBundle\Templating\Entity\SocialActionRender;
use Chill\PersonBundle\Templating\Entity\SocialIssueRender; use Chill\PersonBundle\Templating\Entity\SocialIssueRender;
use Chill\ThirdPartyBundle\Export\Helper\LabelThirdPartyHelper; use Chill\ThirdPartyBundle\Export\Helper\LabelThirdPartyHelper;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Prophecy\PhpUnit\ProphecyTrait;
/** /**
* @internal * @internal
@ -35,6 +37,8 @@ use Doctrine\ORM\EntityManagerInterface;
*/ */
class ListAccompanyingPeriodWorkAssociatePersonOnAccompanyingPeriodTest extends AbstractExportTest class ListAccompanyingPeriodWorkAssociatePersonOnAccompanyingPeriodTest extends AbstractExportTest
{ {
use ProphecyTrait;
protected function setUp(): void protected function setUp(): void
{ {
parent::setUp(); parent::setUp();
@ -55,6 +59,7 @@ class ListAccompanyingPeriodWorkAssociatePersonOnAccompanyingPeriodTest extends
$rollingDateConverter = self::$container->get(RollingDateConverterInterface::class); $rollingDateConverter = self::$container->get(RollingDateConverterInterface::class);
$aggregateStringHelper = self::$container->get(AggregateStringHelper::class); $aggregateStringHelper = self::$container->get(AggregateStringHelper::class);
$socialActionRepository = self::$container->get(SocialActionRepository::class); $socialActionRepository = self::$container->get(SocialActionRepository::class);
$filterListAccompanyingPeriodHelper = $this->prophesize(FilterListAccompanyingPeriodHelperInterface::class);
yield new ListAccompanyingPeriodWorkAssociatePersonOnAccompanyingPeriod( yield new ListAccompanyingPeriodWorkAssociatePersonOnAccompanyingPeriod(
$entityManager, $entityManager,
@ -69,23 +74,7 @@ class ListAccompanyingPeriodWorkAssociatePersonOnAccompanyingPeriodTest extends
$rollingDateConverter, $rollingDateConverter,
$aggregateStringHelper, $aggregateStringHelper,
$socialActionRepository, $socialActionRepository,
$this->getParameters(true), $filterListAccompanyingPeriodHelper->reveal(),
);
yield new ListAccompanyingPeriodWorkAssociatePersonOnAccompanyingPeriod(
$entityManager,
$dateTimeHelper,
$userHelper,
$personHelper,
$thirdPartyHelper,
$translatableStringExportLabelHelper,
$socialIssueRender,
$socialIssueRepository,
$socialActionRender,
$rollingDateConverter,
$aggregateStringHelper,
$socialActionRepository,
$this->getParameters(false),
); );
} }

View File

@ -20,6 +20,7 @@ use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface;
use Chill\MainBundle\Test\Export\AbstractExportTest; use Chill\MainBundle\Test\Export\AbstractExportTest;
use Chill\PersonBundle\Export\Declarations; use Chill\PersonBundle\Export\Declarations;
use Chill\PersonBundle\Export\Export\ListAccompanyingPeriodWorkAssociatePersonOnWork; use Chill\PersonBundle\Export\Export\ListAccompanyingPeriodWorkAssociatePersonOnWork;
use Chill\PersonBundle\Export\Helper\FilterListAccompanyingPeriodHelperInterface;
use Chill\PersonBundle\Export\Helper\LabelPersonHelper; use Chill\PersonBundle\Export\Helper\LabelPersonHelper;
use Chill\PersonBundle\Repository\SocialWork\SocialActionRepository; use Chill\PersonBundle\Repository\SocialWork\SocialActionRepository;
use Chill\PersonBundle\Repository\SocialWork\SocialIssueRepository; use Chill\PersonBundle\Repository\SocialWork\SocialIssueRepository;
@ -27,6 +28,7 @@ use Chill\PersonBundle\Templating\Entity\SocialActionRender;
use Chill\PersonBundle\Templating\Entity\SocialIssueRender; use Chill\PersonBundle\Templating\Entity\SocialIssueRender;
use Chill\ThirdPartyBundle\Export\Helper\LabelThirdPartyHelper; use Chill\ThirdPartyBundle\Export\Helper\LabelThirdPartyHelper;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Prophecy\PhpUnit\ProphecyTrait;
/** /**
* @internal * @internal
@ -35,6 +37,8 @@ use Doctrine\ORM\EntityManagerInterface;
*/ */
class ListAccompanyingPeriodWorkAssociatePersonOnWorkTest extends AbstractExportTest class ListAccompanyingPeriodWorkAssociatePersonOnWorkTest extends AbstractExportTest
{ {
use ProphecyTrait;
protected function setUp(): void protected function setUp(): void
{ {
parent::setUp(); parent::setUp();
@ -55,6 +59,7 @@ class ListAccompanyingPeriodWorkAssociatePersonOnWorkTest extends AbstractExport
$rollingDateConverter = self::$container->get(RollingDateConverterInterface::class); $rollingDateConverter = self::$container->get(RollingDateConverterInterface::class);
$aggregateStringHelper = self::$container->get(AggregateStringHelper::class); $aggregateStringHelper = self::$container->get(AggregateStringHelper::class);
$socialActionRepository = self::$container->get(SocialActionRepository::class); $socialActionRepository = self::$container->get(SocialActionRepository::class);
$filterHelper = $this->prophesize(FilterListAccompanyingPeriodHelperInterface::class);
yield new ListAccompanyingPeriodWorkAssociatePersonOnWork( yield new ListAccompanyingPeriodWorkAssociatePersonOnWork(
$entityManager, $entityManager,
@ -69,23 +74,7 @@ class ListAccompanyingPeriodWorkAssociatePersonOnWorkTest extends AbstractExport
$rollingDateConverter, $rollingDateConverter,
$aggregateStringHelper, $aggregateStringHelper,
$socialActionRepository, $socialActionRepository,
$this->getParameters(true), $filterHelper->reveal(),
);
yield new ListAccompanyingPeriodWorkAssociatePersonOnWork(
$entityManager,
$dateTimeHelper,
$userHelper,
$personHelper,
$thirdPartyHelper,
$translatableStringExportLabelHelper,
$socialIssueRender,
$socialIssueRepository,
$socialActionRender,
$rollingDateConverter,
$aggregateStringHelper,
$socialActionRepository,
$this->getParameters(false),
); );
} }

View File

@ -11,7 +11,6 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Tests\Export\Export; namespace Chill\PersonBundle\Tests\Export\Export;
use Chill\MainBundle\Entity\Center;
use Chill\MainBundle\Export\Helper\AggregateStringHelper; use Chill\MainBundle\Export\Helper\AggregateStringHelper;
use Chill\MainBundle\Export\Helper\DateTimeHelper; use Chill\MainBundle\Export\Helper\DateTimeHelper;
use Chill\MainBundle\Export\Helper\TranslatableStringExportLabelHelper; use Chill\MainBundle\Export\Helper\TranslatableStringExportLabelHelper;
@ -22,13 +21,14 @@ use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface;
use Chill\MainBundle\Test\Export\AbstractExportTest; use Chill\MainBundle\Test\Export\AbstractExportTest;
use Chill\PersonBundle\Export\Declarations; use Chill\PersonBundle\Export\Declarations;
use Chill\PersonBundle\Export\Export\ListEvaluation; use Chill\PersonBundle\Export\Export\ListEvaluation;
use Chill\PersonBundle\Export\Helper\FilterListAccompanyingPeriodHelperInterface;
use Chill\PersonBundle\Export\Helper\LabelPersonHelper; use Chill\PersonBundle\Export\Helper\LabelPersonHelper;
use Chill\PersonBundle\Repository\SocialWork\SocialActionRepository; use Chill\PersonBundle\Repository\SocialWork\SocialActionRepository;
use Chill\PersonBundle\Repository\SocialWork\SocialIssueRepository; use Chill\PersonBundle\Repository\SocialWork\SocialIssueRepository;
use Chill\PersonBundle\Templating\Entity\SocialActionRender; use Chill\PersonBundle\Templating\Entity\SocialActionRender;
use Chill\PersonBundle\Templating\Entity\SocialIssueRender; use Chill\PersonBundle\Templating\Entity\SocialIssueRender;
use Doctrine\ORM\AbstractQuery;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Prophecy\PhpUnit\ProphecyTrait;
/** /**
* @internal * @internal
@ -37,7 +37,7 @@ use Doctrine\ORM\EntityManagerInterface;
*/ */
class ListEvaluationTest extends AbstractExportTest class ListEvaluationTest extends AbstractExportTest
{ {
private ListEvaluation $listEvaluation; use ProphecyTrait;
private CenterRepositoryInterface $centerRepository; private CenterRepositoryInterface $centerRepository;
@ -46,7 +46,6 @@ class ListEvaluationTest extends AbstractExportTest
parent::setUp(); parent::setUp();
self::bootKernel(); self::bootKernel();
$this->listEvaluation = self::$container->get(ListEvaluation::class);
$this->centerRepository = self::$container->get(CenterRepositoryInterface::class); $this->centerRepository = self::$container->get(CenterRepositoryInterface::class);
} }
@ -63,6 +62,7 @@ class ListEvaluationTest extends AbstractExportTest
$rollingDateConverter = self::$container->get(RollingDateConverterInterface::class); $rollingDateConverter = self::$container->get(RollingDateConverterInterface::class);
$aggregateStringHelper = self::$container->get(AggregateStringHelper::class); $aggregateStringHelper = self::$container->get(AggregateStringHelper::class);
$socialActionRepository = self::$container->get(SocialActionRepository::class); $socialActionRepository = self::$container->get(SocialActionRepository::class);
$filterListHelper = $this->prophesize(FilterListAccompanyingPeriodHelperInterface::class);
yield new ListEvaluation( yield new ListEvaluation(
$entityManager, $entityManager,
@ -76,22 +76,7 @@ class ListEvaluationTest extends AbstractExportTest
$translatableStringExportLabelHelper, $translatableStringExportLabelHelper,
$aggregateStringHelper, $aggregateStringHelper,
$rollingDateConverter, $rollingDateConverter,
$this->getParameters(true), $filterListHelper->reveal(),
);
yield new ListEvaluation(
$entityManager,
$socialIssueRender,
$socialIssueRepository,
$socialActionRender,
$socialActionRepository,
$userHelper,
$personHelper,
$dateTimeHelper,
$translatableStringExportLabelHelper,
$aggregateStringHelper,
$rollingDateConverter,
$this->getParameters(false),
); );
} }
@ -104,14 +89,4 @@ class ListEvaluationTest extends AbstractExportTest
{ {
return [[Declarations::ACP_TYPE]]; return [[Declarations::ACP_TYPE]];
} }
public function testQuery(): void
{
$centers = $this->centerRepository->findAll();
$query = $this->listEvaluation->initiateQuery([], array_map(fn (Center $c) => ['center' => $c], $centers), ['calc_date' => new RollingDate(RollingDate::T_TODAY)]);
$query->setMaxResults(1);
self::assertIsArray($query->getQuery()->getResult(AbstractQuery::HYDRATE_ARRAY));
}
} }

View File

@ -16,9 +16,11 @@ use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface;
use Chill\MainBundle\Test\Export\AbstractExportTest; use Chill\MainBundle\Test\Export\AbstractExportTest;
use Chill\PersonBundle\Export\Declarations; use Chill\PersonBundle\Export\Declarations;
use Chill\PersonBundle\Export\Export\ListPersonWithAccompanyingPeriodDetails; use Chill\PersonBundle\Export\Export\ListPersonWithAccompanyingPeriodDetails;
use Chill\PersonBundle\Export\Helper\FilterListAccompanyingPeriodHelperInterface;
use Chill\PersonBundle\Export\Helper\ListAccompanyingPeriodHelper; use Chill\PersonBundle\Export\Helper\ListAccompanyingPeriodHelper;
use Chill\PersonBundle\Export\Helper\ListPersonHelper; use Chill\PersonBundle\Export\Helper\ListPersonHelper;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Prophecy\PhpUnit\ProphecyTrait;
/** /**
* @internal * @internal
@ -27,6 +29,8 @@ use Doctrine\ORM\EntityManagerInterface;
*/ */
class ListPersonWithAccompanyingPeriodDetailsTest extends AbstractExportTest class ListPersonWithAccompanyingPeriodDetailsTest extends AbstractExportTest
{ {
use ProphecyTrait;
protected function setUp(): void protected function setUp(): void
{ {
parent::setUp(); parent::setUp();
@ -39,21 +43,14 @@ class ListPersonWithAccompanyingPeriodDetailsTest extends AbstractExportTest
$listAccompanyingPeriodHelper = self::$container->get(ListAccompanyingPeriodHelper::class); $listAccompanyingPeriodHelper = self::$container->get(ListAccompanyingPeriodHelper::class);
$entityManager = self::$container->get(EntityManagerInterface::class); $entityManager = self::$container->get(EntityManagerInterface::class);
$rollingDateConverter = self::$container->get(RollingDateConverterInterface::class); $rollingDateConverter = self::$container->get(RollingDateConverterInterface::class);
$filterHelper = $this->prophesize(FilterListAccompanyingPeriodHelperInterface::class);
yield new ListPersonWithAccompanyingPeriodDetails( yield new ListPersonWithAccompanyingPeriodDetails(
$listPersonHelper, $listPersonHelper,
$listAccompanyingPeriodHelper, $listAccompanyingPeriodHelper,
$entityManager, $entityManager,
$rollingDateConverter, $rollingDateConverter,
$this->getParameters(true), $filterHelper->reveal()
);
yield new ListPersonWithAccompanyingPeriodDetails(
$listPersonHelper,
$listAccompanyingPeriodHelper,
$entityManager,
$rollingDateConverter,
$this->getParameters(false),
); );
} }

View File

@ -1,5 +1,14 @@
<?php <?php
declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\PersonBundle\Tests\Export\Helper; namespace Chill\PersonBundle\Tests\Export\Helper;
use Chill\MainBundle\Entity\Center; use Chill\MainBundle\Entity\Center;
@ -13,7 +22,6 @@ use Chill\PersonBundle\Export\Helper\FilterListAccompanyingPeriodHelper;
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter; use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\QueryBuilder; use Doctrine\ORM\QueryBuilder;
use PHPUnit\Framework\TestCase;
use Prophecy\Argument; use Prophecy\Argument;
use Prophecy\PhpUnit\ProphecyTrait; use Prophecy\PhpUnit\ProphecyTrait;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
@ -21,6 +29,11 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\Security\Core\Security; use Symfony\Component\Security\Core\Security;
/**
* @internal
*
* @coversNothing
*/
final class FilterListAccompanyingPeriodHelperTest extends KernelTestCase final class FilterListAccompanyingPeriodHelperTest extends KernelTestCase
{ {
use ProphecyTrait; use ProphecyTrait;
@ -40,7 +53,6 @@ final class FilterListAccompanyingPeriodHelperTest extends KernelTestCase
} }
/** /**
* @return void
* @dataProvider dataProviderTestAddFilterAccompanyingPeriod * @dataProvider dataProviderTestAddFilterAccompanyingPeriod
*/ */
public function testAddFilterAccompanyingPeriod(QueryBuilder $qb, ParameterBagInterface $parameterBag): void public function testAddFilterAccompanyingPeriod(QueryBuilder $qb, ParameterBagInterface $parameterBag): void
@ -89,19 +101,19 @@ final class FilterListAccompanyingPeriodHelperTest extends KernelTestCase
yield [ yield [
$qb, $qb,
new ParameterBag(['chill_main' => ['acl' => ['filter_stats_by_center' => true]]]) new ParameterBag(['chill_main' => ['acl' => ['filter_stats_by_center' => true]]]),
]; ];
yield [ yield [
$qb, $qb,
new ParameterBag(['chill_main' => ['acl' => ['filter_stats_by_center' => false]]]) new ParameterBag(['chill_main' => ['acl' => ['filter_stats_by_center' => false]]]),
]; ];
} }
/** /**
* @return list<array{center: Center, circles: list<Scope>}> The ACL, structured as an array. * @return list<array{center: Center, circles: list<Scope>}> the ACL, structured as an array
* *
* @throws \RuntimeException When no center or circle is found. * @throws \RuntimeException when no center or circle is found
*/ */
private function getACL(): array private function getACL(): array
{ {