From 0c68dac7b54ec8a5fcfe86921d6c685b4dac8ae3 Mon Sep 17 00:00:00 2001 From: "a.shamavov" Date: Tue, 4 Mar 2025 09:56:29 +0500 Subject: [PATCH] =?UTF-8?q?tests:=20=D0=94=D0=BE=D0=BF=D0=BE=D0=BB=D0=BD?= =?UTF-8?q?=D0=B8=D1=82=D0=B5=D0=BB=D1=8C=D0=BD=D1=8B=D0=B5=20=D1=82=D0=B5?= =?UTF-8?q?=D1=81=D1=82=D1=8B=20=D0=B4=D0=BB=D1=8F=20=D1=84=D0=B8=D0=BB?= =?UTF-8?q?=D1=8C=D1=82=D1=80=D0=B0=20In?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/FilterByInTest.php | 53 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/tests/FilterByInTest.php b/tests/FilterByInTest.php index b023649..bcf3d8a 100644 --- a/tests/FilterByInTest.php +++ b/tests/FilterByInTest.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace IQDEV\Tests\Packages\DoctrineHttpFilter; +use IQDEV\Packages\DoctrineHttpFilter\Exception\FilterParameterValueIsNullException; use IQDEV\Packages\DoctrineHttpFilter\Filter\In; use IQDEV\Packages\DoctrineHttpFilter\HttpFilter; use IQDEV\Tests\Packages\DoctrineHttpFilter\Entity\Post; @@ -126,4 +127,56 @@ class FilterByInTest extends TestCase $this->assertEmpty($result); } + + public function testFilterInWithoutParameterValue(): void + { + /** @var PostRepository $postRepository */ + $postRepository = $this->em->getRepository(Post::class); + + $this->expectException(FilterParameterValueIsNullException::class); + + $postRepository->createQueryByFilter([ + 'title' => In::class, + ], new Request([ + HttpFilter::REQUEST_FILTER_KEY => [], + ])) + ->getQuery() + ->getResult(); + } + + public function testFilterInWithNotArrayParameterValue(): void + { + /** @var PostRepository $postRepository */ + $postRepository = $this->em->getRepository(Post::class); + + $this->expectException(FilterParameterValueIsNullException::class); + + $postRepository->createQueryByFilter([ + 'title' => In::class, + ], new Request([ + HttpFilter::REQUEST_FILTER_KEY => [ + 'title' => 'not array', + ], + ])) + ->getQuery() + ->getResult(); + } + + public function testFilterInWithDifferentKey(): void + { + /** @var PostRepository $postRepository */ + $postRepository = $this->em->getRepository(Post::class); + + $this->expectException(FilterParameterValueIsNullException::class); + + $postRepository->createQueryByFilter([ + 'title' => In::class, + ], new Request([ + HttpFilter::REQUEST_FILTER_KEY => [ + 'notTitle' => 'Not title value' + ], + ])) + ->getQuery() + ->getResult(); + } } -- GitLab