1
0
mirror of https://github.com/dannyvankooten/AltoRouter.git synced 2025-01-17 20:28:26 +01:00

add failing test for generate

This commit is contained in:
Koen Punt 2014-12-22 12:18:10 +01:00
parent e72248c744
commit f18a57d481

View File

@ -233,7 +233,27 @@ class AltoRouterTest extends PHPUnit_Framework_TestCase
$this->assertEquals('/test/someaction.json',
$this->router->generate('bar_route', $params));
}
/**
* GitHub #98
*/
public function testGenerateWithOptionalPartOnBareUrl()
{
$this->router->map('GET', '/[i:page]?', function(){}, 'bare_route');
$params = array(
'page' => 1
);
$this->assertEquals('/1',
$this->router->generate('bare_route', $params));
$params = array();
$this->assertEquals('/',
$this->router->generate('bare_route', $params));
}
public function testGenerateWithNonexistingRoute()
{
try{
@ -390,9 +410,7 @@ class AltoRouterTest extends PHPUnit_Framework_TestCase
$this->assertEquals(array(
'target' => 'bare_action',
'params' => array(
),
'params' => array(),
'name' => 'bare_route'
), $this->router->match('/', 'GET'));
}