Skip to content

Commit

Permalink
when creating a route with the 'some' method, methods are case insens…
Browse files Browse the repository at this point in the history
…itive
  • Loading branch information
IngeniozIT committed Feb 25, 2024
1 parent d1abfe4 commit 1931e1e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Route.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public static function some(array $methods, string $path, mixed $callback, ?stri
{
$method = 0;
foreach ($methods as $methodString) {
$method |= self::METHODS[$methodString];
$method |= self::METHODS[strtoupper($methodString)];
}

return new self($method, $path, $callback, $name, $where, $with);
Expand Down
5 changes: 4 additions & 1 deletion tests/RouteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,18 +76,21 @@ public static function providerRouteMethods(): array

public function testCanMatchSomeMethods(): void
{
$route = Route::some(['GET', 'POST'], '/', 'foo');
$route = Route::some(['GET', 'POST', 'delete'], '/', 'foo');
$getRequest = self::serverRequest('GET', '/');
$postRequest = self::serverRequest('POST', '/');
$putRequest = self::serverRequest('PUT', '/');
$deleteRequest = self::serverRequest('DELETE', '/');

$getResult = $route->match($getRequest);
$postResult = $route->match($postRequest);
$putResult = $route->match($putRequest);
$deleteResult = $route->match($deleteRequest);

self::assertSame([], $getResult);
self::assertSame([], $postResult);
self::assertSame(false, $putResult);
self::assertSame([], $deleteResult);
}

public function testMatchesRequestsBasedOnPath(): void
Expand Down

0 comments on commit 1931e1e

Please sign in to comment.