Skip to content

Commit c087798

Browse files
authored
Add support for OPTIONS method (#19)
1 parent 5221717 commit c087798

File tree

3 files changed

+44
-0
lines changed

3 files changed

+44
-0
lines changed

src/Enums/HTTPMethod.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class HTTPMethod extends Enum
1515
const POST = 'POST';
1616
const PUT = 'PUT';
1717
const DELETE = 'DELETE';
18+
const OPTIONS = 'OPTIONS';
1819

1920
public function __toString()
2021
{

src/Traits/Request/Options.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
namespace Firehed\API\Traits\Request;
5+
6+
use Firehed\API\Enums\HTTPMethod;
7+
8+
trait Options
9+
{
10+
11+
public function getMethod(): HTTPMethod
12+
{
13+
return HTTPMethod::OPTIONS();
14+
}
15+
}

tests/Traits/Request/OptionsTest.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
namespace Firehed\API\Traits\Request;
5+
6+
/**
7+
* @coversDefaultClass Firehed\API\Traits\Request\Options
8+
* @covers ::<protected>
9+
* @covers ::<private>
10+
*/
11+
class OptionsTest extends \PHPUnit\Framework\TestCase
12+
{
13+
14+
/**
15+
* @covers ::getMethod
16+
*/
17+
public function testGetMethod()
18+
{
19+
$obj = new class {
20+
use Options;
21+
};
22+
$this->assertEquals(
23+
\Firehed\API\Enums\HTTPMethod::OPTIONS(),
24+
$obj->getMethod(),
25+
'getMethod did not return HTTP OPTIONS'
26+
);
27+
}
28+
}

0 commit comments

Comments
 (0)