1
0
mirror of https://github.com/dannyvankooten/AltoRouter.git synced 2025-08-02 14:37:43 +02: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

@@ -234,6 +234,26 @@ class AltoRouterTest extends PHPUnit_Framework_TestCase
$this->router->generate('bar_route', $params)); $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() public function testGenerateWithNonexistingRoute()
{ {
try{ try{
@@ -390,9 +410,7 @@ class AltoRouterTest extends PHPUnit_Framework_TestCase
$this->assertEquals(array( $this->assertEquals(array(
'target' => 'bare_action', 'target' => 'bare_action',
'params' => array( 'params' => array(),
),
'name' => 'bare_route' 'name' => 'bare_route'
), $this->router->match('/', 'GET')); ), $this->router->match('/', 'GET'));
} }