diff --git a/tests/FilterByDateTest.php b/tests/FilterByDateTest.php index e6eae9570ec687e7c9f049dfe0544d0183099504..887fcf9abb27dab4220974de3d37ba899c2c2145 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 020e6614e99857f17276eba223395ce2a479a625..d1bf6e5112868637c8364ca7639daa9e3b4d0c2b 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 395571954ba0a39dd3b2bb0a244c4f3e2664106d..9922b0384cd5fb3809cf13a11b5fe65f20c6331c 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