diff --git a/src/Bundle/ChillMainBundle/Entity/SavedExport.php b/src/Bundle/ChillMainBundle/Entity/SavedExport.php index 56143efdd..7e0306a7e 100644 --- a/src/Bundle/ChillMainBundle/Entity/SavedExport.php +++ b/src/Bundle/ChillMainBundle/Entity/SavedExport.php @@ -177,7 +177,7 @@ class SavedExport implements TrackCreationInterface, TrackUpdateInterface } /** - * Return true if shared with at least one user or one group + * Return true if shared with at least one user or one group. */ public function isShared(): bool { diff --git a/src/Bundle/ChillMainBundle/Export/ExportManager.php b/src/Bundle/ChillMainBundle/Export/ExportManager.php index 9a26f70ad..f5e9bfc4d 100644 --- a/src/Bundle/ChillMainBundle/Export/ExportManager.php +++ b/src/Bundle/ChillMainBundle/Export/ExportManager.php @@ -144,8 +144,6 @@ class ExportManager /** * @param string $alias * - * @return AggregatorInterface - * * @throws \RuntimeException if the aggregator is not known */ public function getAggregator($alias): AggregatorInterface diff --git a/src/Bundle/ChillMainBundle/Export/Formatter/SpreadsheetListFormatter.php b/src/Bundle/ChillMainBundle/Export/Formatter/SpreadsheetListFormatter.php index 7b89dd0a6..27ee7f44c 100644 --- a/src/Bundle/ChillMainBundle/Export/Formatter/SpreadsheetListFormatter.php +++ b/src/Bundle/ChillMainBundle/Export/Formatter/SpreadsheetListFormatter.php @@ -41,8 +41,6 @@ class SpreadsheetListFormatter implements FormatterInterface, ExportManagerAware * of this formatter. * * @uses appendAggregatorForm - * - * @param string $exportAlias */ public function buildForm( FormBuilderInterface $builder, @@ -88,7 +86,7 @@ class SpreadsheetListFormatter implements FormatterInterface, ExportManagerAware return ['numerotation' => true, 'format' => 'xlsx']; } - public function getName(): string|\Symfony\Contracts\Translation\TranslatableInterface + public function getName(): string|TranslatableInterface { return 'Spreadsheet list formatter (.xlsx, .ods)'; } @@ -214,8 +212,7 @@ class SpreadsheetListFormatter implements FormatterInterface, ExportManagerAware /** * Give the label corresponding to the given key and value. * - * - * @return string|\DateTimeInterface|int|null|float|TranslatableInterface + * @return string|\DateTimeInterface|int|float|TranslatableInterface|null * * @throws \LogicException if the label is not found */ @@ -231,10 +228,6 @@ class SpreadsheetListFormatter implements FormatterInterface, ExportManagerAware /** * Prepare the label cache which will be used by getLabel. * - * @param array $result - * @param string $exportAlias - * @param array $exportData - * * @return array The labels cache */ private function prepareCacheLabels(array $result, string $exportAlias, array $exportData): array @@ -261,12 +254,6 @@ class SpreadsheetListFormatter implements FormatterInterface, ExportManagerAware /** * add the headers to the csv file. - * - * @param Worksheet $worksheet - * @param array $result - * @param array $formatterData - * @param string $exportAlias - * @param array $exportData */ protected function prepareHeaders(array $labelsCache, Worksheet $worksheet, array $result, array $formatterData, string $exportAlias, array $exportData) { diff --git a/src/Bundle/ChillMainBundle/Test/Export/AbstractAggregatorTest.php b/src/Bundle/ChillMainBundle/Test/Export/AbstractAggregatorTest.php index 91640f7c7..baf7620ce 100644 --- a/src/Bundle/ChillMainBundle/Test/Export/AbstractAggregatorTest.php +++ b/src/Bundle/ChillMainBundle/Test/Export/AbstractAggregatorTest.php @@ -34,119 +34,6 @@ abstract class AbstractAggregatorTest extends KernelTestCase self::ensureKernelShutdown(); } - /** - * provide data for `testAliasDidNotDisappears`. - */ - public static function dataProviderAliasDidNotDisappears() - { - $datas = static::getFormData(); - - if (!\is_array($datas)) { - $datas = iterator_to_array($datas); - } - - foreach (static::getQueryBuilders() as $qb) { - if ([] === $datas) { - yield [clone $qb, []]; - } else { - foreach (static::getFormData() as $data) { - yield [clone $qb, $data]; - } - } - } - } - - /** - * A list of data to normalize. - * - * @return iterable{array} - */ - public static function dataProviderFormDataToNormalize(): iterable - { - foreach (static::getFormData() as $data) { - yield [$data, 1, []]; - } - } - - /** - * provide data for `testAlterQuery`. - */ - public static function dataProviderAlterQuery() - { - $datas = static::getFormData(); - - if (!\is_array($datas)) { - $datas = iterator_to_array($datas); - } - - foreach (static::getQueryBuilders() as $qb) { - if ([] === $datas) { - yield [clone $qb, []]; - } else { - foreach (static::getFormData() as $data) { - yield [clone $qb, $data]; - } - } - } - } - - public static function dataProviderQueryExecution(): iterable - { - $datas = static::getFormData(); - - if (!\is_array($datas)) { - $datas = iterator_to_array($datas); - } - - foreach (static::getQueryBuilders() as $qb) { - if ([] === $datas) { - yield [clone $qb, []]; - } else { - foreach (static::getFormData() as $data) { - yield [clone $qb, $data]; - } - } - } - } - - /** - * prepare data for `testGetQueryKeys`. - */ - public static function dataProviderGetQueryKeys() - { - $datas = static::getFormData(); - - if (!\is_array($datas)) { - $datas = iterator_to_array($datas); - } - - foreach ($datas as $data) { - yield [$data]; - } - } - - /** - * prepare date for method `testGetResultsAndLabels`. - */ - public static function dataProviderGetResultsAndLabels() - { - $datas = static::getFormData(); - - if (!\is_array($datas)) { - $datas = iterator_to_array($datas); - } - - foreach (static::getQueryBuilders() as $qb) { - if ([] === $datas) { - yield [clone $qb, []]; - } else { - foreach ($datas as $data) { - yield [clone $qb, $data]; - } - } - } - } - /** * Create an aggregator instance which will be used in tests. * @@ -214,6 +101,28 @@ abstract class AbstractAggregatorTest extends KernelTestCase } } + /** + * provide data for `testAliasDidNotDisappears`. + */ + public static function dataProviderAliasDidNotDisappears() + { + $datas = static::getFormData(); + + if (!\is_array($datas)) { + $datas = iterator_to_array($datas); + } + + foreach (static::getQueryBuilders() as $qb) { + if ([] === $datas) { + yield [clone $qb, []]; + } else { + foreach (static::getFormData() as $data) { + yield [clone $qb, $data]; + } + } + } + } + /** * @dataProvider dataProviderQueryExecution * @@ -228,6 +137,25 @@ abstract class AbstractAggregatorTest extends KernelTestCase self::assertIsArray($actual); } + public static function dataProviderQueryExecution(): iterable + { + $datas = static::getFormData(); + + if (!\is_array($datas)) { + $datas = iterator_to_array($datas); + } + + foreach (static::getQueryBuilders() as $qb) { + if ([] === $datas) { + yield [clone $qb, []]; + } else { + foreach (static::getFormData() as $data) { + yield [clone $qb, $data]; + } + } + } + } + /** * test the alteration of query by the filter. * @@ -266,6 +194,28 @@ abstract class AbstractAggregatorTest extends KernelTestCase ); } + /** + * provide data for `testAlterQuery`. + */ + public static function dataProviderAlterQuery() + { + $datas = static::getFormData(); + + if (!\is_array($datas)) { + $datas = iterator_to_array($datas); + } + + foreach (static::getQueryBuilders() as $qb) { + if ([] === $datas) { + yield [clone $qb, []]; + } else { + foreach (static::getFormData() as $data) { + yield [clone $qb, $data]; + } + } + } + } + /** * Test the `applyOn` method. */ @@ -309,6 +259,18 @@ abstract class AbstractAggregatorTest extends KernelTestCase } } + /** + * A list of data to normalize. + * + * @return iterable{array} + */ + public static function dataProviderFormDataToNormalize(): iterable + { + foreach (static::getFormData() as $data) { + yield [$data, 1, []]; + } + } + /** * Test that the query keys are strings. * @@ -335,6 +297,22 @@ abstract class AbstractAggregatorTest extends KernelTestCase ); } + /** + * prepare data for `testGetQueryKeys`. + */ + public static function dataProviderGetQueryKeys() + { + $datas = static::getFormData(); + + if (!\is_array($datas)) { + $datas = iterator_to_array($datas); + } + + foreach ($datas as $data) { + yield [$data]; + } + } + /** * Test that. * @@ -399,6 +377,28 @@ abstract class AbstractAggregatorTest extends KernelTestCase } } + /** + * prepare date for method `testGetResultsAndLabels`. + */ + public static function dataProviderGetResultsAndLabels() + { + $datas = static::getFormData(); + + if (!\is_array($datas)) { + $datas = iterator_to_array($datas); + } + + foreach (static::getQueryBuilders() as $qb) { + if ([] === $datas) { + yield [clone $qb, []]; + } else { + foreach ($datas as $data) { + yield [clone $qb, $data]; + } + } + } + } + /** * test the `getTitle` method. */ diff --git a/src/Bundle/ChillMainBundle/Test/Export/AbstractExportTest.php b/src/Bundle/ChillMainBundle/Test/Export/AbstractExportTest.php index 223976056..7e0ecf166 100644 --- a/src/Bundle/ChillMainBundle/Test/Export/AbstractExportTest.php +++ b/src/Bundle/ChillMainBundle/Test/Export/AbstractExportTest.php @@ -33,39 +33,6 @@ abstract class AbstractExportTest extends WebTestCase { use PrepareClientTrait; - /** - * A list of data to normalize. - * - * @return iterable{array} - */ - public static function dataProviderFormDataToNormalize(): iterable - { - foreach (static::getFormData() as $data) { - yield [$data, 1, []]; - } - } - - public static function dataProviderGetQueryKeys() - { - foreach (static::getFormData() as $data) { - yield [$data]; - } - } - - /** - * create data for `ìnitiateQuery` method. - */ - public static function dataProviderInitiateQuery() - { - $acl = static::getAcl(); - - foreach (static::getModifiersCombination() as $modifiers) { - foreach (static::getFormData() as $data) { - yield [$modifiers, $acl, $data]; - } - } - } - /** * Return an array usable as ACL. * @@ -182,6 +149,18 @@ abstract class AbstractExportTest extends WebTestCase } } + /** + * A list of data to normalize. + * + * @return iterable{array} + */ + public static function dataProviderFormDataToNormalize(): iterable + { + foreach (static::getFormData() as $data) { + yield [$data, 1, []]; + } + } + private function testOneDataNormalization(ExportInterface|DirectExportInterface $export, array $data, int $version, array $customAssert): void { $normalized = $export->normalizeFormData($data); @@ -262,6 +241,13 @@ abstract class AbstractExportTest extends WebTestCase } } + public static function dataProviderGetQueryKeys() + { + foreach (static::getFormData() as $data) { + yield [$data]; + } + } + /** * Test that. * @@ -446,4 +432,18 @@ abstract class AbstractExportTest extends WebTestCase } } } + + /** + * create data for `ìnitiateQuery` method. + */ + public static function dataProviderInitiateQuery() + { + $acl = static::getAcl(); + + foreach (static::getModifiersCombination() as $modifiers) { + foreach (static::getFormData() as $data) { + yield [$modifiers, $acl, $data]; + } + } + } } diff --git a/src/Bundle/ChillMainBundle/Test/Export/AbstractFilterTest.php b/src/Bundle/ChillMainBundle/Test/Export/AbstractFilterTest.php index 378f8c4d9..e76d7d504 100644 --- a/src/Bundle/ChillMainBundle/Test/Export/AbstractFilterTest.php +++ b/src/Bundle/ChillMainBundle/Test/Export/AbstractFilterTest.php @@ -35,61 +35,6 @@ abstract class AbstractFilterTest extends KernelTestCase self::ensureKernelShutdown(); } - /** - * provide data for `testAliasDidNotDisappears`. - */ - public static function dataProviderAliasDidNotDisappears() - { - $datas = static::getFormData(); - - foreach (static::getQueryBuilders() as $qb) { - if ([] === $datas) { - yield [clone $qb, []]; - } else { - foreach ($datas as $data) { - yield [clone $qb, $data]; - } - } - } - } - - public static function dataProviderAlterQuery() - { - $datas = static::getFormData(); - - foreach (static::getQueryBuilders() as $qb) { - if ([] === $datas) { - yield [clone $qb, []]; - } else { - foreach ($datas as $data) { - yield [clone $qb, $data]; - } - } - } - } - - public static function dataProvideQueryExecution(): iterable - { - $datas = static::getFormData(); - - foreach (static::getQueryBuilders() as $qb) { - if ([] === $datas) { - yield [clone $qb, []]; - } else { - foreach ($datas as $data) { - yield [clone $qb, $data]; - } - } - } - } - - public static function dataProviderDescriptionAction() - { - foreach (static::getFormData() as $data) { - yield [$data]; - } - } - protected function getUser(): User { $em = static::getContainer()->get(EntityManagerInterface::class); @@ -134,18 +79,6 @@ abstract class AbstractFilterTest extends KernelTestCase */ abstract public static function getQueryBuilders(); - /** - * A list of data to normalize. - * - * @return iterable{array} - */ - public static function dataProviderFormDataToNormalize(): iterable - { - foreach (static::getFormData() as $data) { - yield [$data, 1, []]; - } - } - /** * @dataProvider dataProviderFormDataToNormalize */ @@ -172,6 +105,18 @@ abstract class AbstractFilterTest extends KernelTestCase } } + /** + * A list of data to normalize. + * + * @return iterable{array} + */ + public static function dataProviderFormDataToNormalize(): iterable + { + foreach (static::getFormData() as $data) { + yield [$data, 1, []]; + } + } + /** * Compare aliases array before and after that filter alter query. * @@ -192,6 +137,24 @@ abstract class AbstractFilterTest extends KernelTestCase } } + /** + * provide data for `testAliasDidNotDisappears`. + */ + public static function dataProviderAliasDidNotDisappears() + { + $datas = static::getFormData(); + + foreach (static::getQueryBuilders() as $qb) { + if ([] === $datas) { + yield [clone $qb, []]; + } else { + foreach ($datas as $data) { + yield [clone $qb, $data]; + } + } + } + } + /** * test the alteration of query by the filter. * @@ -232,6 +195,21 @@ abstract class AbstractFilterTest extends KernelTestCase ); } + public static function dataProviderAlterQuery() + { + $datas = static::getFormData(); + + foreach (static::getQueryBuilders() as $qb) { + if ([] === $datas) { + yield [clone $qb, []]; + } else { + foreach ($datas as $data) { + yield [clone $qb, $data]; + } + } + } + } + /** * @dataProvider dataProvideQueryExecution */ @@ -244,6 +222,21 @@ abstract class AbstractFilterTest extends KernelTestCase self::assertIsArray($actual); } + public static function dataProvideQueryExecution(): iterable + { + $datas = static::getFormData(); + + foreach (static::getQueryBuilders() as $qb) { + if ([] === $datas) { + yield [clone $qb, []]; + } else { + foreach ($datas as $data) { + yield [clone $qb, $data]; + } + } + } + } + public function testApplyOn() { $filter = $this->getFilter(); @@ -308,4 +301,11 @@ abstract class AbstractFilterTest extends KernelTestCase ); } } + + public static function dataProviderDescriptionAction() + { + foreach (static::getFormData() as $data) { + yield [$data]; + } + } } diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/ReferrerAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/ReferrerAggregatorTest.php index 96ba94f62..f8ba356d2 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/ReferrerAggregatorTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/ReferrerAggregatorTest.php @@ -61,18 +61,6 @@ final class ReferrerAggregatorTest extends AbstractAggregatorTest ]; } - /** - * A list of data to normalize. - * - * @return iterable{array} - */ - public static function dataProviderFormDataToNormalize(): iterable - { - foreach (self::getFormData() as $data) { - yield [$data, 1, []]; - } - } - /** * @dataProvider dataProviderFormDataToNormalize */ @@ -85,4 +73,16 @@ final class ReferrerAggregatorTest extends AbstractAggregatorTest self::assertIsArray($actual); } + + /** + * A list of data to normalize. + * + * @return iterable{array} + */ + public static function dataProviderFormDataToNormalize(): iterable + { + foreach (self::getFormData() as $data) { + yield [$data, 1, []]; + } + } } diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/GenderFilterTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/GenderFilterTest.php index 4038bd54b..baf46de26 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/GenderFilterTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/GenderFilterTest.php @@ -46,6 +46,20 @@ final class GenderFilterTest extends AbstractFilterTest ]; } + /** + * @dataProvider dataProviderFormDataToNormalize + */ + public function testDataNormalization(array $data, int $version, array $customAssert): void + { + $filter = $this->getFilter(); + + $normalized = $filter->normalizeFormData($data); + $actual = $filter->denormalizeFormData($normalized, $version); + + self::assertIsArray($actual); + self::assertArrayHasKey('accepted_genders_entity', $actual); + } + /** * A list of data to normalize. * @@ -65,20 +79,6 @@ final class GenderFilterTest extends AbstractFilterTest ]; } - /** - * @dataProvider dataProviderFormDataToNormalize - */ - public function testDataNormalization(array $data, int $version, array $customAssert): void - { - $filter = $this->getFilter(); - - $normalized = $filter->normalizeFormData($data); - $actual = $filter->denormalizeFormData($normalized, $version); - - self::assertIsArray($actual); - self::assertArrayHasKey('accepted_genders_entity', $actual); - } - public static function getQueryBuilders(): iterable { self::bootKernel();