Completed
Pull Request — master (#457)
by Alejandro
06:50
created

ImplicitOptionsTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 9
dl 0
loc 21
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A optionsRequestsReturnEmptyResponse() 0 6 1
A optionsRequestsReturnAllowedMethodsForEndpoint() 0 9 1
1
<?php
2
declare(strict_types=1);
3
4
namespace ShlinkioApiTest\Shlink\Rest\Middleware;
5
6
use Shlinkio\Shlink\TestUtils\ApiTest\ApiTestCase;
7
8
use function explode;
9
10
class ImplicitOptionsTest extends ApiTestCase
11
{
12
    /** @test */
13
    public function optionsRequestsReturnEmptyResponse(): void
14
    {
15
        $resp = $this->callApi(self::METHOD_OPTIONS, '/short-urls');
16
17
        $this->assertEquals(self::STATUS_NO_CONTENT, $resp->getStatusCode());
18
        $this->assertEmpty((string) $resp->getBody());
19
    }
20
21
    /** @test */
22
    public function optionsRequestsReturnAllowedMethodsForEndpoint(): void
23
    {
24
        $resp = $this->callApi(self::METHOD_OPTIONS, '/short-urls');
25
        $allowedMethods = $resp->getHeaderLine('Allow');
26
27
        $this->assertEquals([
28
            self::METHOD_GET,
29
            self::METHOD_POST,
30
        ], explode(',', $allowedMethods));
31
    }
32
}
33