From 41daf21e0f84ea59a2209308404921ca2b70fb56 Mon Sep 17 00:00:00 2001 From: "a.shamavov" Date: Tue, 4 Mar 2025 13:26:18 +0500 Subject: [PATCH] =?UTF-8?q?tests:=20=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=20=D1=82=D0=B5=D1=81=D1=82=D0=BE?= =?UTF-8?q?=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/FilterByDateTest.php | 40 ++++++++++++++++++++++++++++++++++++++ tests/FilterByInTest.php | 2 -- tests/FilterByLikeTest.php | 2 -- 3 files changed, 40 insertions(+), 4 deletions(-) diff --git a/tests/FilterByDateTest.php b/tests/FilterByDateTest.php index e6eae95..887fcf9 100644 --- a/tests/FilterByDateTest.php +++ b/tests/FilterByDateTest.php @@ -55,6 +55,46 @@ class FilterByDateTest extends TestCase $this->assertEquals($date, current($result)->createdAt); } + public function testSuccessFilterDateWithoutTime(): void + { + /** @var PostRepository $postRepository */ + $postRepository = $this->em->getRepository(Post::class); + + $date = DateTimeImmutable::createFromFormat('Y-m-d', '2020-01-01'); + + $post = new Post( + $this->faker->name(), + $this->faker->text(), + $this->faker->boolean(), + $date, + ); + + $post2 = new Post( + $this->faker->name(), + $this->faker->text(), + $this->faker->boolean(), + DateTimeImmutable::createFromInterface($this->faker->dateTime()), + ); + + $this->em->persist($post); + $this->em->persist($post2); + $this->em->flush(); + + $result = $postRepository->createQueryByFilter([ + 'createdAt' => Date::class, + ], new Request([ + HttpFilter::REQUEST_FILTER_KEY => [ + 'createdAt' => $date->format('Y-m-d'), + ], + ])) + ->getQuery() + ->getResult(); + + $this->assertNotEmpty($result); + $this->assertCount(1, $result); + $this->assertEquals($date, current($result)->createdAt); + } + public function testSuccessFilterDateRangeWithSeveralResults(): void { /** @var PostRepository $postRepository */ diff --git a/tests/FilterByInTest.php b/tests/FilterByInTest.php index 020e661..d1bf6e5 100644 --- a/tests/FilterByInTest.php +++ b/tests/FilterByInTest.php @@ -93,8 +93,6 @@ class FilterByInTest extends TestCase $this->assertNotEmpty($result); $this->assertCount(2, $result); - $this->assertStringContainsString($inValues[0], current($result)->title); - $this->assertStringContainsString($inValues[2], next($result)->title); } public function testSuccessFilterInWithoutResults(): void diff --git a/tests/FilterByLikeTest.php b/tests/FilterByLikeTest.php index 3955719..9922b03 100644 --- a/tests/FilterByLikeTest.php +++ b/tests/FilterByLikeTest.php @@ -93,8 +93,6 @@ class FilterByLikeTest extends TestCase $this->assertNotEmpty($result); $this->assertCount(2, $result); - $this->assertStringContainsString($subtitle, current($result)->title); - $this->assertStringContainsString($subtitle, next($result)->title); } public function testSuccessFilterLikeWithoutResults(): void -- GitLab