From afca66d6557dcbe6b73eb29b9c44be6a4a6d7498 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Fri, 21 Jan 2022 19:58:56 +0100 Subject: [PATCH] Added tests covering tags info with counted ordering and limit --- docker-compose.yml | 2 +- .../Core/test-db/Repository/TagRepositoryTest.php | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 5e2a3bd6..739c0079 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -100,7 +100,7 @@ services: shlink_db_maria: container_name: shlink_db_maria - image: mariadb:10.5 + image: mariadb:10.7 ports: - "3308:3306" volumes: diff --git a/module/Core/test-db/Repository/TagRepositoryTest.php b/module/Core/test-db/Repository/TagRepositoryTest.php index 0ddd04ab..30cb6256 100644 --- a/module/Core/test-db/Repository/TagRepositoryTest.php +++ b/module/Core/test-db/Repository/TagRepositoryTest.php @@ -286,6 +286,20 @@ class TagRepositoryTest extends DatabaseTestCase self::assertEquals($tagNames[3], $result[3]->tag()->__toString()); }, ]; + yield 'visits count DESC ordering and limit' => [ + new TagsListFiltering(2, null, null, Ordering::fromTuple(['visitsCount', 'DESC'])), + static function (array $result, array $tagNames): void { + /** @var TagInfo[] $result */ + self::assertCount(2, $result); + self::assertEquals(2, $result[0]->shortUrlsCount()); + self::assertEquals(4, $result[0]->visitsCount()); + self::assertEquals($tagNames[0], $result[0]->tag()->__toString()); + + self::assertEquals(3, $result[1]->shortUrlsCount()); + self::assertEquals(3, $result[1]->visitsCount()); + self::assertEquals($tagNames[1], $result[1]->tag()->__toString()); + }, + ]; yield 'api key' => [new TagsListFiltering(null, null, null, null, ApiKey::fromMeta( ApiKeyMeta::withRoles(RoleDefinition::forAuthoredShortUrls()), )), static function (array $result, array $tagNames): void {