Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,14 @@ class Request implements RequestInterface {

/** @SuppressWarnings("StaticAccess") */
public function __construct(
string $method,
RequestMethod|string $method,
UriInterface $uri,
RequestHeaders $headers
) {
if($method instanceof RequestMethod) {
$method = $method->name;
}

$this->method = RequestMethod::filterMethodName($method);
$this->uri = $uri;
$this->headers = $headers;
Expand Down
12 changes: 12 additions & 0 deletions test/phpunit/RequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,18 @@ public function testGetMethod() {
);
}

public function testConstructorAcceptsRequestMethodCases():void {
foreach(RequestMethod::cases() as $method) {
$request = new Request(
$method,
self::getUriMock(),
self::getHeadersMock()
);

self::assertSame($method->name, $request->getMethod());
}
}

public function testWithMethod() {
$req = new Request(
"get",
Expand Down
Loading