From af1cf806f0ec0cbc28d6310711a7489e688b1b5f Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Thu, 6 Jan 2022 10:55:57 +0100 Subject: [PATCH] Created tag paginator adapter tests --- .../Adapter/TagsInfoPaginatorAdapterTest.php | 48 +++++++++++++++++++ .../Adapter/TagsPaginatorAdapterTest.php | 37 ++++++++++++++ .../test/{Service => }/Tag/TagServiceTest.php | 2 +- 3 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 module/Core/test/Tag/Paginator/Adapter/TagsInfoPaginatorAdapterTest.php create mode 100644 module/Core/test/Tag/Paginator/Adapter/TagsPaginatorAdapterTest.php rename module/Core/test/{Service => }/Tag/TagServiceTest.php (99%) diff --git a/module/Core/test/Tag/Paginator/Adapter/TagsInfoPaginatorAdapterTest.php b/module/Core/test/Tag/Paginator/Adapter/TagsInfoPaginatorAdapterTest.php new file mode 100644 index 00000000..2fc354ba --- /dev/null +++ b/module/Core/test/Tag/Paginator/Adapter/TagsInfoPaginatorAdapterTest.php @@ -0,0 +1,48 @@ +repo = $this->prophesize(TagRepositoryInterface::class); + $this->adapter = new TagsInfoPaginatorAdapter($this->repo->reveal(), TagsParams::fromRawData([]), null); + } + + /** @test */ + public function getSliceIsDelegatedToRepository(): void + { + $findTags = $this->repo->findTagsWithInfo(Argument::cetera())->willReturn([]); + + $this->adapter->getSlice(1, 1); + + $findTags->shouldHaveBeenCalledOnce(); + } + + /** @test */ + public function getNbResultsIsDelegatedToRepository(): void + { + $match = $this->repo->matchSingleScalarResult(Argument::cetera())->willReturn(3); + + $result = $this->adapter->getNbResults(); + + self::assertEquals(3, $result); + $match->shouldHaveBeenCalledOnce(); + } +} diff --git a/module/Core/test/Tag/Paginator/Adapter/TagsPaginatorAdapterTest.php b/module/Core/test/Tag/Paginator/Adapter/TagsPaginatorAdapterTest.php new file mode 100644 index 00000000..4cbfd703 --- /dev/null +++ b/module/Core/test/Tag/Paginator/Adapter/TagsPaginatorAdapterTest.php @@ -0,0 +1,37 @@ +repo = $this->prophesize(TagRepositoryInterface::class); + $this->adapter = new TagsPaginatorAdapter($this->repo->reveal(), TagsParams::fromRawData([]), null); + } + + /** @test */ + public function getSliceDelegatesToRepository(): void + { + $match = $this->repo->match(Argument::cetera())->willReturn([]); + + $this->adapter->getSlice(1, 1); + + $match->shouldHaveBeenCalledOnce(); + } +} diff --git a/module/Core/test/Service/Tag/TagServiceTest.php b/module/Core/test/Tag/TagServiceTest.php similarity index 99% rename from module/Core/test/Service/Tag/TagServiceTest.php rename to module/Core/test/Tag/TagServiceTest.php index 40d50b36..75b02163 100644 --- a/module/Core/test/Service/Tag/TagServiceTest.php +++ b/module/Core/test/Tag/TagServiceTest.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace ShlinkioTest\Shlink\Core\Service\Tag; +namespace ShlinkioTest\Shlink\Core\Tag; use Doctrine\ORM\EntityManagerInterface; use PHPUnit\Framework\TestCase;