From b9186ed6e01cf8af6a29e8a49ad553c769f35f8c Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Wed, 27 Jul 2022 18:39:58 +0200 Subject: [PATCH] tests: write a simple Export test for new indicators + fix depreciation with BrowserKit client cfr: https://symfony.com/doc/4.4/components/browser_kit.html#creating-a-client --- .../Test/Export/AbstractExportTest.php | 6 ++- .../Export/CountAccompanyingCourseTest.php | 43 +++++++++++++++++++ .../StatAccompanyingCourseDurationTest.php | 36 ++++++++++++++++ 3 files changed, 83 insertions(+), 2 deletions(-) create mode 100644 src/Bundle/ChillPersonBundle/Tests/Export/Export/CountAccompanyingCourseTest.php create mode 100644 src/Bundle/ChillPersonBundle/Tests/Export/Export/StatAccompanyingCourseDurationTest.php diff --git a/src/Bundle/ChillMainBundle/Test/Export/AbstractExportTest.php b/src/Bundle/ChillMainBundle/Test/Export/AbstractExportTest.php index a80753a46..60d539573 100644 --- a/src/Bundle/ChillMainBundle/Test/Export/AbstractExportTest.php +++ b/src/Bundle/ChillMainBundle/Test/Export/AbstractExportTest.php @@ -16,6 +16,7 @@ use Doctrine\ORM\NativeQuery; use Doctrine\ORM\QueryBuilder; use RuntimeException; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; +use Symfony\Component\BrowserKit\HttpBrowser; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Security\Core\Role\Role; use Traversable; @@ -332,8 +333,9 @@ abstract class AbstractExportTest extends WebTestCase */ public function testListExportPage() { - /** @var \Symfony\Component\BrowserKit\Client $client */ - $client = $this->getClient(); + /** @var HttpBrowser $client */ + $client = new HttpBrowser(); + $export = $this->getExport(); $prophet = new \Prophecy\Prophet(); $container = static::$kernel->getContainer(); diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Export/CountAccompanyingCourseTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Export/CountAccompanyingCourseTest.php new file mode 100644 index 000000000..d6fa9a843 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Export/CountAccompanyingCourseTest.php @@ -0,0 +1,43 @@ +export = self::$container->get('chill.person.export.count_accompanyingcourse'); + } + + /** + * @inheritDoc + */ + public function getExport() + { + return $this->export; + } + + /** + * @inheritDoc + */ + public function getFormData(): array + { + return [[]]; + } + + /** + * @inheritDoc + */ + public function getModifiersCombination() + { + return [[Declarations::ACP_TYPE]]; + } +} \ No newline at end of file diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Export/StatAccompanyingCourseDurationTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Export/StatAccompanyingCourseDurationTest.php new file mode 100644 index 000000000..7c1420c86 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Export/StatAccompanyingCourseDurationTest.php @@ -0,0 +1,36 @@ +export = self::$container->get('chill.person.export.avg_accompanyingcourse_duration'); + } + + public function getExport() + { + return $this->export; + } + + public function getFormData(): array + { + return [ + ['closingdate' => \DateTime::createFromFormat('Y-m-d', '2022-06-30')], + ]; + } + + public function getModifiersCombination() + { + return [[Declarations::ACP_TYPE]]; + } +} \ No newline at end of file