diff --git a/src/Bundle/ChillJobBundle/src/Export/ListCV.php b/src/Bundle/ChillJobBundle/src/Export/ListCV.php index 5a106065b..7fd23abf0 100644 --- a/src/Bundle/ChillJobBundle/src/Export/ListCV.php +++ b/src/Bundle/ChillJobBundle/src/Export/ListCV.php @@ -153,8 +153,6 @@ class ListCV implements ListInterface, ExportElementValidatedInterface * Most of the type, it will be a string which references an entity. * * Example of types : Chill\PersonBundle\Export\Declarations::PERSON_TYPE - * - * @return string */ public function getType(): string { @@ -216,8 +214,6 @@ class ListCV implements ListInterface, ExportElementValidatedInterface * this function will return `array('count_id')`. * * @param mixed[] $data the data from the export's form (added by self::buildForm) - * - * @return array */ public function getQueryKeys($data): array { diff --git a/src/Bundle/ChillJobBundle/src/Export/ListFrein.php b/src/Bundle/ChillJobBundle/src/Export/ListFrein.php index cf251d1b9..9517bbdfb 100644 --- a/src/Bundle/ChillJobBundle/src/Export/ListFrein.php +++ b/src/Bundle/ChillJobBundle/src/Export/ListFrein.php @@ -166,8 +166,6 @@ class ListFrein implements ListInterface, ExportElementValidatedInterface * Most of the type, it will be a string which references an entity. * * Example of types : Chill\PersonBundle\Export\Declarations::PERSON_TYPE - * - * @return string */ public function getType(): string { @@ -239,8 +237,6 @@ class ListFrein implements ListInterface, ExportElementValidatedInterface * this function will return `array('count_id')`. * * @param mixed[] $data the data from the export's form (added by self::buildForm) - * - * @return array */ public function getQueryKeys($data): array { diff --git a/src/Bundle/ChillJobBundle/src/Export/ListProjetProfessionnel.php b/src/Bundle/ChillJobBundle/src/Export/ListProjetProfessionnel.php index 97f89ddeb..c4a525c7a 100644 --- a/src/Bundle/ChillJobBundle/src/Export/ListProjetProfessionnel.php +++ b/src/Bundle/ChillJobBundle/src/Export/ListProjetProfessionnel.php @@ -172,8 +172,6 @@ class ListProjetProfessionnel implements ListInterface, ExportElementValidatedIn * Most of the type, it will be a string which references an entity. * * Example of types : Chill\PersonBundle\Export\Declarations::PERSON_TYPE - * - * @return string */ public function getType(): string { @@ -245,8 +243,6 @@ class ListProjetProfessionnel implements ListInterface, ExportElementValidatedIn * this function will return `array('count_id')`. * * @param mixed[] $data the data from the export's form (added by self::buildForm) - * - * @return array */ public function getQueryKeys($data): array { diff --git a/src/Bundle/ChillMainBundle/Export/AggregatorInterface.php b/src/Bundle/ChillMainBundle/Export/AggregatorInterface.php index 882ebd245..27ce09746 100644 --- a/src/Bundle/ChillMainBundle/Export/AggregatorInterface.php +++ b/src/Bundle/ChillMainBundle/Export/AggregatorInterface.php @@ -38,13 +38,10 @@ interface AggregatorInterface extends ModifierInterface /** * @param D $formData - * @return array */ public function normalizeFormData(array $formData): array; /** - * @param array $formData - * @param int $fromVersion * @return D */ public function denormalizeFormData(array $formData, int $fromVersion): array; @@ -106,6 +103,7 @@ interface AggregatorInterface extends ModifierInterface * this function will return `array('count_id')`. * * @param D $data the data from the export's form (added by self::buildForm) + * * @return list */ public function getQueryKeys(array $data): array; diff --git a/src/Bundle/ChillMainBundle/Export/ExportInterface.php b/src/Bundle/ChillMainBundle/Export/ExportInterface.php index c0fe0b3fa..edb5a53d1 100644 --- a/src/Bundle/ChillMainBundle/Export/ExportInterface.php +++ b/src/Bundle/ChillMainBundle/Export/ExportInterface.php @@ -96,7 +96,7 @@ interface ExportInterface extends ExportElementInterface * which do not need to be translated, or value already translated in * database. But the header must be, in every case, translated. * - * @param string $key The column key, as added in the query + * @param string $key The column key, as added in the query * @param list $values The values from the result. if there are duplicates, those might be given twice. Example: array('FR', 'BE', 'CZ', 'FR', 'BE', 'FR') * * @return (callable(string|int|float|'_header'|null $value): string|int|\DateTimeInterface|TranslatableInterface) where the first argument is the value, and the function should return the label to show in the formatted file. Example : `function($countryCode) use ($countries) { return $countries[$countryCode]->getName(); }` @@ -117,7 +117,7 @@ interface ExportInterface extends ExportElementInterface /** * Return the results of the query builder. * - * @param Q $query + * @param Q $query * @param D $data the data from the export's fomr (added by self::buildForm) * * @return mixed[] an array of results @@ -151,13 +151,12 @@ interface ExportInterface extends ExportElementInterface /** * @param D $formData - * @return array */ public function normalizeFormData(array $formData): array; /** * @param array $formData the normalized data - * @param int $fromVersion + * * @return D */ public function denormalizeFormData(array $formData, int $fromVersion): array; diff --git a/src/Bundle/ChillMainBundle/Export/FilterInterface.php b/src/Bundle/ChillMainBundle/Export/FilterInterface.php index 94f025dcd..438597ce1 100644 --- a/src/Bundle/ChillMainBundle/Export/FilterInterface.php +++ b/src/Bundle/ChillMainBundle/Export/FilterInterface.php @@ -45,13 +45,10 @@ interface FilterInterface extends ModifierInterface /** * @param D $formData - * @return array */ public function normalizeFormData(array $formData): array; /** - * @param array $formData - * @param int $fromVersion * @return D */ public function denormalizeFormData(array $formData, int $fromVersion): array; diff --git a/src/Bundle/ChillMainBundle/Export/Formatter/CSVListFormatter.php b/src/Bundle/ChillMainBundle/Export/Formatter/CSVListFormatter.php index 4d07abafb..40348c6a2 100644 --- a/src/Bundle/ChillMainBundle/Export/Formatter/CSVListFormatter.php +++ b/src/Bundle/ChillMainBundle/Export/Formatter/CSVListFormatter.php @@ -100,7 +100,7 @@ class CSVListFormatter implements FormatterInterface, ExportManagerAwareInterfac return ['numerotation' => true]; } - public function getName(): string|\Symfony\Contracts\Translation\TranslatableInterface + public function getName(): string|TranslatableInterface { return 'CSV vertical list'; } diff --git a/src/Bundle/ChillMainBundle/Export/ListInterface.php b/src/Bundle/ChillMainBundle/Export/ListInterface.php index 863a57c8d..3fe9315ae 100644 --- a/src/Bundle/ChillMainBundle/Export/ListInterface.php +++ b/src/Bundle/ChillMainBundle/Export/ListInterface.php @@ -25,6 +25,7 @@ use Doctrine\ORM\QueryBuilder; * * @template Q of QueryBuilder|NativeQuery * @template D of array + * * @template-extends ExportInterface */ interface ListInterface extends ExportInterface {} diff --git a/src/Bundle/ChillMainBundle/Test/Export/AbstractFilterTest.php b/src/Bundle/ChillMainBundle/Test/Export/AbstractFilterTest.php index 5c38515fc..f064bae59 100644 --- a/src/Bundle/ChillMainBundle/Test/Export/AbstractFilterTest.php +++ b/src/Bundle/ChillMainBundle/Test/Export/AbstractFilterTest.php @@ -11,6 +11,8 @@ declare(strict_types=1); namespace Chill\MainBundle\Test\Export; +use Chill\MainBundle\Entity\User; +use Chill\MainBundle\Export\ExportGenerationContext; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\QueryBuilder; use Prophecy\PhpUnit\ProphecyTrait; @@ -23,16 +25,6 @@ abstract class AbstractFilterTest extends KernelTestCase { use ProphecyTrait; - /** - * @var \Prophecy\Prophet - */ - private $prophet; - - protected function setUp(): void - { - $this->prophet = $this->getProphet(); - } - public static function tearDownAfterClass(): void { if (null !== self::getContainer()) { @@ -98,6 +90,19 @@ abstract class AbstractFilterTest extends KernelTestCase } } + private function getUser(): User + { + $em = static::getContainer()->get(EntityManagerInterface::class); + if (null === $user = $em->createQueryBuilder()->select('u') + ->from(User::class, 'u') + ->setMaxResults(1) + ->getQuery()->getOneOrNullResult()) { + throw new \RuntimeException('User not found'); + } + + return $user; + } + /** * Create a filter which will be used in tests. * @@ -138,7 +143,7 @@ abstract class AbstractFilterTest extends KernelTestCase { $aliases = $qb->getAllAliases(); - $this->getFilter()->alterQuery($qb, $data); + $this->getFilter()->alterQuery($qb, $data, new ExportGenerationContext($this->getUser())); $alteredQuery = $qb->getAllAliases(); @@ -166,7 +171,9 @@ abstract class AbstractFilterTest extends KernelTestCase $nbOfSelect = null !== $query->getDQLPart('select') ? \count($query->getDQLPart('select')) : 0; - $this->getFilter()->alterQuery($query, $data); + $context = new ExportGenerationContext($this->getUser()); + + $this->getFilter()->alterQuery($query, $data, $context); $this->assertGreaterThanOrEqual( $nbOfFrom, @@ -192,7 +199,7 @@ abstract class AbstractFilterTest extends KernelTestCase */ public function testQueryExecution(QueryBuilder $qb, mixed $data): void { - $this->getFilter()->alterQuery($qb, $data); + $this->getFilter()->alterQuery($qb, $data, new ExportGenerationContext($this->getUser())); $actual = $qb->getQuery()->getResult(); @@ -262,15 +269,4 @@ abstract class AbstractFilterTest extends KernelTestCase ); } } - - public function testGetTitle() - { - $title = $this->getFilter()->getTitle(); - - $this->assertIsString($title); - $this->assertNotEmpty( - $title, - 'test that the title is not empty' - ); - } } diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Helper/FilterListAccompanyingPeriodHelperTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Helper/FilterListAccompanyingPeriodHelperTest.php index fc58344a8..c5b1deb1f 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Helper/FilterListAccompanyingPeriodHelperTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Helper/FilterListAccompanyingPeriodHelperTest.php @@ -63,8 +63,6 @@ final class FilterListAccompanyingPeriodHelperTest extends KernelTestCase if (null === $user) { throw new \RuntimeException('no user found'); } - $security = $this->prophesize(Security::class); - $security->getUser()->willReturn($user); // mock authorization helper $scopes = $this->scopeRepository->findAll(); @@ -76,7 +74,6 @@ final class FilterListAccompanyingPeriodHelperTest extends KernelTestCase ->willReturn($scopesConfidentials); $filter = new FilterListAccompanyingPeriodHelper( - $security->reveal(), $this->centerRepository, $authorizationHelper->reveal(), $parameterBag diff --git a/src/Bundle/ChillReportBundle/Export/Export/ReportList.php b/src/Bundle/ChillReportBundle/Export/Export/ReportList.php index 974a20cc5..da91602de 100644 --- a/src/Bundle/ChillReportBundle/Export/Export/ReportList.php +++ b/src/Bundle/ChillReportBundle/Export/Export/ReportList.php @@ -308,7 +308,7 @@ class ReportList implements ExportElementValidatedInterface, ListInterface return 'report'; } - public function initiateQuery(array $requiredModifiers, array $acl, array $data, \Chill\MainBundle\Export\ExportGenerationContext $context): \Doctrine\ORM\QueryBuilder + public function initiateQuery(array $requiredModifiers, array $acl, array $data, \Chill\MainBundle\Export\ExportGenerationContext $context): QueryBuilder { $centers = array_map(static fn ($el) => $el['center'], $acl);