Permalink
Browse files

Merge branch '2.2'

* 2.2:
  Fixed XmlFileLoaderTest::testLoadThrowsExceptionWithInvalidFileEvenWithoutSchemaValidation
  moved file hash calculation to own method
  [Validator] Add check for existing metadata on property
  added support for the X-Forwarded-For header (closes #6982, closes #7000)
  fixed the IP address in HttpCache when calling the backend
  [EventDispatcher] Added assertion.
  [EventDispathcer] Fix removeListener
  [DependencyInjection] Add clone for resources which were introduced in 2.1
  [DependencyInjection] Allow frozen containers to be dumped to graphviz
  Fix 'undefined index' error, when entering scope recursively
  [Security] fixed session creation on login (closes #7011)
  replaced usage of the deprecated pattern routing key (replaced with path)
  Add dot character `.` to legal mime subtype regular expression
  [HttpFoundation] fixed the creation of sub-requests under some circumstancies (closes #6923, closes #6936)
  • Loading branch information...
2 parents 42ae473 + 6b4baba commit 4da2f0d89ec3b62021b5c3342979fa3161ed6357 @fabpot fabpot committed Feb 11, 2013
@@ -12,14 +12,15 @@
namespace Symfony\Component\Routing\Tests\Fixtures;
use Symfony\Component\Routing\Loader\XmlFileLoader;
+use Symfony\Component\Config\Util\XmlUtils;
/**
* XmlFileLoader with schema validation turned off
*/
class CustomXmlFileLoader extends XmlFileLoader
{
- protected function validate(\DOMDocument $dom)
+ protected function loadFile($file)
{
- return true;
+ return XmlUtils::loadFile($file, function() { return true; });
}
}
@@ -1,3 +1,3 @@
blog_show:
resource: validpattern.yml
- pattern: /test
+ path: /test
@@ -1,3 +1,3 @@
blog_show:
- pattern: /blog/{slug}
+ path: /blog/{slug}
type: custom
@@ -1,2 +1,2 @@
"#$péß^a|":
- pattern: "true"
+ path: "true"
@@ -6,9 +6,18 @@
$collection->add('blog_show', new Route(
'/blog/{slug}',
array('_controller' => 'MyBlogBundle:Blog:show'),
- array('_method' => 'GET', 'locale' => '\w+'),
+ array('_method' => 'GET', 'locale' => '\w+', '_scheme' => 'https'),
array('compiler_class' => 'RouteCompiler'),
'{locale}.example.com'
));
+$collection->add('blog_show_legacy', new Route(
+ '/blog/{slug}',
+ array('_controller' => 'MyBlogBundle:Blog:show'),
+ array('locale' => '\w+'),
+ array('compiler_class' => 'RouteCompiler'),
+ '{locale}.example.com',
+ array('https'),
+ array('GET')
+));
return $collection;
@@ -4,9 +4,16 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">
- <route id="blog_show" pattern="/blog/{slug}" host="{locale}.example.com">
+ <route id="blog_show" path="/blog/{slug}" host="{locale}.example.com" methods="GET" schemes="https">
+ <default key="_controller">MyBundle:Blog:show</default>
+ <requirement key="locale">\w+</requirement>
+ <option key="compiler_class">RouteCompiler</option>
+ </route>
+
+ <route id="blog_show_legacy" pattern="/blog/{slug}" host="{locale}.example.com">
<default key="_controller">MyBundle:Blog:show</default>
<requirement key="_method">GET</requirement>
+ <requirement key="_scheme">https</requirement>
<requirement key="locale">\w+</requirement>
<option key="compiler_class">RouteCompiler</option>
</route>
@@ -1,7 +1,17 @@
blog_show:
+ path: /blog/{slug}
+ defaults: { _controller: MyBlogBundle:Blog:show }
+ host: "{locale}.example.com"
+ requirements: { 'locale': '\w+' }
+ methods: ['GET']
+ schemes: ['https']
+ options:
+ compiler_class: RouteCompiler
+
+blog_show_legacy:
pattern: /blog/{slug}
defaults: { _controller: MyBlogBundle:Blog:show }
- host : "{locale}.example.com"
- requirements: { '_method': 'GET', 'locale': '\w+' }
+ host: "{locale}.example.com"
+ requirements: { '_method': 'GET', 'locale': '\w+', _scheme: 'https' }
options:
compiler_class: RouteCompiler
@@ -40,13 +40,16 @@ public function testLoadWithRoute()
$routeCollection = $loader->load('validpattern.php');
$routes = $routeCollection->all();
- $this->assertEquals(1, count($routes), 'One route is loaded');
+ $this->assertCount(2, $routes, 'Two routes are loaded');
$this->assertContainsOnly('Symfony\Component\Routing\Route', $routes);
- $route = $routes['blog_show'];
- $this->assertEquals('/blog/{slug}', $route->getPath());
- $this->assertEquals('MyBlogBundle:Blog:show', $route->getDefault('_controller'));
- $this->assertEquals('GET', $route->getRequirement('_method'));
- $this->assertEquals('{locale}.example.com', $route->getHost());
- $this->assertEquals('RouteCompiler', $route->getOption('compiler_class'));
+
+ foreach ($routes as $route) {
+ $this->assertEquals('/blog/{slug}', $route->getPath());
+ $this->assertEquals('MyBlogBundle:Blog:show', $route->getDefault('_controller'));
+ $this->assertEquals('GET', $route->getRequirement('_method'));
+ $this->assertEquals('https', $route->getRequirement('_scheme'));
+ $this->assertEquals('{locale}.example.com', $route->getHost());
+ $this->assertEquals('RouteCompiler', $route->getOption('compiler_class'));
+ }
}
}
@@ -41,12 +41,13 @@ public function testLoadWithRoute()
$routeCollection = $loader->load('validpattern.xml');
$routes = $routeCollection->all();
- $this->assertEquals(1, count($routes), 'One route is loaded');
+ $this->assertCount(2, $routes, 'Two routes are loaded');
$this->assertContainsOnly('Symfony\Component\Routing\Route', $routes);
$route = $routes['blog_show'];
$this->assertEquals('/blog/{slug}', $route->getPath());
$this->assertEquals('MyBundle:Blog:show', $route->getDefault('_controller'));
$this->assertEquals('GET', $route->getRequirement('_method'));
+ $this->assertEquals('https', $route->getRequirement('_scheme'));
$this->assertEquals('\w+', $route->getRequirement('locale'));
$this->assertEquals('{locale}.example.com', $route->getHost());
$this->assertEquals('RouteCompiler', $route->getOption('compiler_class'));
@@ -57,7 +58,8 @@ public function testLoadWithNamespacePrefix()
$loader = new XmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures')));
$routeCollection = $loader->load('namespaceprefix.xml');
- $this->assertCount(1, $routeCollection, 'One route is loaded');
+ $this->assertCount(1, $routeCollection->all(), 'One route is loaded');
+
$route = $routeCollection->get('blog_show');
$this->assertEquals('/blog/{slug}', $route->getPath());
$this->assertEquals('MyBundle:Blog:show', $route->getDefault('_controller'));
@@ -73,14 +75,17 @@ public function testLoadWithImport()
$routeCollection = $loader->load('validresource.xml');
$routes = $routeCollection->all();
- $this->assertEquals(1, count($routes), 'One route is loaded');
+ $this->assertCount(2, $routes, 'Two routes are loaded');
$this->assertContainsOnly('Symfony\Component\Routing\Route', $routes);
- $this->assertEquals('/{foo}/blog/{slug}', $routes['blog_show']->getPath());
- $this->assertEquals('MyBundle:Blog:show', $routes['blog_show']->getDefault('_controller'));
- $this->assertEquals('123', $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']->getHost());
+
+ foreach ($routes as $route) {
+ $this->assertEquals('/{foo}/blog/{slug}', $routes['blog_show']->getPath());
+ $this->assertEquals('MyBundle:Blog:show', $routes['blog_show']->getDefault('_controller'));
+ $this->assertEquals('123', $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']->getHost());
+ }
}
/**
@@ -79,15 +79,18 @@ public function testLoadWithPattern()
$routeCollection = $loader->load('validpattern.yml');
$routes = $routeCollection->all();
- $this->assertEquals(1, count($routes), 'One route is loaded');
+ $this->assertCount(2, $routes, 'Two routes are loaded');
$this->assertContainsOnly('Symfony\Component\Routing\Route', $routes);
- $route = $routes['blog_show'];
- $this->assertEquals('/blog/{slug}', $route->getPath());
- $this->assertEquals('MyBlogBundle:Blog:show', $route->getDefault('_controller'));
- $this->assertEquals('GET', $route->getRequirement('_method'));
- $this->assertEquals('\w+', $route->getRequirement('locale'));
- $this->assertEquals('{locale}.example.com', $route->getHost());
- $this->assertEquals('RouteCompiler', $route->getOption('compiler_class'));
+
+ foreach ($routes as $route) {
+ $this->assertEquals('/blog/{slug}', $route->getPath());
+ $this->assertEquals('MyBlogBundle:Blog:show', $route->getDefault('_controller'));
+ $this->assertEquals('GET', $route->getRequirement('_method'));
+ $this->assertEquals('https', $route->getRequirement('_scheme'));
+ $this->assertEquals('\w+', $route->getRequirement('locale'));
+ $this->assertEquals('{locale}.example.com', $route->getHost());
+ $this->assertEquals('RouteCompiler', $route->getOption('compiler_class'));
+ }
}
public function testLoadWithResource()
@@ -96,7 +99,7 @@ public function testLoadWithResource()
$routeCollection = $loader->load('validresource.yml');
$routes = $routeCollection->all();
- $this->assertEquals(1, count($routes), 'One route is loaded');
+ $this->assertCount(2, $routes, 'Two routes are loaded');
$this->assertContainsOnly('Symfony\Component\Routing\Route', $routes);
$this->assertEquals('/{foo}/blog/{slug}', $routes['blog_show']->getPath());
$this->assertEquals('MyBlogBundle:Blog:show', $routes['blog_show']->getDefault('_controller'));

0 comments on commit 4da2f0d

Please sign in to comment.