From 3b20f955ff31d8f11183441bc9c9b0bfafa901f1 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sun, 23 Oct 2022 20:27:51 +0200 Subject: [PATCH] Migrated TagsInfoPaginatorAdapterTest to use PHPUnit mocks --- .../Adapter/TagsInfoPaginatorAdapterTest.php | 20 ++++++------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/module/Core/test/Tag/Paginator/Adapter/TagsInfoPaginatorAdapterTest.php b/module/Core/test/Tag/Paginator/Adapter/TagsInfoPaginatorAdapterTest.php index f2f573a4..99ebddf1 100644 --- a/module/Core/test/Tag/Paginator/Adapter/TagsInfoPaginatorAdapterTest.php +++ b/module/Core/test/Tag/Paginator/Adapter/TagsInfoPaginatorAdapterTest.php @@ -4,45 +4,37 @@ declare(strict_types=1); namespace ShlinkioTest\Shlink\Core\Tag\Paginator\Adapter; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; -use Prophecy\Argument; -use Prophecy\PhpUnit\ProphecyTrait; -use Prophecy\Prophecy\ObjectProphecy; use Shlinkio\Shlink\Core\Tag\Model\TagsParams; use Shlinkio\Shlink\Core\Tag\Paginator\Adapter\TagsInfoPaginatorAdapter; use Shlinkio\Shlink\Core\Tag\Repository\TagRepositoryInterface; class TagsInfoPaginatorAdapterTest extends TestCase { - use ProphecyTrait; - private TagsInfoPaginatorAdapter $adapter; - private ObjectProphecy $repo; + private MockObject $repo; protected function setUp(): void { - $this->repo = $this->prophesize(TagRepositoryInterface::class); - $this->adapter = new TagsInfoPaginatorAdapter($this->repo->reveal(), TagsParams::fromRawData([]), null); + $this->repo = $this->createMock(TagRepositoryInterface::class); + $this->adapter = new TagsInfoPaginatorAdapter($this->repo, TagsParams::fromRawData([]), null); } /** @test */ public function getSliceIsDelegatedToRepository(): void { - $findTags = $this->repo->findTagsWithInfo(Argument::cetera())->willReturn([]); - + $this->repo->expects($this->once())->method('findTagsWithInfo')->willReturn([]); $this->adapter->getSlice(1, 1); - - $findTags->shouldHaveBeenCalledOnce(); } /** @test */ public function getNbResultsIsDelegatedToRepository(): void { - $match = $this->repo->matchSingleScalarResult(Argument::cetera())->willReturn(3); + $this->repo->expects($this->once())->method('matchSingleScalarResult')->willReturn(3); $result = $this->adapter->getNbResults(); self::assertEquals(3, $result); - $match->shouldHaveBeenCalledOnce(); } }