$t->diag('->prependRoute()'); $r->clearRoutes(); $r->connect('test', new sfRoute('/:module', array('action' => 'index'))); $r->connect('test1', new sfRoute('/:module/:action/*', array())); $route_names = array_keys($r->getRoutes()); $r->clearRoutes(); $r->prependRoute('test', new sfRoute('/:module', array('action' => 'index'))); $r->prependRoute('test1', new sfRoute('/:module/:action/*', array())); $p_route_names = array_keys($r->getRoutes()); $t->is(implode('-', $p_route_names), implode('-', array_reverse($route_names)), '->prependRoute() adds new routes at the beginning of the existings ones'); // ->addRouteBefore() $t->diag('->insertRouteBefore()'); $r->clearRoutes(); $r->connect('test1', new sfRoute('/:module', array('action' => 'index'))); $r->connect('test3', new sfRoute('/:module/:action/*', array())); $r->insertRouteBefore('test3', 'test2', new sfRoute('/:module/:action', array('module' => 'default'))); $route_names = array_keys($r->getRoutes()); $r->clearRoutes(); $r->connect('test1', new sfRoute('/:module', array('action' => 'index'))); $r->connect('test2', new sfRoute('/:module/:action', array('module' => 'default'))); $r->connect('test3', new sfRoute('/:module/:action/*', array())); $test_route_names = array_keys($r->getRoutes()); $t->is(implode('-', $test_route_names), implode('-', $route_names), '->insertRouteBefore() adds a new route before another existings one'); $r->clearRoutes(); $msg = '->insertRouteBefore() throws an sfConfigurationException when trying to insert a route before a non existent one'; try { $r->insertRouteBefore('test2', 'test', new sfRoute('/index.php/:module/:action', array('module' => 'default', 'action' => 'index'))); $t->fail($msg); } catch (sfConfigurationException $e) { $t->pass($msg); }