From f5fb721ddd78017d2a168511e07b968343323589 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Thu, 29 Sep 2022 20:00:45 +0200 Subject: [PATCH] activity export export tests --- .../Export/LinkedToACP/CountActivityTest.php | 51 +++++++++++++++++++ .../CountActivityTest.php | 17 +++---- .../{ => LinkedToPerson}/ListActivityTest.php | 23 ++++----- .../StatActivityDurationTest.php} | 19 +++---- 4 files changed, 74 insertions(+), 36 deletions(-) create mode 100644 src/Bundle/ChillActivityBundle/Tests/Export/Export/LinkedToACP/CountActivityTest.php rename src/Bundle/ChillActivityBundle/Tests/Export/Export/{ => LinkedToPerson}/CountActivityTest.php (62%) rename src/Bundle/ChillActivityBundle/Tests/Export/Export/{ => LinkedToPerson}/ListActivityTest.php (65%) rename src/Bundle/ChillActivityBundle/Tests/Export/Export/{StatActivityDurationSumTest.php => LinkedToPerson/StatActivityDurationTest.php} (55%) diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Export/LinkedToACP/CountActivityTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Export/LinkedToACP/CountActivityTest.php new file mode 100644 index 000000000..78f8556c1 --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Export/LinkedToACP/CountActivityTest.php @@ -0,0 +1,51 @@ +export = self::$container->get('chill.activity.export.count_activity_linked_to_acp'); + } + + public function getExport() + { + return $this->export; + } + + public function getFormData(): array + { + return [ + [], + ]; + } + + public function getModifiersCombination(): array + { + return [ + ['activity'], + ['activity', 'accompanying_period'], + ]; + } +} diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Export/CountActivityTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Export/LinkedToPerson/CountActivityTest.php similarity index 62% rename from src/Bundle/ChillActivityBundle/Tests/Export/Export/CountActivityTest.php rename to src/Bundle/ChillActivityBundle/Tests/Export/Export/LinkedToPerson/CountActivityTest.php index cbf562dfa..f94ef3414 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Export/CountActivityTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Export/LinkedToPerson/CountActivityTest.php @@ -9,8 +9,9 @@ declare(strict_types=1); -namespace Chill\ActivityBundle\Tests\Export\Export; +namespace Chill\ActivityBundle\Tests\Export\Export\LinkedToPerson; +use Chill\ActivityBundle\Export\Export\LinkedToPerson\CountActivity; use Chill\MainBundle\Test\Export\AbstractExportTest; /** @@ -19,19 +20,13 @@ use Chill\MainBundle\Test\Export\AbstractExportTest; */ final class CountActivityTest extends AbstractExportTest { - /** - * @var - */ - private $export; + private CountActivity $export; protected function setUp(): void { self::bootKernel(); - /** @var \Symfony\Component\DependencyInjection\ContainerInterface $container */ - $container = self::$kernel->getContainer(); - - $this->export = $container->get('chill.activity.export.count_activity'); + $this->export = self::$container->get('chill.activity.export.count_activity_linked_to_person'); } public function getExport() @@ -39,14 +34,14 @@ final class CountActivityTest extends AbstractExportTest return $this->export; } - public function getFormData() + public function getFormData(): array { return [ [], ]; } - public function getModifiersCombination() + public function getModifiersCombination(): array { return [ ['activity'], diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Export/ListActivityTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Export/LinkedToPerson/ListActivityTest.php similarity index 65% rename from src/Bundle/ChillActivityBundle/Tests/Export/Export/ListActivityTest.php rename to src/Bundle/ChillActivityBundle/Tests/Export/Export/LinkedToPerson/ListActivityTest.php index 46d23b023..a613bc083 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Export/ListActivityTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Export/LinkedToPerson/ListActivityTest.php @@ -9,9 +9,11 @@ declare(strict_types=1); -namespace Chill\ActivityBundle\Tests\Export\Export; +namespace Chill\ActivityBundle\Tests\Export\Export\LinkedToPerson; +use Chill\ActivityBundle\Export\Export\LinkedToPerson\ListActivity; use Chill\MainBundle\Test\Export\AbstractExportTest; +use Prophecy\PhpUnit\ProphecyTrait; /** * @internal @@ -19,27 +21,22 @@ use Chill\MainBundle\Test\Export\AbstractExportTest; */ final class ListActivityTest extends AbstractExportTest { - /** - * @var \Chill\ActivityBundle\Export\Export\ListActivity - */ - private $export; + use ProphecyTrait; + + private ListActivity $export; protected function setUp(): void { self::bootKernel(); - /** @var \Symfony\Component\DependencyInjection\ContainerInterface $container */ - $container = self::$kernel->getContainer(); + $this->export = self::$container->get('chill.activity.export.list_activity_linked_to_person'); - $this->export = $container->get('chill.activity.export.list_activity'); + $request = $this->prophesize() + ->willExtend(\Symfony\Component\HttpFoundation\Request::class); - // add a fake request with a default locale (used in translatable string) - $prophet = new \Prophecy\Prophet(); - $request = $prophet->prophesize(); - $request->willExtend(\Symfony\Component\HttpFoundation\Request::class); $request->getLocale()->willReturn('fr'); - $container->get('request_stack') + self::$container->get('request_stack') ->push($request->reveal()); } diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Export/StatActivityDurationSumTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Export/LinkedToPerson/StatActivityDurationTest.php similarity index 55% rename from src/Bundle/ChillActivityBundle/Tests/Export/Export/StatActivityDurationSumTest.php rename to src/Bundle/ChillActivityBundle/Tests/Export/Export/LinkedToPerson/StatActivityDurationTest.php index c69a31b5a..ae9e4f583 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Export/StatActivityDurationSumTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Export/LinkedToPerson/StatActivityDurationTest.php @@ -9,8 +9,9 @@ declare(strict_types=1); -namespace Chill\ActivityBundle\Tests\Export\Export; +namespace Chill\ActivityBundle\Tests\Export\Export\LinkedToPerson; +use Chill\ActivityBundle\Export\Export\LinkedToPerson\StatActivityDuration; use Chill\MainBundle\Test\Export\AbstractExportTest; /** @@ -19,21 +20,15 @@ use Chill\MainBundle\Test\Export\AbstractExportTest; * @internal * @coversNothing */ -final class StatActivityDurationSumTest extends AbstractExportTest +final class StatActivityDurationTest extends AbstractExportTest { - /** - * @var \Chill\ActivityBundle\Export\Export\StatActivityDuration - */ - private $export; + private StatActivityDuration $export; protected function setUp(): void { self::bootKernel(); - /** @var \Symfony\Component\DependencyInjection\ContainerInterface $container */ - $container = self::$kernel->getContainer(); - - $this->export = $container->get('chill.activity.export.sum_activity_duration'); + $this->export = self::$container->get('chill.activity.export.sum_activity_duration_linked_to_person'); } public function getExport() @@ -41,14 +36,14 @@ final class StatActivityDurationSumTest extends AbstractExportTest return $this->export; } - public function getFormData() + public function getFormData(): array { return [ [], ]; } - public function getModifiersCombination() + public function getModifiersCombination(): array { return [ ['activity'],