apply more cs rules for php-cs

This commit is contained in:
2023-10-17 13:27:03 +02:00
parent 0b0cbed9db
commit bc2041cbdd
1485 changed files with 8169 additions and 9620 deletions

View File

@@ -28,7 +28,6 @@ use Chill\MainBundle\Repository\ScopeRepositoryInterface;
use Chill\MainBundle\Security\Authorization\AuthorizationHelperInterface;
use Chill\MainBundle\Security\Resolver\CenterResolverManagerInterface;
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Entity\Person;
use Chill\PersonBundle\Repository\ResidentialAddressRepository;
use Chill\PersonBundle\Service\DocGenerator\AccompanyingPeriodContext;
@@ -37,7 +36,6 @@ use Chill\ThirdPartyBundle\Entity\ThirdParty;
use Chill\ThirdPartyBundle\Repository\ThirdPartyRepository;
use Chill\ThirdPartyBundle\Templating\Entity\ThirdPartyRender;
use Doctrine\ORM\EntityManagerInterface;
use PHPUnit\Framework\TestCase;
use Prophecy\Argument;
use Prophecy\Exception\Prediction\FailedPredictionException;
use Prophecy\PhpUnit\ProphecyTrait;
@@ -50,10 +48,10 @@ 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 KernelTestCase
@@ -61,17 +59,17 @@ final class PersonContextTest extends KernelTestCase
use ProphecyTrait;
/**
* This test run the methods executed when a document is generated:
* This test run the methods executed when a document is generated:.
*
* - normalized data from the form in a way that they are stored in message queue;
* - denormalize the data from the message queue,
* - and get the data, as they will be transmitted to the GeneratorDriver
*
* @param array $options the options, as they are stored in the DocGeneratorTemplate (the admin form data)
* @param Person $entity The entity from which the data will be extracted
* @param array $data The data, from the public form
* @param array $expectedNormalized, how the normalized data are expected (allow to check that this data will be compliant with the storage in messenger queue)
* @param array $options the options, as they are stored in the DocGeneratorTemplate (the admin form data)
* @param Person $entity The entity from which the data will be extracted
* @param array $data The data, from the public form
* @param callable $assertionsOnData some test that will be executed on the normalized data
*
* @dataProvider provideNormalizedData
*/
public function testContextGenerationDataNormalizeDenormalizeGetData(
@@ -93,7 +91,7 @@ final class PersonContextTest extends KernelTestCase
self::$container->get(DocumentCategoryRepository::class),
self::$container->get(EntityManagerInterface::class),
self::$container->get(NormalizerInterface::class),
(new ParameterBag(['chill_main' => ['acl' => ['form_show_scopes' => false]]])),
new ParameterBag(['chill_main' => ['acl' => ['form_show_scopes' => false]]]),
null,
self::$container->get(Security::class),
null,
@@ -102,8 +100,8 @@ final class PersonContextTest extends KernelTestCase
self::$container->get(ThirdPartyRepository::class)
);
$template = new DocGeneratorTemplate();
$template->setName(["fr" => "test"])->setContext(AccompanyingPeriodContext::class)
->setDescription("description")->setActive(true)
$template->setName(['fr' => 'test'])->setContext(AccompanyingPeriodContext::class)
->setDescription('description')->setActive(true)
->setOptions($options);
$normalized = $context->contextGenerationDataNormalize($template, $entity, $data);
@@ -122,27 +120,27 @@ final class PersonContextTest extends KernelTestCase
self::bootKernel();
$em = self::$container->get(EntityManagerInterface::class);
$thirdParty = $em->createQuery("SELECT t FROM " . ThirdParty::class . " t")
$thirdParty = $em->createQuery('SELECT t FROM '.ThirdParty::class.' t')
->setMaxResults(1)
->getSingleResult();
if (null === $thirdParty) {
throw new \RuntimeException("No thirdparty in database");
throw new \RuntimeException('No thirdparty in database');
}
$person = $em->createQuery("SELECT p FROM " . Person::class . " p")
$person = $em->createQuery('SELECT p FROM '.Person::class.' p')
->setMaxResults(1)
->getSingleResult();
if (null === $person) {
throw new \RuntimeException("No confirmed period in database");
throw new \RuntimeException('No confirmed period in database');
}
$category = self::$container->get(DocumentCategoryRepository::class)
->findAll()[0];
if (null === $category) {
throw new \RuntimeException("no document category in database");
throw new \RuntimeException('no document category in database');
}
yield [
@@ -167,7 +165,7 @@ final class PersonContextTest extends KernelTestCase
self::assertArrayHasKey('thirdParty', $data);
self::assertEquals($thirdParty->getId(), $data['thirdParty']['id']);
}
},
];
yield [
@@ -185,10 +183,10 @@ final class PersonContextTest extends KernelTestCase
'scope_id' => null,
'thirdParty' => null,
],
function ($data) use ($person, $thirdParty) {
function ($data) use ($person) {
self::assertArrayHasKey('person', $data);
self::assertEquals($person->getId(), $data['person']['id']);
}
},
];
}
@@ -205,8 +203,8 @@ final class PersonContextTest extends KernelTestCase
$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)));
if (1 !== \count($calls)) {
throw new FailedPredictionException(sprintf('the persist should be called exactly once, %d receivved', \count($calls)));
}
/** @var PersonDocument $personDocument */
@@ -247,8 +245,8 @@ final class PersonContextTest extends KernelTestCase
$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)));
if (1 !== \count($calls)) {
throw new FailedPredictionException(sprintf('the persist should be called exactly once, %d receivved', \count($calls)));
}
/** @var PersonDocument $personDocument */
@@ -291,8 +289,8 @@ final class PersonContextTest extends KernelTestCase
$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 received', count($calls)));
if (1 !== \count($calls)) {
throw new FailedPredictionException(sprintf('the persist should be called exactly once, %d received', \count($calls)));
}
/** @var PersonDocument $personDocument */
@@ -343,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();
@@ -435,7 +433,7 @@ final class PersonContextTest extends KernelTestCase
(new Person\ResidentialAddress())
->setAddress((new Address())
->setStreet('test street')
->setPostcode(new PostalCode()))
->setPostcode(new PostalCode())),
]);
$residentialAddressRepository = $residentialAddressRepository->reveal();
}