[Routing] added some unit tests for the YAML loader
This commit is contained in:
parent
92f9c1561b
commit
3dfca47bcd
@ -57,7 +57,7 @@ use Symfony\Component\Config\Loader\LoaderResolverInterface;
|
||||
abstract class AnnotationClassLoader implements LoaderInterface
|
||||
{
|
||||
protected $reader;
|
||||
protected $routeAnnotationClass = 'Symfony\\Component\\Routing\\Annotation\\Route';
|
||||
protected $routeAnnotationClass = 'Symfony\\Component\\Routing\\Annotation\\Route';
|
||||
protected $defaultRouteIndex;
|
||||
|
||||
/**
|
||||
@ -97,11 +97,11 @@ abstract class AnnotationClassLoader implements LoaderInterface
|
||||
}
|
||||
|
||||
$globals = array(
|
||||
'pattern' => '',
|
||||
'requirements' => array(),
|
||||
'options' => array(),
|
||||
'defaults' => array(),
|
||||
'hostname_pattern' => null,
|
||||
'pattern' => '',
|
||||
'requirements' => array(),
|
||||
'options' => array(),
|
||||
'defaults' => array(),
|
||||
'hostname_pattern' => null,
|
||||
);
|
||||
|
||||
$class = new \ReflectionClass($class);
|
||||
|
@ -1,5 +1,7 @@
|
||||
blog_show:
|
||||
pattern: /blog/{slug}
|
||||
defaults: { _controller: MyBlogBundle:Blog:show }
|
||||
pattern: /blog/{slug}
|
||||
defaults: { _controller: MyBlogBundle:Blog:show }
|
||||
hostname_pattern: "{locale}.example.com"
|
||||
requirements: { 'foo': '\d+' }
|
||||
options:
|
||||
compiler_class: RouteCompiler
|
||||
|
@ -1,6 +1,7 @@
|
||||
blog_show:
|
||||
resource: validpattern.yml
|
||||
prefix: /{foo}
|
||||
defaults: { 'foo': 'foo' }
|
||||
requirements: { 'foo': '\d+' }
|
||||
options: { 'foo': 'bar' }
|
||||
resource: validpattern.yml
|
||||
prefix: /{foo}
|
||||
defaults: { 'foo': 'foo' }
|
||||
requirements: { 'foo': '\d+' }
|
||||
options: { 'foo': 'bar' }
|
||||
hostname_pattern: "{locale}.example.com"
|
||||
|
@ -88,6 +88,10 @@ class YamlFileLoaderTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals(1, count($routes), 'One route is loaded');
|
||||
$this->assertContainsOnly('Symfony\Component\Routing\Route', $routes);
|
||||
$route = $routes['blog_show'];
|
||||
$this->assertEquals('/blog/{slug}', $route->getPattern());
|
||||
$this->assertEquals('MyBlogBundle:Blog:show', $route->getDefault('_controller'));
|
||||
$this->assertEquals('\d+', $route->getRequirement('foo'));
|
||||
$this->assertEquals('{locale}.example.com', $route->getHostnamePattern());
|
||||
$this->assertEquals('RouteCompiler', $route->getOption('compiler_class'));
|
||||
}
|
||||
|
||||
@ -99,9 +103,12 @@ class YamlFileLoaderTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$this->assertEquals(1, count($routes), 'One route is loaded');
|
||||
$this->assertContainsOnly('Symfony\Component\Routing\Route', $routes);
|
||||
$this->assertEquals('/{foo}/blog/{slug}', $routes['blog_show']->getPattern());
|
||||
$this->assertEquals('MyBlogBundle:Blog:show', $routes['blog_show']->getDefault('_controller'));
|
||||
$this->assertEquals('foo', $routes['blog_show']->getDefault('foo'));
|
||||
$this->assertEquals('\d+', $routes['blog_show']->getRequirement('foo'));
|
||||
$this->assertEquals('bar', $routes['blog_show']->getOption('foo'));
|
||||
$this->assertEquals('{locale}.example.com', $routes['blog_show']->getHostnamePattern());
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user