Skip to content
Permalink
Browse files

Update thrown message to indicate missing method/route combination.

  • Loading branch information...
mikeu committed Jan 6, 2017
1 parent b70d554 commit 2c3b50fc1eafaf6cfca1c7e8376ce0d7c6281bcf
Showing with 23 additions and 2 deletions.
  1. +5 −1 src/Routing/RouteCollection.php
  2. +18 −1 tests/TestCase/Routing/RouteCollectionTest.php
@@ -144,7 +144,11 @@ public function parse($url, $method = '')
return $r;
}
}
throw new MissingRouteException(['url' => $url]);
throw new MissingRouteException([
'method' => $method,
'url' => $url,
'message' => 'A "%s" route matching "%s" could not be found.',
]);
}
/**
@@ -37,7 +37,7 @@ public function setUp()
* Test parse() throws an error on unknown routes.
*
* @expectedException \Cake\Routing\Exception\MissingRouteException
* @expectedExceptionMessage A route matching "/" could not be found
* @expectedExceptionMessage A "" route matching "/" could not be found
*/
public function testParseMissingRoute()
{
@@ -49,6 +49,23 @@ public function testParseMissingRoute()
$this->assertEquals([], $result, 'Should not match, missing /b');
}
/**
* Test parse() throws an error on known routes called with unknown methods.
*
* @expectedException \Cake\Routing\Exception\MissingRouteException
* @expectedExceptionMessage A "POST" route matching "/b" could not be found
*/
public function testParseMissingRouteMethod()
{
$routes = new RouteBuilder($this->collection, '/b', ['key' => 'value']);
$routes->connect('/', ['controller' => 'Articles', '_method' => ['GET']]);
$result = $this->collection->parse('/b', 'GET');
$this->assertNotEmpty($result, 'Route should be found');
$result = $this->collection->parse('/b', 'POST');
$this->assertEquals([], $result, 'Should not match with missing method');
}
/**
* Test parsing routes.
*

0 comments on commit 2c3b50f

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.