Merge branch 'master' into upgrade-sf5

This commit is contained in:
2024-02-12 21:50:34 +01:00
920 changed files with 6430 additions and 1914 deletions

View File

@@ -244,10 +244,10 @@ final class PersonMoveEventSubscriberTest extends KernelTestCase
}
private function buildSubscriber(
\Twig\Environment $engine = null,
NotificationPersisterInterface $notificationPersister = null,
Security $security = null,
TranslatorInterface $translator = null
?\Twig\Environment $engine = null,
?NotificationPersisterInterface $notificationPersister = null,
?Security $security = null,
?TranslatorInterface $translator = null
): PersonAddressMoveEventSubscriber {
if (null === $translator) {
$double = $this->prophesize(TranslatorInterface::class);

View File

@@ -121,7 +121,9 @@ final class AccompanyingPeriodSocialIssueConsistencyEntityListenerTest extends T
protected function generateClass(AccompanyingPeriod $period, Collection $socialIssues): AccompanyingPeriodLinkedWithSocialIssuesEntityInterface
{
return new class ($period, $socialIssues) implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterface {
public function __construct(public $period, public $socialIssues) {}
public function __construct(public $period, public $socialIssues)
{
}
public function getAccompanyingPeriod(): AccompanyingPeriod
{

View File

@@ -0,0 +1,157 @@
<?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 Tests\Controller\AccompanyingCoursWorkApiController;
use Chill\MainBundle\Repository\UserRepositoryInterface;
use Chill\MainBundle\Test\PrepareClientTrait;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Entity\Person;
use Chill\PersonBundle\Entity\SocialWork\SocialAction;
use Chill\PersonBundle\Entity\SocialWork\SocialIssue;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
/**
* @internal
*
* @coversNothing
*/
class ConflictTest extends WebTestCase
{
use PrepareClientTrait;
protected function setUp(): void
{
self::ensureKernelShutdown();
}
protected function tearDown(): void
{
self::ensureKernelShutdown();
}
/**
* @dataProvider generateAccompanyingPeriodWork
*
* @throws \JsonException
*/
public function testWhenEditionAccompanyingPeriodWorkWithCurrentVersionNoConflictOccurs(AccompanyingPeriod\AccompanyingPeriodWork $work, int $personId): void
{
$client = $this->getClientAuthenticated();
$currentVersion = $work->getVersion();
$client->request(
'PUT',
"/api/1.0/person/accompanying-course/work/{$work->getid()}.json?entity_version={$currentVersion}",
content: json_encode([
'type' => 'accompanying_period_work',
'id' => $work->getId(),
'startDate' => [
'datetime' => '2023-12-15T00:00:00+01:00',
],
'endDate' => null,
'note' => 'This is a note',
'accompanyingPeriodWorkEvaluations' => [],
'goals' => [],
'handlingThirdParty' => null,
'persons' => [[
'type' => 'person',
'id' => $personId,
],
],
'privateComment' => '',
'refferers' => [],
'results' => [],
'thirdParties' => [],
], JSON_THROW_ON_ERROR)
);
self::assertResponseIsSuccessful();
$w = json_decode($client->getResponse()->getContent(), true, 512, JSON_THROW_ON_ERROR);
self::assertEquals($work->getVersion() + 1, $w['version']);
}
/**
* @dataProvider generateAccompanyingPeriodWork
*/
public function testWhenEditingAccompanyingPeriodWorkWithPreviousVersionAnHttpConflictResponseOccurs(AccompanyingPeriod\AccompanyingPeriodWork $work, int $personId): void
{
$client = $this->getClientAuthenticated();
$previous = $work->getVersion() - 1;
$client->request(
'PUT',
"/api/1.0/person/accompanying-course/work/{$work->getid()}.json?entity_version={$previous}",
content: json_encode([
'type' => 'accompanying_period_work',
'id' => $work->getId(),
'startDate' => [
'datetime' => '2023-12-15T00:00:00+01:00',
],
'endDate' => null,
'note' => 'This is a note',
'accompanyingPeriodWorkEvaluations' => [],
'goals' => [],
'handlingThirdParty' => null,
'persons' => [[
'type' => 'person',
'id' => $personId,
],
],
'privateComment' => '',
'refferers' => [],
'results' => [],
'thirdParties' => [],
], JSON_THROW_ON_ERROR)
);
self::assertResponseStatusCodeSame(409);
}
public function generateAccompanyingPeriodWork(): iterable
{
self::bootKernel();
$em = self::$container->get(EntityManagerInterface::class);
$userRepository = self::$container->get(UserRepositoryInterface::class);
$user = $userRepository->findOneByUsernameOrEmail('center a_social');
$period = new AccompanyingPeriod();
$em->persist($period);
$period->addPerson(($p = new Person())->setFirstName('test')->setLastName('test')
->setBirthdate(new \DateTime('1980-01-01'))->setGender(Person::BOTH_GENDER));
$em->persist($p);
$issue = (new SocialIssue())->setTitle(['fr' => 'test']);
$em->persist($issue);
$action = (new SocialAction())->setIssue($issue);
$em->persist($action);
$work = new AccompanyingPeriod\AccompanyingPeriodWork();
$work
->setAccompanyingPeriod($period)
->setStartDate(new \DateTimeImmutable())
->addPerson($p)
->setSocialAction($action)
->setCreatedBy($user)
->setUpdatedBy($user)
;
$em->persist($work);
$em->flush();
self::ensureKernelShutdown();
yield [$work, $p->getId()];
}
}

View File

@@ -222,7 +222,7 @@ final class PersonControllerCreateTest extends WebTestCase
Form &$creationForm,
string $firstname = 'God',
string $lastname = 'Jesus',
\DateTime $birthdate = null
?\DateTime $birthdate = null
) {
$creationForm->get(self::FIRSTNAME_INPUT)->setValue($firstname.'_'.uniqid());
$creationForm->get(self::LASTNAME_INPUT)->setValue($lastname.'_'.uniqid());

View File

@@ -43,7 +43,9 @@ final class PersonControllerUpdateTest extends WebTestCase
/**
* Prepare client and create a random person.
*/
protected function setUp(): void {}
protected function setUp(): void
{
}
protected function tearDown(): void
{

View File

@@ -34,7 +34,7 @@ final class PersonControllerUpdateWithHiddenFieldsTest extends WebTestCase
private ?object $em = null;
private ?\Chill\PersonBundle\Entity\Person $person = null;
private ?Person $person = null;
/**
* @var string The url using for seeing the person's information

View File

@@ -23,7 +23,7 @@ final class PersonControllerViewWithHiddenFieldsTest extends WebTestCase
{
private ?object $em = null;
private ?\Chill\PersonBundle\Entity\Person $person = null;
private ?Person $person = null;
/**
* @var string The url to view the person details

View File

@@ -312,4 +312,34 @@ final class AccompanyingPeriodTest extends \PHPUnit\Framework\TestCase
$this->assertNull($period->getRequestorPerson());
$this->assertNull($period->getRequestor());
}
public function testSetStep(): void
{
$period = new AccompanyingPeriod();
$period->setStep(AccompanyingPeriod::STEP_CONFIRMED);
self::assertEquals(AccompanyingPeriod::STEP_CONFIRMED, $period->getStep());
self::assertCount(1, $period->getStepHistories());
$period->setStep(AccompanyingPeriod::STEP_CONFIRMED_INACTIVE_SHORT);
self::assertEquals(AccompanyingPeriod::STEP_CONFIRMED_INACTIVE_SHORT, $period->getStep());
self::assertCount(2, $period->getStepHistories());
$periodInactiveSteps = $period->getStepHistories()->filter(fn (AccompanyingPeriod\AccompanyingPeriodStepHistory $h) => AccompanyingPeriod::STEP_CONFIRMED_INACTIVE_SHORT === $h->getStep());
self::assertCount(1, $periodInactiveSteps);
$period->setStep(AccompanyingPeriod::STEP_CLOSED, ['closing_motive' => $closingMotive = new AccompanyingPeriod\ClosingMotive()]);
self::assertEquals(AccompanyingPeriod::STEP_CLOSED, $period->getStep());
self::assertCount(3, $period->getStepHistories());
$periodClosedSteps = $period->getStepHistories()->filter(fn (AccompanyingPeriod\AccompanyingPeriodStepHistory $h) => AccompanyingPeriod::STEP_CLOSED === $h->getStep());
self::assertCount(1, $periodClosedSteps);
$periodClosedStep = $periodClosedSteps->first();
self::assertSame($closingMotive, $periodClosedStep->getClosingMotive());
}
}

View File

@@ -0,0 +1,61 @@
<?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\Aggregator\AccompanyingCourseAggregators;
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Export\Helper\LabelPersonHelper;
use Doctrine\ORM\EntityManagerInterface;
use Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\PersonParticipatingAggregator;
/**
* @internal
*
* @coversNothing
*/
final class PersonParticipatingAggregatorTest extends AbstractAggregatorTest
{
private LabelPersonHelper $labelPersonHelper;
protected function setUp(): void
{
self::bootKernel();
$this->labelPersonHelper = self::$container->get(LabelPersonHelper::class);
}
public function getAggregator()
{
return new PersonParticipatingAggregator($this->labelPersonHelper);
}
public function getFormData()
{
return [[]];
}
public function getQueryBuilders()
{
self::bootKernel();
$em = self::$container->get(EntityManagerInterface::class);
return [
$em->createQueryBuilder()
->select('count(acp.id)')
->from(AccompanyingPeriod::class, 'acp'),
$em->createQueryBuilder()
->select('count(acp.id)')
->from(AccompanyingPeriod::class, 'acp')
->join('acp.participations', 'acppart'),
];
}
}

View File

@@ -0,0 +1,68 @@
<?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\Aggregator\AccompanyingPeriodStepHistoryAggregators;
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodStepHistory;
use Chill\PersonBundle\Export\Aggregator\AccompanyingPeriodStepHistoryAggregators\ByClosingMotiveAggregator;
use Chill\PersonBundle\Repository\AccompanyingPeriod\ClosingMotiveRepositoryInterface;
use Chill\PersonBundle\Templating\Entity\ClosingMotiveRender;
use Doctrine\ORM\EntityManagerInterface;
/**
* @internal
*
* @coversNothing
*/
class ByClosingMotiveAggregatorTest extends AbstractAggregatorTest
{
private ClosingMotiveRender $closingMotiveRender;
private ClosingMotiveRepositoryInterface $closingMotiveRepository;
protected function setUp(): void
{
parent::setUp();
self::bootKernel();
$this->closingMotiveRender = self::$container->get(ClosingMotiveRender::class);
$this->closingMotiveRepository = self::$container->get(ClosingMotiveRepositoryInterface::class);
}
public function getAggregator()
{
return new ByClosingMotiveAggregator(
$this->closingMotiveRepository,
$this->closingMotiveRender
);
}
public function getFormData()
{
return [
[],
];
}
public function getQueryBuilders()
{
self::bootKernel();
$em = self::$container->get(EntityManagerInterface::class);
$qb = $em->createQueryBuilder()
->select('COUNT(DISTINCT acpstephistory.id) As export_result')
->from(AccompanyingPeriodStepHistory::class, 'acpstephistory')
->join('acpstephistory.period', 'acp');
return [
$qb,
];
}
}

View File

@@ -0,0 +1,61 @@
<?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\Aggregator\AccompanyingPeriodStepHistoryAggregators;
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodStepHistory;
use Chill\PersonBundle\Export\Enum\DateGroupingChoiceEnum;
use Doctrine\ORM\EntityManagerInterface;
use Chill\PersonBundle\Export\Aggregator\AccompanyingPeriodStepHistoryAggregators\ByDateAggregator;
/**
* @internal
*
* @coversNothing
*/
class ByDateAggregatorTest extends AbstractAggregatorTest
{
public function getAggregator()
{
return new ByDateAggregator();
}
public function getFormData()
{
return [
[
'frequency' => DateGroupingChoiceEnum::YEAR->value,
],
[
'frequency' => DateGroupingChoiceEnum::WEEK->value,
],
[
'frequency' => DateGroupingChoiceEnum::MONTH->value,
],
];
}
public function getQueryBuilders()
{
self::bootKernel();
$em = self::$container->get(EntityManagerInterface::class);
$qb = $em->createQueryBuilder()
->select('COUNT(DISTINCT acpstephistory.id) As export_result')
->from(AccompanyingPeriodStepHistory::class, 'acpstephistory')
->join('acpstephistory.period', 'acp');
return [
$qb,
];
}
}

View File

@@ -0,0 +1,58 @@
<?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\Aggregator\AccompanyingPeriodStepHistoryAggregators;
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodStepHistory;
use Chill\PersonBundle\Export\Aggregator\AccompanyingPeriodStepHistoryAggregators\ByStepAggregator;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
/**
* @internal
*
* @coversNothing
*/
class ByStepAggregatorTest extends AbstractAggregatorTest
{
public function getAggregator()
{
$translator = new class () implements TranslatorInterface {
public function trans(string $id, array $parameters = [], ?string $domain = null, ?string $locale = null)
{
return $id;
}
};
return new ByStepAggregator($translator);
}
public function getFormData()
{
return [[]];
}
public function getQueryBuilders()
{
self::bootKernel();
$em = self::$container->get(EntityManagerInterface::class);
$qb = $em->createQueryBuilder()
->select('COUNT(DISTINCT acpstephistory.id) As export_result')
->from(AccompanyingPeriodStepHistory::class, 'acpstephistory')
->join('acpstephistory.period', 'acp');
return [
$qb,
];
}
}

View File

@@ -0,0 +1,48 @@
<?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 src\Bundle\ChillPersonBundle\Tests\Export\Export;
use Chill\MainBundle\Test\Export\AbstractExportTest;
use Chill\PersonBundle\Export\Declarations;
use Chill\PersonBundle\Export\Export\CountAccompanyingCourseStepHistory;
use Doctrine\ORM\EntityManagerInterface;
/**
* @internal
*
* @coversNothing
*/
final class CountAccompanyingCourseStepHistoryTest extends AbstractExportTest
{
protected function setUp(): void
{
self::bootKernel();
}
public function getExport()
{
$em = self::$container->get(EntityManagerInterface::class);
yield new CountAccompanyingCourseStepHistory($em, $this->getParameters(true));
yield new CountAccompanyingCourseStepHistory($em, $this->getParameters(false));
}
public function getFormData(): array
{
return [[]];
}
public function getModifiersCombination()
{
return [[Declarations::ACP_TYPE], [Declarations::ACP_TYPE, Declarations::ACP_STEP_HISTORY]];
}
}

View File

@@ -33,7 +33,7 @@ final class CountAccompanyingPeriodWorkAssociatePersonOnWorkTest extends Abstrac
$em = self::getContainer()->get(EntityManagerInterface::class);
yield new CountAccompanyingPeriodWorkAssociatePersonOnWork($em, $this->getParameters(true));
yield new CountAccompanyingPeriodWorkAssociatePersonOnwork($em, $this->getParameters(false));
yield new CountAccompanyingPeriodWorkAssociatePersonOnWork($em, $this->getParameters(false));
}
public function getFormData(): array

View File

@@ -0,0 +1,67 @@
<?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\Filter\AccompanyingCourseFilters;
use Chill\MainBundle\Service\RollingDate\RollingDate;
use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface;
use Chill\MainBundle\Test\Export\AbstractFilterTest;
use Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\HasTemporaryLocationFilter;
use Doctrine\ORM\EntityManagerInterface;
/**
* @internal
*
* @coversNothing
*/
class HasTemporaryLocationFilterTest extends AbstractFilterTest
{
private RollingDateConverterInterface $rollingDateConverter;
protected function setUp(): void
{
self::bootKernel();
$this->rollingDateConverter = self::$container->get(RollingDateConverterInterface::class);
}
public function getFilter()
{
return new HasTemporaryLocationFilter($this->rollingDateConverter);
}
public function getFormData()
{
return [
[
'having_temporarily' => true,
'calc_date' => new RollingDate(RollingDate::T_TODAY),
],
[
'having_temporarily' => false,
'calc_date' => new RollingDate(RollingDate::T_TODAY),
],
];
}
public function getQueryBuilders()
{
self::bootKernel();
$em = self::$container->get(EntityManagerInterface::class);
return [
$em->createQueryBuilder()
->from('ChillPersonBundle:AccompanyingPeriod', 'acp')
->select('acp.id'),
];
}
}

View File

@@ -0,0 +1,66 @@
<?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\Filter\AccompanyingCourseFilters;
use Chill\MainBundle\Service\RollingDate\RollingDate;
use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface;
use Chill\MainBundle\Test\Export\AbstractFilterTest;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\NotAssociatedWithAReferenceAddressFilter;
use Doctrine\ORM\EntityManagerInterface;
use Prophecy\PhpUnit\ProphecyTrait;
/**
* @internal
*
* @coversNothing
*/
class NotAssociatedWithAReferenceAddressFilterTest extends AbstractFilterTest
{
use ProphecyTrait;
public function getFilter()
{
$dateConverter = new class () implements RollingDateConverterInterface {
public function convert(?RollingDate $rollingDate): ?\DateTimeImmutable
{
if (null === $rollingDate) {
return null;
}
return new \DateTimeImmutable('now');
}
};
return new NotAssociatedWithAReferenceAddressFilter($dateConverter);
}
public function getFormData()
{
return [
['date_calc' => new RollingDate(RollingDate::T_TODAY)],
];
}
public function getQueryBuilders()
{
self::bootKernel();
$em = self::$container->get(EntityManagerInterface::class);
return [
$em->createQueryBuilder()
->select('acp.id')
->from(AccompanyingPeriod::class, 'acp'),
];
}
}

View File

@@ -0,0 +1,89 @@
<?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 src\Bundle\ChillPersonBundle\Tests\Export\Filter\AccompanyingCourseFilters;
use Chill\MainBundle\Entity\User;
use Chill\MainBundle\Service\RollingDate\RollingDate;
use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface;
use Chill\MainBundle\Templating\Entity\UserRender;
use Chill\MainBundle\Test\Export\AbstractFilterTest;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\ReferrerFilterBetweenDates;
use Doctrine\ORM\EntityManagerInterface;
/**
* @internal
*
* @coversNothing
*/
class ReferrerFilterBetweenDatesTest extends AbstractFilterTest
{
private RollingDateConverterInterface $rollingDateConverter;
private UserRender $userRender;
protected function setUp(): void
{
parent::setUp();
self::bootKernel();
$this->rollingDateConverter = self::$container->get(RollingDateConverterInterface::class);
$this->userRender = self::$container->get(UserRender::class);
}
public function getFilter()
{
return new ReferrerFilterBetweenDates($this->rollingDateConverter, $this->userRender);
}
public function getFormData()
{
self:self::bootKernel();
$em = self::$container->get(EntityManagerInterface::class);
$users = $em->createQueryBuilder()
->from(User::class, 'u')
->select('u')
->getQuery()
->setMaxResults(1)
->getResult();
return [
[
'accepted_referrers' => $users[0],
'start_date' => new RollingDate(RollingDate::T_YEAR_PREVIOUS_START),
'end_date' => new RollingDate(RollingDate::T_TODAY),
],
];
}
public function getQueryBuilders()
{
self::bootKernel();
$em = self::$container->get(EntityManagerInterface::class);
yield $em->createQueryBuilder()
->from(AccompanyingPeriod::class, 'acp')
->select('acp.id');
$qb = $em->createQueryBuilder();
$qb
->from(AccompanyingPeriod\AccompanyingPeriodWork::class, 'acpw')
->join('acpw.accompanyingPeriod', 'acp')
->join('acp.participations', 'acppart')
->join('acppart.person', 'person')
;
$qb->select('COUNT(DISTINCT acpw.id) as export_result');
yield $qb;
}
}

View File

@@ -31,7 +31,7 @@ final class ReferrerFilterTest extends AbstractFilterTest
{
self::bootKernel();
$this->filter = self::getContainer()->get('chill.person.export.filter_referrer');
$this->filter = self::getContainer()->get(ReferrerFilter::class);
}
public function getFilter()

View File

@@ -0,0 +1,67 @@
<?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 src\Bundle\ChillPersonBundle\Tests\Export\Filter\AccompanyingPeriodStepHistoryFilters;
use Chill\MainBundle\Service\RollingDate\RollingDate;
use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface;
use Chill\MainBundle\Test\Export\AbstractFilterTest;
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodStepHistory;
use Chill\PersonBundle\Export\Filter\AccompanyingPeriodStepHistoryFilters\ByDateFilter;
use Doctrine\ORM\EntityManagerInterface;
/**
* @internal
*
* @coversNothing
*/
class ByDateFilterTest extends AbstractFilterTest
{
private RollingDateConverterInterface $rollingDateConverter;
protected function setUp(): void
{
parent::setUp();
self::bootKernel();
$this->rollingDateConverter = self::$container->get(RollingDateConverterInterface::class);
}
public function getFilter()
{
return new ByDateFilter($this->rollingDateConverter);
}
public function getFormData()
{
return [
[
'start_date' => new RollingDate(RollingDate::T_YEAR_CURRENT_START),
'end_date' => new RollingDate(RollingDate::T_TODAY),
],
];
}
public function getQueryBuilders()
{
self::bootKernel();
$em = self::$container->get(EntityManagerInterface::class);
$qb = $em->createQueryBuilder()
->select('COUNT(DISTINCT acpstephistory.id) As export_result')
->from(AccompanyingPeriodStepHistory::class, 'acpstephistory')
->join('acpstephistory.period', 'acp');
return [
$qb,
];
}
}

View File

@@ -0,0 +1,66 @@
<?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 src\Bundle\ChillPersonBundle\Tests\Export\Filter\AccompanyingPeriodStepHistoryFilters;
use Chill\MainBundle\Test\Export\AbstractFilterTest;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodStepHistory;
use Chill\PersonBundle\Export\Filter\AccompanyingPeriodStepHistoryFilters\ByStepFilter;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
/**
* @internal
*
* @coversNothing
*/
class ByStepFilterTest extends AbstractFilterTest
{
public function getFilter()
{
$translator = new class () implements TranslatorInterface {
public function trans(string $id, array $parameters = [], ?string $domain = null, ?string $locale = null)
{
return $id;
}
};
return new ByStepFilter($translator);
}
public function getFormData()
{
return [
[
'steps' => [AccompanyingPeriod::STEP_CONFIRMED, AccompanyingPeriod::STEP_CONFIRMED_INACTIVE_LONG],
],
[
'steps' => [AccompanyingPeriod::STEP_CLOSED],
],
];
}
public function getQueryBuilders()
{
self::bootKernel();
$em = self::$container->get(EntityManagerInterface::class);
$qb = $em->createQueryBuilder()
->select('COUNT(DISTINCT acpstephistory.id) As export_result')
->from(AccompanyingPeriodStepHistory::class, 'acpstephistory')
->join('acpstephistory.period', 'acp');
return [
$qb,
];
}
}

View File

@@ -0,0 +1,63 @@
<?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 Export\Filter\PersonFilters;
use Chill\MainBundle\Service\RollingDate\RollingDate;
use Chill\MainBundle\Test\Export\AbstractFilterTest;
use Chill\PersonBundle\Entity\Person;
use Chill\PersonBundle\Export\Filter\PersonFilters\WithParticipationBetweenDatesFilter;
use Doctrine\ORM\EntityManagerInterface;
/**
* @internal
*
* @coversNothing
*/
final class WithParticipationBetweenDatesFilterTest extends AbstractFilterTest
{
private WithParticipationBetweenDatesFilter $filter;
protected function setUp(): void
{
self::bootKernel();
$this->filter = self::$container->get(WithParticipationBetweenDatesFilter::class);
}
public function getFilter()
{
return $this->filter;
}
public function getFormData()
{
return [
[
'date_after' => new RollingDate(RollingDate::T_YEAR_CURRENT_START),
'date_before' => new RollingDate(RollingDate::T_TODAY),
],
];
}
public function getQueryBuilders()
{
self::bootKernel();
$em = self::$container->get(EntityManagerInterface::class);
return [
$em->createQueryBuilder()
->select('person.id')
->from(Person::class, 'person'),
];
}
}

View File

@@ -561,8 +561,8 @@ final class MembersEditorTest extends TestCase
}
private function buildMembersEditorFactory(
EventDispatcherInterface $eventDispatcher = null,
ValidatorInterface $validator = null
?EventDispatcherInterface $eventDispatcher = null,
?ValidatorInterface $validator = null
) {
if (null === $eventDispatcher) {
$double = $this->getProphet()->prophesize();

View File

@@ -521,7 +521,7 @@ class AccompanyingPeriodACLAwareRepositoryTest extends KernelTestCase
/**
* @param array<Scope> $scopes
*/
private function buildPeriod(Person $person, array $scopes, null|User $creator, bool $confirm): AccompanyingPeriod
private function buildPeriod(Person $person, array $scopes, User|null $creator, bool $confirm): AccompanyingPeriod
{
$period = new AccompanyingPeriod();
$period->addPerson($person);

View File

@@ -155,7 +155,7 @@ final class PersonVoterTest extends KernelTestCase
*
* @return \Symfony\Component\Security\Core\Authentication\Token\TokenInterface
*/
protected function prepareToken(array $permissions = null)
protected function prepareToken(?array $permissions = null)
{
$token = $this->prophet->prophesize();
$token

View File

@@ -237,12 +237,12 @@ final class PersonDocGenNormalizerTest extends KernelTestCase
}
private function buildNormalizer(
PersonRender $personRender = null,
RelationshipRepository $relationshipRepository = null,
TranslatorInterface $translator = null,
TranslatableStringHelper $translatableStringHelper = null,
NormalizerInterface $normalizer = null,
SummaryBudgetInterface $summaryBudget = null
?PersonRender $personRender = null,
?RelationshipRepository $relationshipRepository = null,
?TranslatorInterface $translator = null,
?TranslatableStringHelper $translatableStringHelper = null,
?NormalizerInterface $normalizer = null,
?SummaryBudgetInterface $summaryBudget = null
): PersonDocGenNormalizer {
if (null === $summaryBudget) {
$summaryBudget = $this->prophesize(SummaryBudgetInterface::class);
@@ -274,11 +274,11 @@ final class PersonDocGenNormalizerTest extends KernelTestCase
}
private function buildPersonNormalizer(
PersonRender $personRender = null,
RelationshipRepository $relationshipRepository = null,
TranslatorInterface $translator = null,
TranslatableStringHelper $translatableStringHelper = null,
SummaryBudgetInterface $summaryBudget = null
?PersonRender $personRender = null,
?RelationshipRepository $relationshipRepository = null,
?TranslatorInterface $translator = null,
?TranslatableStringHelper $translatableStringHelper = null,
?SummaryBudgetInterface $summaryBudget = null
): PersonDocGenNormalizer {
if (null === $relationshipRepository) {
$relationshipRepository = $this->prophesize(RelationshipRepository::class);

View File

@@ -341,20 +341,20 @@ final class PersonContextTest extends KernelTestCase
}
private function buildPersonContext(
AuthorizationHelperInterface $authorizationHelper = null,
BaseContextData $baseContextData = null,
CenterResolverManagerInterface $centerResolverManager = null,
DocumentCategoryRepository $documentCategoryRepository = null,
EntityManagerInterface $em = null,
NormalizerInterface $normalizer = null,
ParameterBagInterface $parameterBag = null,
ScopeRepositoryInterface $scopeRepository = null,
Security $security = null,
TranslatorInterface $translator = null,
TranslatableStringHelperInterface $translatableStringHelper = null,
ThirdPartyRender $thirdPartyRender = null,
ThirdPartyRepository $thirdPartyRepository = null,
ResidentialAddressRepository $residentialAddressRepository = null
?AuthorizationHelperInterface $authorizationHelper = null,
?BaseContextData $baseContextData = null,
?CenterResolverManagerInterface $centerResolverManager = null,
?DocumentCategoryRepository $documentCategoryRepository = null,
?EntityManagerInterface $em = null,
?NormalizerInterface $normalizer = null,
?ParameterBagInterface $parameterBag = null,
?ScopeRepositoryInterface $scopeRepository = null,
?Security $security = null,
?TranslatorInterface $translator = null,
?TranslatableStringHelperInterface $translatableStringHelper = null,
?ThirdPartyRender $thirdPartyRender = null,
?ThirdPartyRepository $thirdPartyRepository = null,
?ResidentialAddressRepository $residentialAddressRepository = null
): PersonContext {
if (null === $authorizationHelper) {
$authorizationHelper = $this->prophesize(AuthorizationHelperInterface::class)->reveal();

View File

@@ -39,9 +39,9 @@ class AccompanyingPeriodWorkEvaluationGenericDocProviderTest extends KernelTestC
* @dataProvider provideSearchArguments
*/
public function testBuildFetchQueryForAccompanyingPeriod(
\DateTimeImmutable $startDate = null,
\DateTimeImmutable $endDate = null,
string $content = null
?\DateTimeImmutable $startDate = null,
?\DateTimeImmutable $endDate = null,
?string $content = null
): void {
$period = $this->entityManager->createQuery('SELECT a FROM '.AccompanyingPeriod::class.' a')
->setMaxResults(1)