From d83213341038f69584f2e9a11f2f7d7263946fe3 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sun, 11 Dec 2022 12:33:17 +0100 Subject: [PATCH] Enhanced db tests for expired short urls filtering --- module/Core/src/ShortUrl/Repository/ShortUrlRepository.php | 5 ----- .../test-db/ShortUrl/Repository/ShortUrlRepositoryTest.php | 4 ++++ 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/module/Core/src/ShortUrl/Repository/ShortUrlRepository.php b/module/Core/src/ShortUrl/Repository/ShortUrlRepository.php index 37121bdb..f2a66fda 100644 --- a/module/Core/src/ShortUrl/Repository/ShortUrlRepository.php +++ b/module/Core/src/ShortUrl/Repository/ShortUrlRepository.php @@ -82,11 +82,6 @@ class ShortUrlRepository extends EntitySpecificationRepository implements ShortU $qb->select('COUNT(DISTINCT s)'); $query = $qb->getQuery(); - // TODO Check if this is needed -// if ($filtering->excludeMaxVisitsReached) { -// $qb->addSelect('COUNT(DISTINCT v)'); -// } - // TODO This is crap... return $filtering->excludeMaxVisitsReached ? count($query->getSingleColumnResult()) diff --git a/module/Core/test-db/ShortUrl/Repository/ShortUrlRepositoryTest.php b/module/Core/test-db/ShortUrl/Repository/ShortUrlRepositoryTest.php index 186a4ecf..7f2a5a89 100644 --- a/module/Core/test-db/ShortUrl/Repository/ShortUrlRepositoryTest.php +++ b/module/Core/test-db/ShortUrl/Repository/ShortUrlRepositoryTest.php @@ -378,9 +378,13 @@ class ShortUrlRepositoryTest extends DatabaseTestCase ); self::assertCount(4, $this->repo->findList($filtering(false, false))); + self::assertEquals(4, $this->repo->countList($filtering(false, false))); self::assertCount(3, $this->repo->findList($filtering(true, false))); + self::assertEquals(3, $this->repo->countList($filtering(true, false))); self::assertCount(3, $this->repo->findList($filtering(false, true))); + self::assertEquals(3, $this->repo->countList($filtering(false, true))); self::assertCount(2, $this->repo->findList($filtering(true, true))); + self::assertEquals(2, $this->repo->countList($filtering(true, true))); } /** @test */