mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
fix cs
This commit is contained in:
parent
3a904e8ea1
commit
a2713041da
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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<string>
|
||||
*/
|
||||
public function getQueryKeys(array $data): array;
|
||||
|
@ -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<mixed> $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;
|
||||
|
@ -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;
|
||||
|
@ -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';
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ use Doctrine\ORM\QueryBuilder;
|
||||
*
|
||||
* @template Q of QueryBuilder|NativeQuery
|
||||
* @template D of array
|
||||
*
|
||||
* @template-extends ExportInterface<Q, D>
|
||||
*/
|
||||
interface ListInterface extends ExportInterface {}
|
||||
|
@ -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'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user