Skip to content

Commit

Permalink
additional tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mrjgreen committed Jul 13, 2014
1 parent 6fd6749 commit 2c6c519
Showing 1 changed file with 40 additions and 1 deletion.
41 changes: 40 additions & 1 deletion test/Dispatcher/DispatcherTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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');
}

/**
Expand All @@ -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()
Expand Down

0 comments on commit 2c6c519

Please sign in to comment.