Loading tests/FilterByDateTest.php +53 −0 Original line number Diff line number Diff line Loading @@ -6,6 +6,7 @@ namespace IQDEV\Tests\Packages\DoctrineHttpFilter; use DateInterval; use DateTimeImmutable; use IQDEV\Packages\DoctrineHttpFilter\Exception\FilterParameterValueIsNullException; use IQDEV\Packages\DoctrineHttpFilter\Filter\Date; use IQDEV\Packages\DoctrineHttpFilter\HttpFilter; use IQDEV\Tests\Packages\DoctrineHttpFilter\Entity\Post; Loading Loading @@ -131,4 +132,56 @@ class FilterByDateTest extends TestCase $this->assertEmpty($result); } public function testFilterDateWithoutParameterValue(): void { /** @var PostRepository $postRepository */ $postRepository = $this->em->getRepository(Post::class); $this->expectException(FilterParameterValueIsNullException::class); $postRepository->createQueryByFilter([ 'createdAt' => Date::class, ], new Request([ HttpFilter::REQUEST_FILTER_KEY => [], ])) ->getQuery() ->getResult(); } public function testFilterDateWithNotDateParameterValue(): void { /** @var PostRepository $postRepository */ $postRepository = $this->em->getRepository(Post::class); $result = $postRepository->createQueryByFilter([ 'createdAt' => Date::class, ], new Request([ HttpFilter::REQUEST_FILTER_KEY => [ 'createdAt' => 'not date', ], ])) ->getQuery() ->getResult(); $this->assertEmpty($result); } public function testFilterDateWithDifferentKey(): void { /** @var PostRepository $postRepository */ $postRepository = $this->em->getRepository(Post::class); $this->expectException(FilterParameterValueIsNullException::class); $postRepository->createQueryByFilter([ 'createdAt' => Date::class, ], new Request([ HttpFilter::REQUEST_FILTER_KEY => [ 'notCreatedAt' => 'Not createdAt value' ], ])) ->getQuery() ->getResult(); } } tests/FilterByWhereTest.php +18 −0 Original line number Diff line number Diff line Loading @@ -127,4 +127,22 @@ class FilterByWhereTest extends TestCase ->getQuery() ->getResult(); } public function testFilterWhereWithDifferentKey(): void { /** @var PostRepository $postRepository */ $postRepository = $this->em->getRepository(Post::class); $this->expectException(FilterParameterValueIsNullException::class); $postRepository->createQueryByFilter([ 'title' => Where::class, ], new Request([ HttpFilter::REQUEST_FILTER_KEY => [ 'notTitle' => 'Not title value' ], ])) ->getQuery() ->getResult(); } } Loading
tests/FilterByDateTest.php +53 −0 Original line number Diff line number Diff line Loading @@ -6,6 +6,7 @@ namespace IQDEV\Tests\Packages\DoctrineHttpFilter; use DateInterval; use DateTimeImmutable; use IQDEV\Packages\DoctrineHttpFilter\Exception\FilterParameterValueIsNullException; use IQDEV\Packages\DoctrineHttpFilter\Filter\Date; use IQDEV\Packages\DoctrineHttpFilter\HttpFilter; use IQDEV\Tests\Packages\DoctrineHttpFilter\Entity\Post; Loading Loading @@ -131,4 +132,56 @@ class FilterByDateTest extends TestCase $this->assertEmpty($result); } public function testFilterDateWithoutParameterValue(): void { /** @var PostRepository $postRepository */ $postRepository = $this->em->getRepository(Post::class); $this->expectException(FilterParameterValueIsNullException::class); $postRepository->createQueryByFilter([ 'createdAt' => Date::class, ], new Request([ HttpFilter::REQUEST_FILTER_KEY => [], ])) ->getQuery() ->getResult(); } public function testFilterDateWithNotDateParameterValue(): void { /** @var PostRepository $postRepository */ $postRepository = $this->em->getRepository(Post::class); $result = $postRepository->createQueryByFilter([ 'createdAt' => Date::class, ], new Request([ HttpFilter::REQUEST_FILTER_KEY => [ 'createdAt' => 'not date', ], ])) ->getQuery() ->getResult(); $this->assertEmpty($result); } public function testFilterDateWithDifferentKey(): void { /** @var PostRepository $postRepository */ $postRepository = $this->em->getRepository(Post::class); $this->expectException(FilterParameterValueIsNullException::class); $postRepository->createQueryByFilter([ 'createdAt' => Date::class, ], new Request([ HttpFilter::REQUEST_FILTER_KEY => [ 'notCreatedAt' => 'Not createdAt value' ], ])) ->getQuery() ->getResult(); } }
tests/FilterByWhereTest.php +18 −0 Original line number Diff line number Diff line Loading @@ -127,4 +127,22 @@ class FilterByWhereTest extends TestCase ->getQuery() ->getResult(); } public function testFilterWhereWithDifferentKey(): void { /** @var PostRepository $postRepository */ $postRepository = $this->em->getRepository(Post::class); $this->expectException(FilterParameterValueIsNullException::class); $postRepository->createQueryByFilter([ 'title' => Where::class, ], new Request([ HttpFilter::REQUEST_FILTER_KEY => [ 'notTitle' => 'Not title value' ], ])) ->getQuery() ->getResult(); } }