Skip to content

Commit

Permalink
Merge branch 'issue-2500' into 4.x
Browse files Browse the repository at this point in the history
Closes #2507
  • Loading branch information
akrabat committed Nov 25, 2018
2 parents 6088d8c + 4eb55c7 commit 4d8f304
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

### Added

- [#2507](https://github.com/slimphp/Slim/pull/2507) Method names are now case-sensitive in Router::map(), and so, by extension, in App::map()
- [#2529](https://github.com/slimphp/Slim/pull/2529) Slim no longer ships with a PSR-7 implementation. You need to provide a PSR-7 ServerRequest and a PSR-17 ResponseFactory to run Slim.
- [#2497](https://github.com/slimphp/Slim/pull/2497) PSR-15 RequestHandlers can now be used as route callables
- [#2496](https://github.com/slimphp/Slim/pull/2496) A Slim App can now be used as PSR-15 Request Handler
Expand Down
3 changes: 0 additions & 3 deletions Slim/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,6 @@ public function map(array $methods, string $pattern, $handler): RouteInterface
$pattern = $this->processGroups() . $pattern;
}

// According to RFC methods are defined in uppercase (See RFC 7231)
$methods = array_map("strtoupper", $methods);

/** @var Route $route */
$route = $this->createRoute($methods, $pattern, $handler);
$this->routes[$route->getIdentifier()] = $route;
Expand Down
15 changes: 14 additions & 1 deletion tests/AppTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,19 @@ public function testMapRoute()
$this->assertAttributeContains('POST', 'methods', $route);
}

public function testMapRouteWithLowercaseMethod()
{
$path = '/foo';
$callable = function ($req, $res) {
// Do something
};
$app = new App($this->getResponseFactory());
$route = $app->map(['get'], $path, $callable);

$this->assertInstanceOf('\Slim\Route', $route);
$this->assertAttributeContains('get', 'methods', $route);
}

public function testRedirectRoute()
{
$source = '/foo';
Expand Down Expand Up @@ -1451,7 +1464,7 @@ public function testContainerSetToRoute()

/** @var Router $router */
$router = $app->getRouter();
$router->map(['get'], '/foo', 'foo:bar');
$router->map(['GET'], '/foo', 'foo:bar');

// Invoke app
$resOut = $app($request, $response);
Expand Down

0 comments on commit 4d8f304

Please sign in to comment.