From 2c6c5197d3d11ab248ed95e562e0d043606cae44 Mon Sep 17 00:00:00 2001 From: Joe Green Date: Sun, 13 Jul 2014 10:51:08 +0100 Subject: [PATCH] additional tests --- test/Dispatcher/DispatcherTest.php | 41 +++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) 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()