DeleteShortUrlActionTest.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. declare(strict_types=1);
  3. namespace ShlinkioTest\Shlink\Rest\Action\ShortUrl;
  4. use Laminas\Diactoros\ServerRequest;
  5. use PHPUnit\Framework\TestCase;
  6. use Prophecy\Argument;
  7. use Prophecy\Prophecy\ObjectProphecy;
  8. use Shlinkio\Shlink\Core\Service\ShortUrl\DeleteShortUrlServiceInterface;
  9. use Shlinkio\Shlink\Rest\Action\ShortUrl\DeleteShortUrlAction;
  10. class DeleteShortUrlActionTest extends TestCase
  11. {
  12. private DeleteShortUrlAction $action;
  13. private ObjectProphecy $service;
  14. public function setUp(): void
  15. {
  16. $this->service = $this->prophesize(DeleteShortUrlServiceInterface::class);
  17. $this->action = new DeleteShortUrlAction($this->service->reveal());
  18. }
  19. /** @test */
  20. public function emptyResponseIsReturnedIfProperlyDeleted(): void
  21. {
  22. $deleteByShortCode = $this->service->deleteByShortCode(Argument::any())->will(function (): void {
  23. });
  24. $resp = $this->action->handle(new ServerRequest());
  25. $this->assertEquals(204, $resp->getStatusCode());
  26. $deleteByShortCode->shouldHaveBeenCalledOnce();
  27. }
  28. }