Added new API test for Options requests

This commit is contained in:
Alejandro Celaya 2019-08-11 14:21:35 +02:00
parent 24e708b7e1
commit 97a362617d
2 changed files with 32 additions and 1 deletions

View File

@ -8,7 +8,7 @@ use ShlinkioTest\Shlink\Common\ApiTest\ApiTestCase;
class ListShortUrlsTest extends ApiTestCase class ListShortUrlsTest extends ApiTestCase
{ {
/** @test */ /** @test */
public function shortUrlsAreProperlyListed() public function shortUrlsAreProperlyListed(): void
{ {
$resp = $this->callApiWithKey(self::METHOD_GET, '/short-urls'); $resp = $this->callApiWithKey(self::METHOD_GET, '/short-urls');
$respPayload = $this->getJsonResponsePayload($resp); $respPayload = $this->getJsonResponsePayload($resp);

View File

@ -0,0 +1,31 @@
<?php
declare(strict_types=1);
namespace ShlinkioApiTest\Shlink\Rest\Action;
use ShlinkioTest\Shlink\Common\ApiTest\ApiTestCase;
use function explode;
class OptionsRequestTest extends ApiTestCase
{
/** @test */
public function optionsRequestsReturnEmptyResponse(): void
{
$resp = $this->callApi(self::METHOD_OPTIONS, '/short-urls');
$this->assertEquals(self::STATUS_NO_CONTENT, $resp->getStatusCode());
$this->assertEmpty((string) $resp->getBody());
}
/** @test */
public function optionsRequestsReturnAllowedMethodsForEndpoint(): void
{
$resp = $this->callApi(self::METHOD_OPTIONS, '/short-urls');
$allowedMethods = $resp->getHeaderLine('Allow');
$this->assertEquals([
self::METHOD_GET,
self::METHOD_POST,
], explode(',', $allowedMethods));
}
}