shlink/module/Rest/test-api/Middleware/ImplicitOptionsTest.php

34 lines
867 B
PHP
Raw Normal View History

<?php
2019-10-05 10:26:10 -05:00
declare(strict_types=1);
2019-08-11 09:30:46 -05:00
namespace ShlinkioApiTest\Shlink\Rest\Middleware;
2019-08-11 09:30:46 -05:00
use Shlinkio\Shlink\TestUtils\ApiTest\ApiTestCase;
use function explode;
2019-08-11 09:30:46 -05:00
class ImplicitOptionsTest extends ApiTestCase
{
/** @test */
public function optionsRequestsReturnEmptyResponse(): void
{
$resp = $this->callApi(self::METHOD_OPTIONS, '/short-urls');
2020-10-03 17:35:14 -05:00
self::assertEquals(self::STATUS_NO_CONTENT, $resp->getStatusCode());
self::assertEmpty((string) $resp->getBody());
}
/** @test */
public function optionsRequestsReturnAllowedMethodsForEndpoint(): void
{
$resp = $this->callApi(self::METHOD_OPTIONS, '/short-urls');
$allowedMethods = $resp->getHeaderLine('Allow');
2020-10-03 17:35:14 -05:00
self::assertEquals([
self::METHOD_GET,
self::METHOD_POST,
], explode(',', $allowedMethods));
}
}