$rCached->parse('/test'); $t->is($rCached->getCurrentInternalUri(), 'test/index', '->getCurrentInternalUri() returns the internal URI for last parsed URL using cache'); $rCached->parse('/'); $t->is($rCached->getCurrentInternalUri(), 'default/index', '->getCurrentInternalUri() returns the internal URI for last parsed URL using cache'); // findRoute was added to be the side effectless version to check an uri $parameters = $rCached->findRoute('/test'); $t->is($parameters, array('name' => 'test', 'pattern' => '/:module', 'parameters' => array('action' => 'index', 'module' => 'test')), '->findRoute() returns information about matching route'); $t->is($rCached->getCurrentInternalUri(), 'default/index', '->findRoute() does not change the internal URI of sfPatternRouting'); $t->is($rCached->findRoute('/no/match/found'), null, '->findRoute() returns null on non-matching route'); // current internal uri is reset after negative match $r->clearRoutes(); $r->connect('test', new sfRoute('/test', array('bar' => 'foo'))); $r->parse('/test'); $r->parse('/notfound'); $t->is($r->getCurrentInternalUri(), null, '->getCurrentInternalUri() reseted after negative match'); $t->is($r->getCurrentRouteName(), null, '->getCurrentRouteName() reseted after negative match'); // defaults $t->diag('defaults'); $r->clearRoutes(); $r->connect('test', new sfRoute('/test', array('bar' => 'foo'))); $params = array('module' => 'default', 'action' => 'index'); $url = '/test'; $t->is($r->generate('', $params), $url, '->generate() routes takes default values into account when matching a route'); $params = array('module' => 'default', 'action' => 'index', 'bar' => 'foo'); $t->is($r->generate('', $params), $url, '->generate() routes takes default values into account when matching a route'); $params = array('module' => 'default', 'action' => 'index', 'bar' => 'bar'); try { $r->generate('', $params); $t->fail('->generate() throws a sfConfigurationException if no route matches the params'); } catch (sfConfigurationException $e) { $t->pass('->generate() throws a sfConfigurationException if no route matches the params');