shlink/module/Rest/test/Action/ShortUrl/DeleteShortUrlActionTest.php

36 lines
1.1 KiB
PHP
Raw Normal View History

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);
namespace ShlinkioTest\Shlink\Rest\Action\ShortUrl;
2018-09-15 13:56:17 +03:00
use Laminas\Diactoros\ServerRequestFactory;
use PHPUnit\Framework\MockObject\MockObject;
2018-09-15 13:56:17 +03:00
use PHPUnit\Framework\TestCase;
use Shlinkio\Shlink\Core\ShortUrl\DeleteShortUrlServiceInterface;
use Shlinkio\Shlink\Rest\Action\ShortUrl\DeleteShortUrlAction;
use Shlinkio\Shlink\Rest\Entity\ApiKey;
2018-09-15 13:56:17 +03:00
class DeleteShortUrlActionTest extends TestCase
2018-09-15 13:56:17 +03:00
{
private DeleteShortUrlAction $action;
private MockObject $service;
2018-09-15 13:56:17 +03:00
protected function setUp(): void
2018-09-15 13:56:17 +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
{
$apiKey = ApiKey::create();
$this->service->expects($this->once())->method('deleteByShortCode');
2018-09-15 13:56:17 +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
}
}