diff --git a/module/Rest/test/Action/Domain/ListDomainsActionTest.php b/module/Rest/test/Action/Domain/ListDomainsActionTest.php index b04c8d0e..8c7fcc94 100644 --- a/module/Rest/test/Action/Domain/ListDomainsActionTest.php +++ b/module/Rest/test/Action/Domain/ListDomainsActionTest.php @@ -6,9 +6,8 @@ namespace ShlinkioTest\Shlink\Rest\Action\Domain; use Laminas\Diactoros\Response\JsonResponse; use Laminas\Diactoros\ServerRequestFactory; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; -use Prophecy\PhpUnit\ProphecyTrait; -use Prophecy\Prophecy\ObjectProphecy; use Shlinkio\Shlink\Core\Config\NotFoundRedirects; use Shlinkio\Shlink\Core\Domain\DomainServiceInterface; use Shlinkio\Shlink\Core\Domain\Entity\Domain; @@ -19,17 +18,15 @@ use Shlinkio\Shlink\Rest\Entity\ApiKey; class ListDomainsActionTest extends TestCase { - use ProphecyTrait; - private ListDomainsAction $action; - private ObjectProphecy $domainService; + private MockObject $domainService; private NotFoundRedirectOptions $options; protected function setUp(): void { - $this->domainService = $this->prophesize(DomainServiceInterface::class); + $this->domainService = $this->createMock(DomainServiceInterface::class); $this->options = new NotFoundRedirectOptions(); - $this->action = new ListDomainsAction($this->domainService->reveal(), $this->options); + $this->action = new ListDomainsAction($this->domainService, $this->options); } /** @test */ @@ -40,7 +37,7 @@ class ListDomainsActionTest extends TestCase DomainItem::forDefaultDomain('bar.com', new NotFoundRedirectOptions()), DomainItem::forNonDefaultDomain(Domain::withAuthority('baz.com')), ]; - $listDomains = $this->domainService->listDomains($apiKey)->willReturn($domains); + $this->domainService->expects($this->once())->method('listDomains')->with($apiKey)->willReturn($domains); /** @var JsonResponse $resp */ $resp = $this->action->handle(ServerRequestFactory::fromGlobals()->withAttribute(ApiKey::class, $apiKey)); @@ -52,6 +49,5 @@ class ListDomainsActionTest extends TestCase 'defaultRedirects' => NotFoundRedirects::fromConfig($this->options), ], ], $payload); - $listDomains->shouldHaveBeenCalledOnce(); } }