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

@@ -30,6 +30,7 @@ use Symfony\Contracts\Translation\TranslatorInterface;
/**
* @internal
*
* @coversNothing
*/
class AccompanyingPeriodContextTest extends KernelTestCase
@@ -86,17 +87,17 @@ class AccompanyingPeriodContextTest extends KernelTestCase
}
/**
* 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 AccompanyingPeriod $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 callable $assertionsOnData some test that will be executed on the normalized data
* @param array $options the options, as they are stored in the DocGeneratorTemplate (the admin form data)
* @param AccompanyingPeriod $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(
@@ -108,8 +109,8 @@ class AccompanyingPeriodContextTest extends KernelTestCase
): void {
$context = $this->buildContext();
$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);
@@ -128,28 +129,28 @@ class AccompanyingPeriodContextTest 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');
}
$period = $em->createQuery("SELECT a FROM " . AccompanyingPeriod::class . " a WHERE a.step = 'CONFIRMED'")
$period = $em->createQuery('SELECT a FROM '.AccompanyingPeriod::class." a WHERE a.step = 'CONFIRMED'")
->setMaxResults(1)
->getSingleResult();
if (null === $period) {
throw new \RuntimeException("No confirmed period in database");
throw new \RuntimeException('No confirmed period 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');
}
yield [
@@ -162,11 +163,11 @@ class AccompanyingPeriodContextTest extends KernelTestCase
'person2' => false,
'person2Label' => 'person2',
'thirdParty' => true,
'thirdPartyLabel' => '3party'
'thirdPartyLabel' => '3party',
],
$period,
[
'thirdParty' => $thirdParty
'thirdParty' => $thirdParty,
],
[
'thirdParty' => $thirdParty->getId(),
@@ -193,7 +194,7 @@ class AccompanyingPeriodContextTest extends KernelTestCase
'person2' => false,
'person2Label' => 'person2',
'thirdParty' => false,
'thirdPartyLabel' => '3party'
'thirdPartyLabel' => '3party',
],
$period,
[
@@ -224,7 +225,7 @@ class AccompanyingPeriodContextTest extends KernelTestCase
'person2' => true,
'person2Label' => 'person2',
'thirdParty' => true,
'thirdPartyLabel' => '3party'
'thirdPartyLabel' => '3party',
],
$period,
[
@@ -267,7 +268,7 @@ class AccompanyingPeriodContextTest extends KernelTestCase
'person2' => false,
'person2Label' => 'person2',
'thirdParty' => false,
'thirdPartyLabel' => '3party'
'thirdPartyLabel' => '3party',
],
$period,
[

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();
}

View File

@@ -24,6 +24,7 @@ use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
/**
* @internal
*
* @coversNothing
*/
final class PersonContextWithThirdPartyTest extends KernelTestCase

View File

