Skip to content

Commit

Permalink
Add support for OPTIONS method (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
Firehed authored Feb 23, 2018
1 parent 5221717 commit c087798
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Enums/HTTPMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class HTTPMethod extends Enum
const POST = 'POST';
const PUT = 'PUT';
const DELETE = 'DELETE';
const OPTIONS = 'OPTIONS';

public function __toString()
{
Expand Down
15 changes: 15 additions & 0 deletions src/Traits/Request/Options.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php
declare(strict_types=1);

namespace Firehed\API\Traits\Request;

use Firehed\API\Enums\HTTPMethod;

trait Options
{

public function getMethod(): HTTPMethod
{
return HTTPMethod::OPTIONS();
}
}
28 changes: 28 additions & 0 deletions tests/Traits/Request/OptionsTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php
declare(strict_types=1);

namespace Firehed\API\Traits\Request;

/**
* @coversDefaultClass Firehed\API\Traits\Request\Options
* @covers ::<protected>
* @covers ::<private>
*/
class OptionsTest extends \PHPUnit\Framework\TestCase
{

/**
* @covers ::getMethod
*/
public function testGetMethod()
{
$obj = new class {
use Options;
};
$this->assertEquals(
\Firehed\API\Enums\HTTPMethod::OPTIONS(),
$obj->getMethod(),
'getMethod did not return HTTP OPTIONS'
);
}
}

0 comments on commit c087798

Please sign in to comment.