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