mirror of
https://github.com/shlinkio/shlink.git
synced 2025-01-13 09:31:56 -06:00
Migrated ListDomainsActionTest to use PHPUnit mocks
This commit is contained in:
parent
91e21441f7
commit
74176c298f
@ -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();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user