mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 07:03:49 +00:00
Merge branch '111_exports_suite' into 641_issues_with_children
This commit is contained in:
@@ -0,0 +1,86 @@
|
||||
<?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\Controller;
|
||||
|
||||
use Chill\MainBundle\Test\PrepareClientTrait;
|
||||
use Chill\PersonBundle\Entity\SocialWork\Evaluation;
|
||||
use Chill\PersonBundle\Entity\SocialWork\SocialAction;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @coversNothing
|
||||
*/
|
||||
final class SocialWorkEvaluationApiControllerTest extends WebTestCase
|
||||
{
|
||||
use PrepareClientTrait;
|
||||
|
||||
private EntityManagerInterface $em;
|
||||
|
||||
private ?Evaluation $evaluationToReset = null;
|
||||
|
||||
protected function tearDown(): void
|
||||
{
|
||||
if (null === $this->evaluationToReset) {
|
||||
return;
|
||||
}
|
||||
|
||||
self::bootKernel();
|
||||
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
$evaluation = $em->find(Evaluation::class, $this->evaluationToReset->getId());
|
||||
|
||||
$evaluation->setActive(true);
|
||||
$em->flush();
|
||||
}
|
||||
|
||||
public function dataGenerateSocialActionWithEvaluations(): iterable
|
||||
{
|
||||
self::bootKernel();
|
||||
|
||||
$this->em = self::$container->get(EntityManagerInterface::class);
|
||||
|
||||
/** @var SocialAction $socialAction */
|
||||
$socialAction = $this->em->createQuery(
|
||||
'SELECT s FROM ' . SocialAction::class . ' s WHERE SIZE(s.evaluations) >= 2'
|
||||
)
|
||||
->setMaxResults(1)
|
||||
->getSingleResult();
|
||||
|
||||
// set the first evaluation as inactive and save
|
||||
$this->evaluationToReset = $socialAction->getEvaluations()->first();
|
||||
$this->evaluationToReset->setActive(false);
|
||||
|
||||
$this->em->flush();
|
||||
|
||||
yield [$socialAction, $this->evaluationToReset];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider dataGenerateSocialActionWithEvaluations
|
||||
*/
|
||||
public function testListEvaluationBySocialAction(SocialAction $action, Evaluation $inactiveEvaluation): void
|
||||
{
|
||||
$client = $this->getClientAuthenticated();
|
||||
|
||||
$client->request('GET', sprintf('/api/1.0/person/social-work/evaluation/by-social-action/%d.json', $action->getId()));
|
||||
|
||||
$this->assertResponseIsSuccessful();
|
||||
|
||||
$content = json_decode($client->getResponse()->getContent(), true);
|
||||
|
||||
$ids = array_map(static fn (array $item) => $item['id'], $content['results']);
|
||||
|
||||
$this->assertNotContains($inactiveEvaluation->getId(), $ids);
|
||||
}
|
||||
}
|
@@ -29,6 +29,38 @@ use function count;
|
||||
*/
|
||||
final class AccompanyingPeriodTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function testChangeStepKeepHistory()
|
||||
{
|
||||
$period = new AccompanyingPeriod();
|
||||
|
||||
$this->assertCount(0, $period->getStepHistories(), 'at initialization, period should not have any step history');
|
||||
|
||||
$period->setStep(AccompanyingPeriod::STEP_DRAFT);
|
||||
|
||||
$this->assertCount(0, $period->getStepHistories(), 're applying a draft should not create a history');
|
||||
|
||||
$period->setStep(AccompanyingPeriod::STEP_CONFIRMED);
|
||||
|
||||
$this->assertCount(1, $period->getStepHistories());
|
||||
$this->assertEquals(AccompanyingPeriod::STEP_CONFIRMED, $period->getStepHistories()->first()->getStep());
|
||||
|
||||
$period->setOpeningDate($aMonthAgo = new DateTime('1 month ago'));
|
||||
|
||||
$this->assertCount(1, $period->getStepHistories());
|
||||
$this->assertEquals($aMonthAgo, $period->getStepHistories()->first()->getStartDate(), 'when changing the opening date, the start date of the first history should change');
|
||||
|
||||
$period->setOpeningDate($tenDaysAgo = new DateTime('10 days ago'));
|
||||
|
||||
$this->assertCount(1, $period->getStepHistories());
|
||||
$this->assertEquals($tenDaysAgo, $period->getStepHistories()->first()->getStartDate(), 'when changing the opening date, the start date of the first history should change');
|
||||
|
||||
$period->setStep(AccompanyingPeriod::STEP_CLOSED);
|
||||
$this->assertCount(2, $period->getStepHistories());
|
||||
|
||||
$period->setOpeningDate($tomorrow = new DateTime('tomorrow'));
|
||||
$this->assertEquals($tenDaysAgo, $period->getStepHistories()->first()->getStartDate(), 'when changing the opening date to a later one and no history after, start date should change');
|
||||
}
|
||||
|
||||
public function testClosingEqualOpening()
|
||||
{
|
||||
$datetime = new DateTime('now');
|
||||
|
@@ -39,7 +39,9 @@ final class DurationAggregatorTest extends AbstractAggregatorTest
|
||||
public function getFormData(): array
|
||||
{
|
||||
return [
|
||||
[],
|
||||
['precision' => 'day'],
|
||||
['precision' => 'week'],
|
||||
['precision' => 'month'],
|
||||
];
|
||||
}
|
||||
|
||||
|
@@ -14,6 +14,7 @@ namespace Chill\PersonBundle\Tests\Export\Aggregator\AccompanyingCourseAggregato
|
||||
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\GeographicalUnitStatAggregator;
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
/**
|
||||
@@ -38,8 +39,9 @@ final class GeographicalUnitStatAggregatorTest extends AbstractAggregatorTest
|
||||
|
||||
public function getFormData(): array
|
||||
{
|
||||
// TODO: add geographical unit stat into fixtures and provide a level
|
||||
return [
|
||||
[],
|
||||
['date_calc' => new DateTimeImmutable('today'), 'level' => null],
|
||||
];
|
||||
}
|
||||
|
||||
|
@@ -14,6 +14,7 @@ namespace Chill\PersonBundle\Tests\Export\Aggregator\AccompanyingCourseAggregato
|
||||
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\ReferrerAggregator;
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
/**
|
||||
@@ -39,7 +40,7 @@ final class ReferrerAggregatorTest extends AbstractAggregatorTest
|
||||
public function getFormData(): array
|
||||
{
|
||||
return [
|
||||
[],
|
||||
['date_calc' => new DateTimeImmutable('now')],
|
||||
];
|
||||
}
|
||||
|
||||
|
@@ -12,7 +12,7 @@ declare(strict_types=1);
|
||||
namespace Chill\PersonBundle\Tests\Export\Filter\AccompanyingCourseFilters;
|
||||
|
||||
use Chill\MainBundle\Test\Export\AbstractFilterTest;
|
||||
use Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\CurrentUserJobFilter;
|
||||
use Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\UserJobFilter;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
/**
|
||||
@@ -21,7 +21,7 @@ use Doctrine\ORM\EntityManagerInterface;
|
||||
*/
|
||||
final class CurrentUserJobFilterTest extends AbstractFilterTest
|
||||
{
|
||||
private CurrentUserJobFilter $filter;
|
||||
private UserJobFilter $filter;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
@@ -12,7 +12,7 @@ declare(strict_types=1);
|
||||
namespace Chill\PersonBundle\Tests\Export\Filter\AccompanyingCourseFilters;
|
||||
|
||||
use Chill\MainBundle\Test\Export\AbstractFilterTest;
|
||||
use Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\CurrentUserScopeFilter;
|
||||
use Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\UserScopeFilter;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
/**
|
||||
@@ -21,7 +21,7 @@ use Doctrine\ORM\EntityManagerInterface;
|
||||
*/
|
||||
final class CurrentUserScopeFilterTest extends AbstractFilterTest
|
||||
{
|
||||
private CurrentUserScopeFilter $filter;
|
||||
private UserScopeFilter $filter;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
@@ -0,0 +1,46 @@
|
||||
<?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\Serializer\Normalizer;
|
||||
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\Origin;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @coversNothing
|
||||
*/
|
||||
final class AccompanyingPeriodOriginNormalizerTest extends KernelTestCase
|
||||
{
|
||||
private NormalizerInterface $normalizer;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
self::bootKernel();
|
||||
$this->normalizer = self::$container->get(NormalizerInterface::class);
|
||||
}
|
||||
|
||||
public function testNormalization()
|
||||
{
|
||||
$o = new Origin();
|
||||
|
||||
$normalized = $this->normalizer->normalize(
|
||||
$o,
|
||||
'json',
|
||||
['groups' => ['read']]
|
||||
);
|
||||
|
||||
$this->assertIsArray($normalized);
|
||||
$this->assertArrayHasKey('type', $normalized);
|
||||
$this->assertEquals('origin', $normalized['type']);
|
||||
}
|
||||
}
|
@@ -60,7 +60,7 @@ final class AccompanyingPeriodWorkDocGenNormalizerTest extends KernelTestCase
|
||||
}
|
||||
}
|
||||
|
||||
public function testNormlalize()
|
||||
public function testNormalize()
|
||||
{
|
||||
$work = new AccompanyingPeriodWork();
|
||||
$work
|
||||
|
@@ -0,0 +1,46 @@
|
||||
<?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\Serializer\Normalizer;
|
||||
|
||||
use Chill\PersonBundle\Entity\SocialWork\SocialAction;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @coversNothing
|
||||
*/
|
||||
final class SocialActionNormalizerTest extends KernelTestCase
|
||||
{
|
||||
private NormalizerInterface $normalizer;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
self::bootKernel();
|
||||
$this->normalizer = self::$container->get(NormalizerInterface::class);
|
||||
}
|
||||
|
||||
public function testNormalization()
|
||||
{
|
||||
$sa = new SocialAction();
|
||||
|
||||
$normalized = $this->normalizer->normalize(
|
||||
$sa,
|
||||
'json',
|
||||
['groups' => ['read']]
|
||||
);
|
||||
|
||||
$this->assertIsArray($normalized);
|
||||
$this->assertArrayHasKey('type', $normalized);
|
||||
$this->assertEquals('social_work_social_action', $normalized['type']);
|
||||
}
|
||||
}
|
@@ -0,0 +1,46 @@
|
||||
<?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\Serializer\Normalizer;
|
||||
|
||||
use Chill\PersonBundle\Entity\SocialWork\SocialIssue;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @coversNothing
|
||||
*/
|
||||
final class SocialIssueNormalizerTest extends KernelTestCase
|
||||
{
|
||||
private NormalizerInterface $normalizer;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
self::bootKernel();
|
||||
$this->normalizer = self::$container->get(NormalizerInterface::class);
|
||||
}
|
||||
|
||||
public function testNormalization()
|
||||
{
|
||||
$si = new SocialIssue();
|
||||
|
||||
$normalized = $this->normalizer->normalize(
|
||||
$si,
|
||||
'json',
|
||||
['groups' => ['read']]
|
||||
);
|
||||
|
||||
$this->assertIsArray($normalized);
|
||||
$this->assertArrayHasKey('type', $normalized);
|
||||
$this->assertEquals('social_issue', $normalized['type']);
|
||||
}
|
||||
}
|
@@ -0,0 +1,265 @@
|
||||
<?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 Service\DocGenerator;
|
||||
|
||||
use Chill\DocGeneratorBundle\Entity\DocGeneratorTemplate;
|
||||
use Chill\DocGeneratorBundle\Service\Context\BaseContextData;
|
||||
use Chill\DocStoreBundle\Entity\DocumentCategory;
|
||||
use Chill\DocStoreBundle\Entity\PersonDocument;
|
||||
use Chill\DocStoreBundle\Entity\StoredObject;
|
||||
use Chill\DocStoreBundle\Repository\DocumentCategoryRepository;
|
||||
use Chill\DocStoreBundle\Security\Authorization\PersonDocumentVoter;
|
||||
use Chill\MainBundle\Entity\Center;
|
||||
use Chill\MainBundle\Entity\Scope;
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Chill\MainBundle\Security\Authorization\AuthorizationHelperInterface;
|
||||
use Chill\MainBundle\Security\Resolver\CenterResolverManagerInterface;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\PersonBundle\Service\DocGenerator\PersonContext;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Prophecy\Argument;
|
||||
use Prophecy\Exception\Prediction\FailedPredictionException;
|
||||
use Prophecy\PhpUnit\ProphecyTrait;
|
||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
|
||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
use Symfony\Component\Security\Core\User\UserInterface;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
use function count;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @coversNothing
|
||||
*/
|
||||
final class PersonContextTest extends TestCase
|
||||
{
|
||||
use ProphecyTrait;
|
||||
|
||||
/**
|
||||
* Test that the build person context works in the case when 'form_show_scope' is false.
|
||||
*/
|
||||
public function testScopeDoNotShowScopeInForms()
|
||||
{
|
||||
$person = new Person();
|
||||
$docGen = (new DocGeneratorTemplate())
|
||||
->setName(['fr' => 'template']);
|
||||
|
||||
$parameter = new ParameterBag(['chill_main' => ['acl' => ['form_show_scopes' => false]]]);
|
||||
$em = $this->prophesize(EntityManagerInterface::class);
|
||||
$em->persist(Argument::type(PersonDocument::class))
|
||||
->should(static function ($calls, $object, $method) {
|
||||
if (1 !== count($calls)) {
|
||||
throw new FailedPredictionException(sprintf('the persist should be called exactly once, %d receivved', count($calls)));
|
||||
}
|
||||
|
||||
/** @var PersonDocument $personDocument */
|
||||
$personDocument = $calls[0]->getArguments()[0];
|
||||
|
||||
if (null !== $personDocument->getScope()) {
|
||||
throw new FailedPredictionException('the person document should not have any scope');
|
||||
}
|
||||
});
|
||||
|
||||
$personContext = $this->buildPersonContext(
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
$em->reveal(),
|
||||
null,
|
||||
$parameter
|
||||
);
|
||||
|
||||
$this->assertFalse($personContext->hasPublicForm($docGen, $person));
|
||||
|
||||
$personContext->storeGenerated(
|
||||
$docGen,
|
||||
new StoredObject(),
|
||||
$person,
|
||||
[]
|
||||
);
|
||||
}
|
||||
|
||||
public function testScopeScopeMustBeShownInFormsAndUserAccessMultipleScope()
|
||||
{
|
||||
$person = new Person();
|
||||
$docGen = (new DocGeneratorTemplate())
|
||||
->setName(['fr' => 'template']);
|
||||
$scope = new Scope();
|
||||
|
||||
$em = $this->prophesize(EntityManagerInterface::class);
|
||||
$em->persist(Argument::type(PersonDocument::class))
|
||||
->should(static function ($calls, $object, $method) use ($scope) {
|
||||
if (1 !== count($calls)) {
|
||||
throw new FailedPredictionException(sprintf('the persist should be called exactly once, %d receivved', count($calls)));
|
||||
}
|
||||
|
||||
/** @var PersonDocument $personDocument */
|
||||
$personDocument = $calls[0]->getArguments()[0];
|
||||
|
||||
if ($personDocument->getScope() !== $scope) {
|
||||
throw new FailedPredictionException('the person document should show the exactly prepared scope');
|
||||
}
|
||||
});
|
||||
|
||||
$authorizationHelper = $this->prophesize(AuthorizationHelperInterface::class);
|
||||
$authorizationHelper->getReachableScopes(Argument::type(UserInterface::class), PersonDocumentVoter::CREATE, Argument::type('array'))
|
||||
->willReturn([$scope, new Scope()]);
|
||||
|
||||
$personContext = $this->buildPersonContext(
|
||||
$authorizationHelper->reveal(),
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
$em->reveal(),
|
||||
);
|
||||
|
||||
$this->assertTrue($personContext->hasPublicForm($docGen, $person));
|
||||
|
||||
$personContext->storeGenerated(
|
||||
$docGen,
|
||||
new StoredObject(),
|
||||
$person,
|
||||
['scope' => $scope]
|
||||
);
|
||||
}
|
||||
|
||||
public function testScopeScopeMustBeShownInFormsAndUserAccessOneScope()
|
||||
{
|
||||
$person = new Person();
|
||||
$docGen = (new DocGeneratorTemplate())
|
||||
->setName(['fr' => 'template']);
|
||||
$scope = new Scope();
|
||||
|
||||
$em = $this->prophesize(EntityManagerInterface::class);
|
||||
$em->persist(Argument::type(PersonDocument::class))
|
||||
->should(static function ($calls, $object, $method) use ($scope) {
|
||||
if (1 !== count($calls)) {
|
||||
throw new FailedPredictionException(sprintf('the persist should be called exactly once, %d receivved', count($calls)));
|
||||
}
|
||||
|
||||
/** @var PersonDocument $personDocument */
|
||||
$personDocument = $calls[0]->getArguments()[0];
|
||||
|
||||
if ($personDocument->getScope() !== $scope) {
|
||||
throw new FailedPredictionException('the person document should show the exactly prepared scope');
|
||||
}
|
||||
});
|
||||
|
||||
$authorizationHelper = $this->prophesize(AuthorizationHelperInterface::class);
|
||||
$authorizationHelper->getReachableScopes(Argument::type(UserInterface::class), PersonDocumentVoter::CREATE, Argument::type('array'))
|
||||
->willReturn([$scope]);
|
||||
|
||||
$personContext = $this->buildPersonContext(
|
||||
$authorizationHelper->reveal(),
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
$em->reveal(),
|
||||
);
|
||||
|
||||
$this->assertTrue($personContext->hasPublicForm($docGen, $person));
|
||||
|
||||
$personContext->storeGenerated(
|
||||
$docGen,
|
||||
new StoredObject(),
|
||||
$person,
|
||||
['scope' => $scope]
|
||||
);
|
||||
}
|
||||
|
||||
private function buildPersonContext(
|
||||
?AuthorizationHelperInterface $authorizationHelper = null,
|
||||
?BaseContextData $baseContextData = null,
|
||||
?CenterResolverManagerInterface $centerResolverManager = null,
|
||||
?DocumentCategoryRepository $documentCategoryRepository = null,
|
||||
?EntityManagerInterface $em = null,
|
||||
?NormalizerInterface $normalizer = null,
|
||||
?ParameterBagInterface $parameterBag = null,
|
||||
?Security $security = null,
|
||||
?TranslatorInterface $translator = null,
|
||||
?TranslatableStringHelperInterface $translatableStringHelper = null
|
||||
): PersonContext {
|
||||
if (null === $authorizationHelper) {
|
||||
$authorizationHelper = $this->prophesize(AuthorizationHelperInterface::class)->reveal();
|
||||
}
|
||||
|
||||
if (null === $baseContextData) {
|
||||
$baseContextData = $this->prophesize(BaseContextData::class)->reveal();
|
||||
}
|
||||
|
||||
if (null === $centerResolverManager) {
|
||||
$centerResolverManager = $this->prophesize(CenterResolverManagerInterface::class);
|
||||
$centerResolverManager->resolveCenters(Argument::any(), Argument::any())
|
||||
->willReturn([new Center()]);
|
||||
$centerResolverManager = $centerResolverManager->reveal();
|
||||
}
|
||||
|
||||
if (null === $documentCategoryRepository) {
|
||||
$documentCategoryRepository = $this->prophesize(DocumentCategoryRepository::class);
|
||||
$documentCategoryRepository->find(Argument::type('integer'))->willReturn(
|
||||
new DocumentCategory(PersonDocument::class, 1)
|
||||
);
|
||||
$documentCategoryRepository = $documentCategoryRepository->reveal();
|
||||
}
|
||||
|
||||
if (null === $em) {
|
||||
$em = $this->prophesize(EntityManagerInterface::class)->reveal();
|
||||
}
|
||||
|
||||
if (null === $normalizer) {
|
||||
$normalizer = $this->prophesize(NormalizerInterface::class);
|
||||
$normalizer->normalize(Argument::type(Person::class), 'docgen', Argument::any())
|
||||
->willReturn(['type' => 'person']);
|
||||
$normalizer = $normalizer->reveal();
|
||||
}
|
||||
|
||||
if (null === $parameterBag) {
|
||||
$parameterBag = new ParameterBag(['chill_main' => ['acl' => ['form_show_scopes' => true]]]);
|
||||
}
|
||||
|
||||
if (null === $security) {
|
||||
$security = $this->prophesize(Security::class);
|
||||
$security->getUser()->willReturn(new User());
|
||||
$security = $security->reveal();
|
||||
}
|
||||
|
||||
if (null === $translator) {
|
||||
$translator = $this->prophesize(TranslatorInterface::class)->reveal();
|
||||
}
|
||||
|
||||
if (null === $translatableStringHelper) {
|
||||
$translatableStringHelper = $this->prophesize(TranslatableStringHelperInterface::class);
|
||||
// return only the 'fr' key
|
||||
$translatableStringHelper->localize(Argument::type('array'))->will(static function ($args) {
|
||||
return $args[0]['fr'];
|
||||
});
|
||||
$translatableStringHelper = $translatableStringHelper->reveal();
|
||||
}
|
||||
|
||||
return new PersonContext(
|
||||
$authorizationHelper,
|
||||
$baseContextData,
|
||||
$centerResolverManager,
|
||||
$documentCategoryRepository,
|
||||
$em,
|
||||
$normalizer,
|
||||
$parameterBag,
|
||||
$security,
|
||||
$translator,
|
||||
$translatableStringHelper
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user