Based on this question on stackoverflow.com
http://stackoverflow.com/questions/2895834/underscore-as-a-segment-separators-in-routing-yml
It seems that you can't use an underscore as a separator. Is this a bug or by design?
Test here, copy and paste from the symfony test suit with the other separator tests left in to confirm the tests are working.
require_once(dirname(__FILE__).'/../../lib/vendor/symfony/test/bootstrap/unit.php');
$t = new lime_test(15);
class sfPatternRoutingTest extends sfPatternRouting
{
public function initialize(sfEventDispatcher $dispatcher, sfCache $cache = null, $options = array())
{
parent::initialize($dispatcher, $cache, $options);
$this->options['context']['host'] = 'localhost';
}
public function parse($url)
{
$parameters = parent::parse($url);
unset($parameters['_sf_route']);
return $parameters;
}
public function getCurrentRouteName()
{
return $this->currentRouteName;
}
public function isRouteLoaded($name)
{
return isset($this->routes[$name]) && is_object($this->routes[$name]);
}
}
class sfAlwaysAbsoluteRoute extends sfRoute
{
public function generate($params, $context = array(), $absolute = false)
{
$url = parent::generate($params, $context, $absolute);
return 'http://'.$context['host'].$url;
}
}
$options = array('generate_shortest_url' => false, 'extra_parameters_as_query_string' => false);
$t->diag('separators');
$r = new sfPatternRoutingTest(new sfEventDispatcher(), null, array_merge($options, array('segment_separators' => array('/', ';', ':', '|', '.', '-', '+','_'))));
$r->connect('test', new sfRoute('/:module/:action;:foo::baz+static+:toto|:hip-:zozo.:format', array()));
$r->connect('test0', new sfRoute('/:module/:action0', array()));
$r->connect('test1', new sfRoute('/:module;:action1', array()));
$r->connect('test2', new sfRoute('/:module::action2', array()));
$r->connect('test3', new sfRoute('/:module+:action3', array()));
$r->connect('test4', new sfRoute('/:module|:action4', array()));
$r->connect('test5', new sfRoute('/:module.:action5', array()));
$r->connect('test6', new sfRoute('/:module-:action6', array()));
//New test
$r->connect('test7', new sfRoute('/:module_:action7', array()));
$params = array('module' => 'default', 'action' => 'index', 'action0' => 'foobar');
$url = '/default/foobar';
$t->is($r->parse($url), $params, '->parse() recognizes parameters separated by /');
$t->is($r->generate('', $params), $url, '->generate() creates routes with / separator');
$params = array('module' => 'default', 'action' => 'index', 'action1' => 'foobar');
$url = '/default;foobar';
$t->is($r->parse($url), $params, '->parse() recognizes parameters separated by ;');
$t->is($r->generate('', $params), $url, '->generate() creates routes with ; separator');
$params = array('module' => 'default', 'action' => 'index', 'action2' => 'foobar');
$url = '/default:foobar';
$t->is($r->parse($url), $params, '->parse() recognizes parameters separated by :');
$t->is($r->generate('', $params), $url, '->generate() creates routes with : separator');
$params = array('module' => 'default', 'action' => 'index', 'action3' => 'foobar');
$url = '/default+foobar';
$t->is($r->parse($url), $params, '->parse() recognizes parameters separated by +');
$t->is($r->generate('', $params), $url, '->generate() creates routes with + separator');
$params = array('module' => 'default', 'action' => 'index', 'action4' => 'foobar');
$url = '/default|foobar';
$t->is($r->parse($url), $params, '->parse() recognizes parameters separated by |');
$t->is($r->generate('', $params), $url, '->generate() creates routes with | separator');
$params = array('module' => 'default', 'action' => 'index', 'action5' => 'foobar');
$url = '/default.foobar';
$t->is($r->parse($url), $params, '->parse() recognizes parameters separated by .');
$t->is($r->generate('', $params), $url, '->generate() creates routes with . separator');
$params = array('module' => 'default', 'action' => 'index', 'action' => 'index', 'action6' => 'foobar');
$url = '/default-foobar';
$t->is($r->parse($url), $params, '->parse() recognizes parameters separated by -');
$t->is($r->generate('', $params), $url, '->generate() creates routes with - separator');
$params = array('module' => 'default', 'action' => 'index', 'action' => 'index', 'action7' => 'foobar');
//New test
$url = '/default_foobar';
$t->is($r->parse($url), $params, '->parse() recognizes parameters separated by _');
$t->is($r->generate('', $params), $url, '->generate() creates routes with _ separator');
$params = array('module' => 'default', 'action' => 'index', 'action' => 'foobar', 'foo' => 'bar', 'baz' => 'baz', 'toto' => 'titi', 'hip' => 'hop', 'zozo' => 'zaza', 'format' => 'xml');
$url = '/default/foobar;bar:baz+static+titi|hop-zaza.xml';
$t->is($r->parse($url), $params, '->parse() recognizes parameters separated by mixed separators');
$t->is($r->generate('', $params), $url, '->generate() creates routes with mixed separators');