2019-08-11 14:21:35 +02:00
|
|
|
<?php
|
2019-10-05 17:26:10 +02:00
|
|
|
|
2019-08-11 14:21:35 +02:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2019-08-11 16:30:46 +02:00
|
|
|
namespace ShlinkioApiTest\Shlink\Rest\Middleware;
|
2019-08-11 14:21:35 +02:00
|
|
|
|
2023-02-09 20:42:18 +01:00
|
|
|
use PHPUnit\Framework\Attributes\Test;
|
2019-08-11 16:30:46 +02:00
|
|
|
use Shlinkio\Shlink\TestUtils\ApiTest\ApiTestCase;
|
2019-08-11 14:29:22 +02:00
|
|
|
|
2019-08-11 14:21:35 +02:00
|
|
|
use function explode;
|
|
|
|
|
2019-08-11 16:30:46 +02:00
|
|
|
class ImplicitOptionsTest extends ApiTestCase
|
2019-08-11 14:21:35 +02:00
|
|
|
{
|
2023-02-09 20:42:18 +01:00
|
|
|
#[Test]
|
2019-08-11 14:21:35 +02:00
|
|
|
public function optionsRequestsReturnEmptyResponse(): void
|
|
|
|
{
|
|
|
|
$resp = $this->callApi(self::METHOD_OPTIONS, '/short-urls');
|
|
|
|
|
2020-10-04 00:35:14 +02:00
|
|
|
self::assertEquals(self::STATUS_NO_CONTENT, $resp->getStatusCode());
|
|
|
|
self::assertEmpty((string) $resp->getBody());
|
2019-08-11 14:21:35 +02:00
|
|
|
}
|
|
|
|
|
2023-02-09 20:42:18 +01:00
|
|
|
#[Test]
|
2019-08-11 14:21:35 +02:00
|
|
|
public function optionsRequestsReturnAllowedMethodsForEndpoint(): void
|
|
|
|
{
|
|
|
|
$resp = $this->callApi(self::METHOD_OPTIONS, '/short-urls');
|
|
|
|
$allowedMethods = $resp->getHeaderLine('Allow');
|
|
|
|
|
2020-10-04 00:35:14 +02:00
|
|
|
self::assertEquals([
|
2019-08-11 14:21:35 +02:00
|
|
|
self::METHOD_GET,
|
|
|
|
self::METHOD_POST,
|
|
|
|
], explode(',', $allowedMethods));
|
|
|
|
}
|
|
|
|
}
|