diff --git a/core/modules/views/src/Plugin/views/display/Page.php b/core/modules/views/src/Plugin/views/display/Page.php index b3954a21a0..b2ec8f25cd 100644 --- a/core/modules/views/src/Plugin/views/display/Page.php +++ b/core/modules/views/src/Plugin/views/display/Page.php @@ -93,6 +93,13 @@ protected function getRoute($view_id, $display_id) { // Explicitly set HTML as the format for Page displays. $route->setRequirement('_format', 'html'); + // Add the _admin_route option only if 'admin_theme' display option is TRUE. + // Otherwise, let other modules or alters to make a decision. + // @see \Drupal\system\EventSubscriber\AdminRouteSubscriber::alterRoutes() + if ($this->getOption('admin_theme')) { + $route->setOption('_admin_route', TRUE); + } + return $route; } @@ -566,18 +573,4 @@ public function calculateDependencies() { return $dependencies; } - /** - * {@inheritdoc} - */ - protected function getRoute($view_id, $display_id) { - $route = parent::getRoute($view_id, $display_id); - // Add the _admin_route option only if 'admin_theme' display option is TRUE. - // Otherwise, let other modules or alters to make a decision. - // @see \Drupal\system\EventSubscriber\AdminRouteSubscriber::alterRoutes() - if ($this->getOption('admin_theme')) { - $route->setOption('_admin_route', TRUE); - } - return $route; - } - } diff --git a/core/modules/views/tests/src/Functional/Plugin/DisplayPageWebTest.php b/core/modules/views/tests/src/Functional/Plugin/DisplayPageWebTest.php index 887981ed46..bc4c30aa7b 100644 --- a/core/modules/views/tests/src/Functional/Plugin/DisplayPageWebTest.php +++ b/core/modules/views/tests/src/Functional/Plugin/DisplayPageWebTest.php @@ -160,7 +160,7 @@ public function testAdminTheme() { // Check that the page has been served with the default theme. $this->drupalGet('test_page_display_200'); - $this->assertNoRaw('seven/css/base/elements.css'); + $this->assertSession()->responseNotContains('seven/css/base/elements.css'); $view = $this->config('views.view.test_page_display'); $view->set('display.page_3.display_options.admin_theme', TRUE)->save(); @@ -168,7 +168,7 @@ public function testAdminTheme() { // Check that the page was served with the administrative theme. $this->drupalGet('test_page_display_200'); - $this->assertRaw('seven/css/base/elements.css'); + $this->assertSession()->responseContains('seven/css/base/elements.css'); } /** diff --git a/core/modules/views/src/Tests/Update/AdminThemeOptionUpdateTest.php b/core/modules/views/tests/src/Functional/Update/AdminThemeOptionUpdateTest.php similarity index 69% rename from core/modules/views/src/Tests/Update/AdminThemeOptionUpdateTest.php rename to core/modules/views/tests/src/Functional/Update/AdminThemeOptionUpdateTest.php index ed75184610..12117aaa4a 100644 --- a/core/modules/views/src/Tests/Update/AdminThemeOptionUpdateTest.php +++ b/core/modules/views/tests/src/Functional/Update/AdminThemeOptionUpdateTest.php @@ -1,8 +1,8 @@ databaseDumpFiles = [ - __DIR__ . '/../../../../system/tests/fixtures/update/drupal-8-rc1.bare.standard.php.gz', + __DIR__ . '/../../../../../system/tests/fixtures/update/drupal-8-rc1.bare.standard.php.gz', ]; } @@ -27,7 +27,7 @@ public function testUpdateAdminThemeOption() { // Check that admin_theme option doesn't exist in 'content' view. $options = $this->config('views.view.content') ->get('display.page_1.display_options'); - $this->assertFalse(isset($options['admin_theme'])); + $this->assertArrayNotHasKey('admin_theme', $options); // Run updates. $this->runUpdates(); @@ -35,9 +35,8 @@ public function testUpdateAdminThemeOption() { // Check that admin_theme option was added in 'content' view and is TRUE. $options = $this->config('views.view.content') ->get('display.page_1.display_options'); - if ($this->assertTrue(isset($options['admin_theme']))) { - $this->assertFalse($options['admin_theme']); - } + $this->assertArrayHasKey('admin_theme', $options); + $this->assertFalse($options['admin_theme']); } }