From 28599adf4824aa9c76f319c56257f14f6b9c5c20 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Mon, 1 Aug 2022 11:37:41 +0200 Subject: [PATCH] tests on new ActiveOnDate and ActiveOneDayBetweenDates filters --- .../Export/Filter/ActiveOnDateFilterTest.php | 65 ++++++++++++++++++ .../ActiveOneDayBetweenDatesFilterTest.php | 66 +++++++++++++++++++ 2 files changed, 131 insertions(+) create mode 100644 src/Bundle/ChillPersonBundle/Tests/Export/Filter/ActiveOnDateFilterTest.php create mode 100644 src/Bundle/ChillPersonBundle/Tests/Export/Filter/ActiveOneDayBetweenDatesFilterTest.php diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/ActiveOnDateFilterTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/ActiveOnDateFilterTest.php new file mode 100644 index 000000000..b66de0f28 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/ActiveOnDateFilterTest.php @@ -0,0 +1,65 @@ +prophesize(); + + $request->willExtend(Request::class); + $request->getLocale()->willReturn('fr'); + + $this->filter = self::$container->get('chill.person.export.filter_activeondate'); + } + + /** + * @inheritDoc + */ + public function getFilter() + { + return $this->filter; + } + + /** + * @inheritDoc + */ + public function getFormData(): array + { + return [ + [ + 'on_date' => \DateTime::createFromFormat('Y-m-d', '2022-05-01'), + ], + ]; + } + + /** + * @inheritDoc + */ + public function getQueryBuilders(): array + { + if (null === self::$kernel) { + self::bootKernel(); + } + + $em = self::$container->get(EntityManagerInterface::class); + + return [ + $em->createQueryBuilder() + ->from('ChillPersonBundle:AccompanyingPeriod', 'acp') + ->select('acp.id'), + ]; + } +} \ No newline at end of file diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/ActiveOneDayBetweenDatesFilterTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/ActiveOneDayBetweenDatesFilterTest.php new file mode 100644 index 000000000..051db8635 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/ActiveOneDayBetweenDatesFilterTest.php @@ -0,0 +1,66 @@ +prophesize(); + + $request->willExtend(Request::class); + $request->getLocale()->willReturn('fr'); + + $this->filter = self::$container->get('chill.person.export.filter_activeonedaybetweendates'); + } + + /** + * @inheritDoc + */ + public function getFilter() + { + return $this->filter; + } + + /** + * @inheritDoc + */ + public function getFormData(): array + { + return [ + [ + 'date_from' => \DateTime::createFromFormat('Y-m-d', '2022-05-01'), + 'date_to' => \DateTime::createFromFormat('Y-m-d', '2022-06-01'), + ], + ]; + } + + /** + * @inheritDoc + */ + public function getQueryBuilders(): array + { + if (null === self::$kernel) { + self::bootKernel(); + } + + $em = self::$container->get(EntityManagerInterface::class); + + return [ + $em->createQueryBuilder() + ->from('ChillPersonBundle:AccompanyingPeriod', 'acp') + ->select('acp.id'), + ]; + } +} \ No newline at end of file