Ejemplo n.º 1
0
 /**
  * Tests altering routes with optional parameters in the overridden route.
  */
 public function testAlterRoutesWithOptionalParameters()
 {
     $collection = new RouteCollection();
     $collection->add('test_route', new Route('test_route/{parameter}', array('_controller' => 'Drupal\\Tests\\Core\\Controller\\TestController::content')));
     list($view) = $this->setupViewExecutableAccessPlugin();
     $display = array();
     $display['display_plugin'] = 'page';
     $display['id'] = 'page_1';
     $display['display_options'] = array('path' => 'test_route/%');
     $display['display_options']['arguments'] = array('test_id' => array(), 'test_id2' => array());
     $this->pathPlugin->initDisplay($view, $display);
     $view_route_names = $this->pathPlugin->alterRoutes($collection);
     $this->assertEquals(array('test_id.page_1' => 'test_route'), $view_route_names);
     // Ensure that the test_route is overridden.
     $route = $collection->get('test_route');
     $this->assertInstanceOf('\\Symfony\\Component\\Routing\\Route', $route);
     $this->assertEquals('test_id', $route->getDefault('view_id'));
     $this->assertEquals('page_1', $route->getDefault('display_id'));
     // Ensure that the path did not changed and placeholders are respected.
     $this->assertEquals('/test_route/{parameter}/{arg_1}', $route->getPath());
     $this->assertEquals(array('arg_0' => 'parameter'), $route->getOption('_view_argument_map'));
 }