diff --git a/module/Rest/test/Action/Tag/TagsStatsActionTest.php b/module/Rest/test/Action/Tag/TagsStatsActionTest.php index 44e6afb0..8e0e8e74 100644 --- a/module/Rest/test/Action/Tag/TagsStatsActionTest.php +++ b/module/Rest/test/Action/Tag/TagsStatsActionTest.php @@ -7,10 +7,8 @@ namespace ShlinkioTest\Shlink\Rest\Action\Tag; use Laminas\Diactoros\Response\JsonResponse; use Laminas\Diactoros\ServerRequestFactory; use Pagerfanta\Adapter\ArrayAdapter; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; -use Prophecy\Argument; -use Prophecy\PhpUnit\ProphecyTrait; -use Prophecy\Prophecy\ObjectProphecy; use Psr\Http\Message\ServerRequestInterface; use Shlinkio\Shlink\Common\Paginator\Paginator; use Shlinkio\Shlink\Core\Tag\Model\TagInfo; @@ -22,15 +20,13 @@ use function count; class TagsStatsActionTest extends TestCase { - use ProphecyTrait; - private TagsStatsAction $action; - private ObjectProphecy $tagService; + private MockObject $tagService; protected function setUp(): void { - $this->tagService = $this->prophesize(TagServiceInterface::class); - $this->action = new TagsStatsAction($this->tagService->reveal()); + $this->tagService = $this->createMock(TagServiceInterface::class); + $this->action = new TagsStatsAction($this->tagService); } /** @test */ @@ -41,9 +37,10 @@ class TagsStatsActionTest extends TestCase new TagInfo('bar', 3, 10), ]; $itemsCount = count($stats); - $tagsInfo = $this->tagService->tagsInfo(Argument::any(), Argument::type(ApiKey::class))->willReturn( - new Paginator(new ArrayAdapter($stats)), - ); + $this->tagService->expects($this->once())->method('tagsInfo')->with( + $this->anything(), + $this->isInstanceOf(ApiKey::class), + )->willReturn(new Paginator(new ArrayAdapter($stats))); $req = $this->requestWithApiKey()->withQueryParams(['withStats' => 'true']); /** @var JsonResponse $resp */ @@ -62,7 +59,6 @@ class TagsStatsActionTest extends TestCase ], ], ], $payload); - $tagsInfo->shouldHaveBeenCalled(); } private function requestWithApiKey(): ServerRequestInterface