2018-09-15 12:56:17 +02:00
|
|
|
<?php
|
2019-10-05 17:26:10 +02:00
|
|
|
|
2018-09-15 12:56:17 +02:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2018-09-20 19:55:24 +02:00
|
|
|
namespace ShlinkioTest\Shlink\Rest\Action\ShortUrl;
|
2018-09-15 12:56:17 +02:00
|
|
|
|
2021-01-03 14:03:10 +01:00
|
|
|
use Laminas\Diactoros\ServerRequestFactory;
|
2022-10-23 22:10:41 +02:00
|
|
|
use PHPUnit\Framework\MockObject\MockObject;
|
2018-09-15 12:56:17 +02:00
|
|
|
use PHPUnit\Framework\TestCase;
|
2022-09-23 18:42:38 +02:00
|
|
|
use Shlinkio\Shlink\Core\ShortUrl\DeleteShortUrlServiceInterface;
|
2018-09-20 19:55:24 +02:00
|
|
|
use Shlinkio\Shlink\Rest\Action\ShortUrl\DeleteShortUrlAction;
|
2021-01-03 14:03:10 +01:00
|
|
|
use Shlinkio\Shlink\Rest\Entity\ApiKey;
|
2018-09-15 12:56:17 +02:00
|
|
|
|
2018-09-20 19:55:24 +02:00
|
|
|
class DeleteShortUrlActionTest extends TestCase
|
2018-09-15 12:56:17 +02:00
|
|
|
{
|
2019-12-29 22:48:40 +01:00
|
|
|
private DeleteShortUrlAction $action;
|
2022-10-23 22:10:41 +02:00
|
|
|
private MockObject $service;
|
2018-09-15 12:56:17 +02:00
|
|
|
|
2022-09-11 12:02:49 +02:00
|
|
|
protected function setUp(): void
|
2018-09-15 12:56:17 +02:00
|
|
|
{
|
2022-10-23 22:10:41 +02:00
|
|
|
$this->service = $this->createMock(DeleteShortUrlServiceInterface::class);
|
|
|
|
$this->action = new DeleteShortUrlAction($this->service);
|
2018-09-15 12:56:17 +02:00
|
|
|
}
|
|
|
|
|
2019-02-17 20:28:34 +01:00
|
|
|
/** @test */
|
|
|
|
public function emptyResponseIsReturnedIfProperlyDeleted(): void
|
2018-09-15 12:56:17 +02:00
|
|
|
{
|
2021-03-14 09:59:35 +01:00
|
|
|
$apiKey = ApiKey::create();
|
2022-10-23 22:10:41 +02:00
|
|
|
$this->service->expects($this->once())->method('deleteByShortCode');
|
2018-09-15 12:56:17 +02:00
|
|
|
|
2021-01-03 14:03:10 +01:00
|
|
|
$resp = $this->action->handle(ServerRequestFactory::fromGlobals()->withAttribute(ApiKey::class, $apiKey));
|
2018-09-15 12:56:17 +02:00
|
|
|
|
2020-10-04 00:35:14 +02:00
|
|
|
self::assertEquals(204, $resp->getStatusCode());
|
2018-09-15 12:56:17 +02:00
|
|
|
}
|
|
|
|
}
|