Commit d4677288 authored by alexpott's avatar alexpott

Issue #2516742 by DuaelFr, dawehner: Allow Views to be resolved by TitleResolver

parent 65dd8599
......@@ -49,7 +49,10 @@ protected function setUp() {
'view',
));
$view_executable = $this->getMock('\Drupal\views\ViewExecutable', array('initHandlers'), array(), '', FALSE);
$view_executable = $this->getMock('\Drupal\views\ViewExecutable', array('initHandlers', 'getTitle'), array(), '', FALSE);
$view_executable->expects($this->any())
->method('getTitle')
->willReturn('View title');
$view_executable->storage = $this->view;
$view_executable->argument = array();
......
......@@ -134,6 +134,7 @@ protected function defineOptions() {
protected function getRoute($view_id, $display_id) {
$defaults = array(
'_controller' => 'Drupal\views\Routing\ViewPageController::handle',
'_title' => $this->view->getTitle(),
'view_id' => $view_id,
'display_id' => $display_id,
'_view_display_show_admin_links' => $this->getOption('show_admin_links'),
......
......@@ -108,6 +108,7 @@ public function testCollectRoutes() {
$this->assertEquals('test_id', $route->getDefault('view_id'));
$this->assertEquals('page_1', $route->getDefault('display_id'));
$this->assertSame(FALSE, $route->getOption('returns_response'));
$this->assertEquals('my views title', $route->getDefault('_title'));
}
/**
......@@ -134,6 +135,7 @@ public function testCollectRoutesWithDisplayReturnResponse() {
$this->pathPlugin->collectRoutes($collection);
$route = $collection->get('view.test_id.page_1');
$this->assertSame(TRUE, $route->getOption('returns_response'));
$this->assertEquals('my views title', $route->getDefault('_title'));
}
/**
......@@ -161,6 +163,7 @@ public function testCollectRoutesWithArguments() {
$this->assertEquals('test_id', $route->getDefault('view_id'));
$this->assertEquals('page_1', $route->getDefault('display_id'));
$this->assertEquals(array('arg_0' => 'arg_0'), $route->getOption('_view_argument_map'));
$this->assertEquals('my views title', $route->getDefault('_title'));
}
/**
......@@ -191,6 +194,7 @@ public function testCollectRoutesWithArgumentsNotSpecifiedInPath() {
$this->assertEquals('test_id', $route->getDefault('view_id'));
$this->assertEquals('page_1', $route->getDefault('display_id'));
$this->assertEquals(array('arg_0' => 'arg_0'), $route->getOption('_view_argument_map'));
$this->assertEquals('my views title', $route->getDefault('_title'));
}
/**
......@@ -216,6 +220,7 @@ public function testCollectRoutesWithSpecialRouteName() {
$this->assertTrue($route instanceof Route);
$this->assertEquals('test_id', $route->getDefault('view_id'));
$this->assertEquals('page_1', $route->getDefault('display_id'));
$this->assertEquals('my views title', $route->getDefault('_title'));
}
/**
......@@ -245,6 +250,7 @@ public function testAlterRoute() {
$this->assertTrue($route instanceof Route);
$this->assertEquals('test_id', $route->getDefault('view_id'));
$this->assertEquals('page_1', $route->getDefault('display_id'));
$this->assertEquals('my views title', $route->getDefault('_title'));
// Ensure that the test_route_2 is not overridden.
$route = $collection->get('test_route_2');
......@@ -285,6 +291,7 @@ public function testCollectRoutesWithNamedParameters() {
$this->assertEquals('/test_route/{node}/example', $route->getPath());
$this->assertEquals('test_id', $route->getDefault('view_id'));
$this->assertEquals('page_1', $route->getDefault('display_id'));
$this->assertEquals('my views title', $route->getDefault('_title'));
$this->assertEquals(array('arg_0' => 'node'), $route->getOption('_view_argument_map'));
}
......@@ -322,6 +329,7 @@ public function testAlterRoutesWithParameters() {
// Ensure that the path did not changed and placeholders are respected.
$this->assertEquals('/test_route/{parameter}', $route->getPath());
$this->assertEquals(array('arg_0' => 'parameter'), $route->getOption('_view_argument_map'));
$this->assertEquals('my views title', $route->getDefault('_title'));
}
/**
......@@ -359,6 +367,7 @@ public function testAlterRoutesWithParametersAndUpcasting() {
// Ensure that the path did not changed and placeholders are respected kk.
$this->assertEquals('/test_route/{parameter}', $route->getPath());
$this->assertEquals(['arg_0' => 'parameter'], $route->getOption('_view_argument_map'));
$this->assertEquals('my views title', $route->getDefault('_title'));
}
/**
......@@ -393,6 +402,7 @@ public function testAlterRoutesWithOptionalParameters() {
// 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'));
$this->assertEquals('my views title', $route->getDefault('_title'));
}
/**
......@@ -427,6 +437,10 @@ protected function setupViewExecutableAccessPlugin() {
$view = $this->getMockBuilder('Drupal\views\ViewExecutable')
->disableOriginalConstructor()
->getMock();
$view->expects($this->any())
->method('getTitle')
->willReturn('my views title');
$view->storage = $view_entity;
// Skip views options caching.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment