diff --git a/test/Dispatcher/DispatcherTest.php b/test/Dispatcher/DispatcherTest.php index e4ff609..fd67568 100644 --- a/test/Dispatcher/DispatcherTest.php +++ b/test/Dispatcher/DispatcherTest.php @@ -73,6 +73,16 @@ public function getParameterOptional($param = 'default') { return $param; } + + public function getParameterRequired($param) + { + return $param; + } + + public function getParameterOptionalRequired($param, $param2 = 'default') + { + return $param . $param2; + } } class DispatcherTest extends \PHPUnit_Framework_TestCase { @@ -345,6 +355,35 @@ public function testRestfulControllerMethods() $this->assertEquals('joe', $this->dispatch($r, Route::GET, 'user/parameter-optional/joe')); $this->assertEquals('default', $this->dispatch($r, Route::GET, 'user/parameter-optional')); + $this->assertEquals('joedefault', $this->dispatch($r, Route::GET, 'user/parameter-optional-required/joe')); + $this->assertEquals('joegreen', $this->dispatch($r, Route::GET, 'user/parameter-optional-required/joe/green')); + + } + + /** + * @expectedException \Phroute\Exception\HttpRouteNotFoundException + * @expectedExceptionMessage does not exist + */ + public function testRestfulOptionalRequiredControllerMethodThrows() + { + $r = $this->router(); + + $r->controller('/user', __NAMESPACE__ . '\\Test'); + + $this->dispatch($r, Route::GET, 'user/parameter-optional-required'); + } + + /** + * @expectedException \Phroute\Exception\HttpRouteNotFoundException + * @expectedExceptionMessage does not exist + */ + public function testRestfulRequiredControllerMethodThrows() + { + $r = $this->router(); + + $r->controller('/user', __NAMESPACE__ . '\\Test'); + + $this->dispatch($r, Route::GET, 'user/parameter-required'); } /** @@ -357,7 +396,7 @@ public function testRestfulHyphenateControllerMethodThrows() $r->controller('/user', __NAMESPACE__ . '\\Test'); - $this->assertEquals('hyphenated', $this->dispatch($r, Route::GET, 'user/camelcasehyphenated')); + $this->dispatch($r, Route::GET, 'user/camelcasehyphenated'); } public function testRestfulMethods()