@@ -24,6 +24,7 @@ use Symfony\Component\Security\Core\Security;
/**
* @internal
*
* @coversNothing
*/
class AccompanyingPeriodCalendarGenericDocProviderTest extends KernelTestCase
@@ -102,33 +103,33 @@ class AccompanyingPeriodCalendarGenericDocProviderTest extends KernelTestCase
{
$this->setUp();
if (null === $person = $this->entityManager->createQuery("SELECT p FROM " . Person::class . " p WHERE SIZE(p.accompanyingPeriodParticipations) > 0")
if (null === $person = $this->entityManager->createQuery('SELECT p FROM '.Person::class.' p WHERE SIZE(p.accompanyingPeriodParticipations) > 0')
->setMaxResults(1)->getSingleResult()) {
throw new \RuntimeException("There is no person");
throw new \RuntimeException('There is no person');
}
yield [$person, null, null, null];
yield [$person, new \DateTimeImmutable("1 year ago"), null, null];
yield [$person, new \DateTimeImmutable("1 year ago"), new \DateTimeImmutable("6 month ago"), null];
yield [$person, new \DateTimeImmutable("1 year ago"), new \DateTimeImmutable("6 month ago"), "text"];
yield [$person, null, null, "text"];
yield [$person, null, new \DateTimeImmutable("6 month ago"), null];
yield [$person, new \DateTimeImmutable('1 year ago'), null, null];
yield [$person, new \DateTimeImmutable('1 year ago'), new \DateTimeImmutable('6 month ago'), null];
yield [$person, new \DateTimeImmutable('1 year ago'), new \DateTimeImmutable('6 month ago'), 'text'];
yield [$person, null, null, 'text'];
yield [$person, null, new \DateTimeImmutable('6 month ago'), null];
}
public function provideDataForAccompanyingPeriod(): iterable
{
$this->setUp();
if (null === $period = $this->entityManager->createQuery("SELECT p FROM " . AccompanyingPeriod::class . " p ")
if (null === $period = $this->entityManager->createQuery('SELECT p FROM '.AccompanyingPeriod::class.' p ')
->setMaxResults(1)->getSingleResult()) {
throw new \RuntimeException("There is no accompanying period");
throw new \RuntimeException('There is no accompanying period');
}
yield [$period, null, null, null];
yield [$period, new \DateTimeImmutable("1 year ago"), null, null];
yield [$period, new \DateTimeImmutable("1 year ago"), new \DateTimeImmutable("6 month ago"), null];
yield [$period, new \DateTimeImmutable("1 year ago"), new \DateTimeImmutable("6 month ago"), "text"];
yield [$period, null, null, "text"];
yield [$period, null, new \DateTimeImmutable("6 month ago"), null];
yield [$period, new \DateTimeImmutable('1 year ago'), null, null];
yield [$period, new \DateTimeImmutable('1 year ago'), new \DateTimeImmutable('6 month ago'), null];
yield [$period, new \DateTimeImmutable('1 year ago'), new \DateTimeImmutable('6 month ago'), 'text'];
yield [$period, null, null, 'text'];
yield [$period, null, new \DateTimeImmutable('6 month ago'), null];
}
}

View File

@@ -21,6 +21,7 @@ use Symfony\Component\Security\Core\Security;
/**
* @internal
*
* @coversNothing
*/
class AccompanyingPeriodWorkEvaluationGenericDocProviderTest extends KernelTestCase
@@ -38,11 +39,11 @@ 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')
$period = $this->entityManager->createQuery('SELECT a FROM '.AccompanyingPeriod::class.' a')
->setMaxResults(1)
->getSingleResult();
@@ -66,7 +67,7 @@ class AccompanyingPeriodWorkEvaluationGenericDocProviderTest extends KernelTestC
$types
)->fetchOne();
self::assertIsInt($nb, "Test that there are no errors");
self::assertIsInt($nb, 'Test that there are no errors');
}
public function provideSearchArguments(): iterable

View File

@@ -20,6 +20,7 @@ use Symfony\Component\Security\Core\Security;
/**
* @internal
*
* @coversNothing
*/
class PersonCalendarGenericDocProviderTest extends KernelTestCase
@@ -55,16 +56,16 @@ class PersonCalendarGenericDocProviderTest extends KernelTestCase
{
$this->setUp();
if (null === $person = $this->entityManager->createQuery("SELECT p FROM " . Person::class . " p ")
if (null === $person = $this->entityManager->createQuery('SELECT p FROM '.Person::class.' p ')
->setMaxResults(1)->getSingleResult()) {
throw new \RuntimeException("There is no person");
throw new \RuntimeException('There is no person');
}
yield [$person, null, null, null];
yield [$person, new \DateTimeImmutable("1 year ago"), null, null];
yield [$person, new \DateTimeImmutable("1 year ago"), new \DateTimeImmutable("6 month ago"), null];
yield [$person, new \DateTimeImmutable("1 year ago"), new \DateTimeImmutable("6 month ago"), "text"];
yield [$person, null, null, "text"];
yield [$person, null, new \DateTimeImmutable("6 month ago"), null];
yield [$person, new \DateTimeImmutable('1 year ago'), null, null];
yield [$person, new \DateTimeImmutable('1 year ago'), new \DateTimeImmutable('6 month ago'), null];
yield [$person, new \DateTimeImmutable('1 year ago'), new \DateTimeImmutable('6 month ago'), 'text'];
yield [$person, null, null, 'text'];
yield [$person, null, new \DateTimeImmutable('6 month ago'), null];
}
}