diff --git a/module/Rest/test/Action/Visit/TagVisitsActionTest.php b/module/Rest/test/Action/Visit/TagVisitsActionTest.php index f413a9eb..fd924d17 100644 --- a/module/Rest/test/Action/Visit/TagVisitsActionTest.php +++ b/module/Rest/test/Action/Visit/TagVisitsActionTest.php @@ -6,10 +6,8 @@ namespace ShlinkioTest\Shlink\Rest\Action\Visit; 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 Shlinkio\Shlink\Common\Paginator\Paginator; use Shlinkio\Shlink\Core\Visit\Model\VisitsParams; use Shlinkio\Shlink\Core\Visit\VisitsStatsHelperInterface; @@ -18,15 +16,13 @@ use Shlinkio\Shlink\Rest\Entity\ApiKey; class TagVisitsActionTest extends TestCase { - use ProphecyTrait; - private TagVisitsAction $action; - private ObjectProphecy $visitsHelper; + private MockObject $visitsHelper; protected function setUp(): void { - $this->visitsHelper = $this->prophesize(VisitsStatsHelperInterface::class); - $this->action = new TagVisitsAction($this->visitsHelper->reveal()); + $this->visitsHelper = $this->createMock(VisitsStatsHelperInterface::class); + $this->action = new TagVisitsAction($this->visitsHelper); } /** @test */ @@ -34,15 +30,16 @@ class TagVisitsActionTest extends TestCase { $tag = 'foo'; $apiKey = ApiKey::create(); - $getVisits = $this->visitsHelper->visitsForTag($tag, Argument::type(VisitsParams::class), $apiKey)->willReturn( - new Paginator(new ArrayAdapter([])), - ); + $this->visitsHelper->expects($this->once())->method('visitsForTag')->with( + $tag, + $this->isInstanceOf(VisitsParams::class), + $apiKey, + )->willReturn(new Paginator(new ArrayAdapter([]))); $response = $this->action->handle( ServerRequestFactory::fromGlobals()->withAttribute('tag', $tag)->withAttribute(ApiKey::class, $apiKey), ); self::assertEquals(200, $response->getStatusCode()); - $getVisits->shouldHaveBeenCalledOnce(); } }