diff --git a/core/modules/rest/tests/src/Unit/CollectRoutesTest.php b/core/modules/rest/tests/src/Unit/CollectRoutesTest.php index c49ff8734efdc8b7e4bbcd5f7e80c1a48f8b9907..8b5d215087fc480488e54aa1a6ec16b661cfaf67 100644 --- a/core/modules/rest/tests/src/Unit/CollectRoutesTest.php +++ b/core/modules/rest/tests/src/Unit/CollectRoutesTest.php @@ -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(); diff --git a/core/modules/views/src/Plugin/views/display/PathPluginBase.php b/core/modules/views/src/Plugin/views/display/PathPluginBase.php index 4df46bccd9924a6123f4a3c2b32de84f0ff774ae..738fbf4d1818d3d2dbc67af716e1834c24e2a359 100644 --- a/core/modules/views/src/Plugin/views/display/PathPluginBase.php +++ b/core/modules/views/src/Plugin/views/display/PathPluginBase.php @@ -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'), diff --git a/core/modules/views/tests/src/Unit/Plugin/display/PathPluginBaseTest.php b/core/modules/views/tests/src/Unit/Plugin/display/PathPluginBaseTest.php index b0ebe13148738fad0abd72d484046d8da9238c21..bae789a93d700cd2b8f9d20b7d94296c4d7ecfbd 100644 --- a/core/modules/views/tests/src/Unit/Plugin/display/PathPluginBaseTest.php +++ b/core/modules/views/tests/src/Unit/Plugin/display/PathPluginBaseTest.php @@ -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.