diff --git a/core/modules/block/src/Tests/BlockHiddenRegionTest.php b/core/modules/block/src/Tests/BlockHiddenRegionTest.php index df45d4d..8bbc376 100644 --- a/core/modules/block/src/Tests/BlockHiddenRegionTest.php +++ b/core/modules/block/src/Tests/BlockHiddenRegionTest.php @@ -53,6 +53,7 @@ public function testBlockNotInHiddenRegion() { $this->drupalGet(''); $this->assertText('Search', 'Block was displayed on the front page.'); + // Install "block_test_theme" and set it as the default theme. $theme = 'block_test_theme'; \Drupal::service('theme_handler')->install(array($theme)); @@ -61,7 +62,7 @@ public function testBlockNotInHiddenRegion() { ->save(); // Installing a theme will cause the kernel terminate event to rebuild the // router. Simulate that here. - \Drupal::service('router.builder')->rebuild(); + \Drupal::service('router.builder')->rebuildIfNeeded(); // Ensure that "block_test_theme" is set as the default theme. $this->drupalGet('admin/structure/block'); diff --git a/core/modules/contact/src/Tests/Views/ContactLinkTest.php b/core/modules/contact/src/Tests/Views/ContactLinkTest.php index 8bc3059..bb7fb91 100644 --- a/core/modules/contact/src/Tests/Views/ContactLinkTest.php +++ b/core/modules/contact/src/Tests/Views/ContactLinkTest.php @@ -47,7 +47,6 @@ protected function setUp() { ViewTestData::createTestViews(get_class($this), array('contact_test_views')); - $this->container->get('router.builder')->rebuild(); $this->userData = $this->container->get('user.data'); } diff --git a/core/modules/content_translation/src/Tests/Views/TranslationLinkTest.php b/core/modules/content_translation/src/Tests/Views/TranslationLinkTest.php index 033eca3..b37666e 100644 --- a/core/modules/content_translation/src/Tests/Views/TranslationLinkTest.php +++ b/core/modules/content_translation/src/Tests/Views/TranslationLinkTest.php @@ -51,7 +51,6 @@ protected function setUp() { $user->save(); ViewTestData::createTestViews(get_class($this), array('content_translation_test_views')); - $this->container->get('router.builder')->rebuild(); } /** diff --git a/core/modules/field_ui/src/Tests/FieldUIRouteTest.php b/core/modules/field_ui/src/Tests/FieldUIRouteTest.php index 6ca3df9..5fd8ec0 100644 --- a/core/modules/field_ui/src/Tests/FieldUIRouteTest.php +++ b/core/modules/field_ui/src/Tests/FieldUIRouteTest.php @@ -80,6 +80,8 @@ public function testFieldUIRoutes() { 'label' => 'Test', 'targetEntityType' => 'user', ))->save(); + $this->container->get('router.builder')->rebuildIfNeeded(); + $edit = array('display_modes_custom[test]' => TRUE); $this->drupalPostForm('admin/config/people/accounts/display', $edit, t('Save')); $this->assertLink('Test'); @@ -91,6 +93,8 @@ public function testFieldUIRoutes() { 'label' => 'Test', 'targetEntityType' => 'user', ))->save(); + $this->container->get('router.builder')->rebuildIfNeeded(); + $edit = array('display_modes_custom[test]' => TRUE); $this->drupalPostForm('admin/config/people/accounts/form-display', $edit, t('Save')); $this->assertLink('Test'); diff --git a/core/modules/node/src/Tests/Views/NodeTestBase.php b/core/modules/node/src/Tests/Views/NodeTestBase.php index db61f94..765f257 100644 --- a/core/modules/node/src/Tests/Views/NodeTestBase.php +++ b/core/modules/node/src/Tests/Views/NodeTestBase.php @@ -27,7 +27,6 @@ protected function setUp($import_test_views = TRUE) { if ($import_test_views) { ViewTestData::createTestViews(get_class($this), array('node_test_views')); - $this->container->get('router.builder')->rebuild(); } } diff --git a/core/modules/user/src/Tests/Views/AccessRoleTest.php b/core/modules/user/src/Tests/Views/AccessRoleTest.php index 9f2e095..f79e86e 100644 --- a/core/modules/user/src/Tests/Views/AccessRoleTest.php +++ b/core/modules/user/src/Tests/Views/AccessRoleTest.php @@ -37,7 +37,7 @@ function testAccessRole() { $this->normalRole => $this->normalRole, ); $view->save(); - $this->container->get('router.builder')->rebuild(); + $this->container->get('router.builder')->rebuildIfNeeded(); $expected = [ 'config' => ['user.role.' . $this->normalRole], 'module' => ['user'], @@ -70,7 +70,7 @@ function testAccessRole() { 'anonymous' => 'anonymous', ); $view->save(); - $this->container->get('router.builder')->rebuild(); + $this->container->get('router.builder')->rebuildIfNeeded(); // Ensure that the list of roles is sorted correctly, if the generated role // ID comes before 'anonymous', see https://www.drupal.org/node/2398259. diff --git a/core/modules/user/src/Tests/Views/UserTestBase.php b/core/modules/user/src/Tests/Views/UserTestBase.php index ede4c22..51017dc 100644 --- a/core/modules/user/src/Tests/Views/UserTestBase.php +++ b/core/modules/user/src/Tests/Views/UserTestBase.php @@ -40,7 +40,6 @@ protected function setUp() { parent::setUp(); ViewTestData::createTestViews(get_class($this), array('user_test_views')); - $this->container->get('router.builder')->rebuild(); $this->users[] = $this->drupalCreateUser(); $this->users[] = user_load(1); diff --git a/core/modules/views/src/Tests/GlossaryTest.php b/core/modules/views/src/Tests/GlossaryTest.php index cc64fb2..a95a0df 100644 --- a/core/modules/views/src/Tests/GlossaryTest.php +++ b/core/modules/views/src/Tests/GlossaryTest.php @@ -62,7 +62,7 @@ public function testGlossaryView() { // Enable the glossary to be displayed. $view->storage->enable()->save(); - $this->container->get('router.builder')->rebuild(); + $this->container->get('router.builder')->rebuildIfNeeded(); // Check the actual page response. $this->drupalGet('glossary'); $this->assertResponse(200); diff --git a/core/modules/views/src/Tests/Plugin/AccessTest.php b/core/modules/views/src/Tests/Plugin/AccessTest.php index 3033ac5..4bc77db 100644 --- a/core/modules/views/src/Tests/Plugin/AccessTest.php +++ b/core/modules/views/src/Tests/Plugin/AccessTest.php @@ -53,7 +53,6 @@ protected function setUp() { $this->enableViewsTestModule(); ViewTestData::createTestViews(get_class($this), array('views_test_data')); - $this->container->get('router.builder')->rebuild(); $this->webUser = $this->drupalCreateUser(); @@ -100,7 +99,7 @@ function testStaticAccessPlugin() { $view->save(); // Saving a view will cause the router to be rebuilt when the kernel // termination event fires. Simulate that here. - $this->container->get('router.builder')->rebuild(); + $this->container->get('router.builder')->rebuildIfNeeded(); $this->assertTrue($access_plugin->access($this->normalUser)); diff --git a/core/modules/views/src/Tests/Plugin/CacheTest.php b/core/modules/views/src/Tests/Plugin/CacheTest.php index 913aab2..354225c 100644 --- a/core/modules/views/src/Tests/Plugin/CacheTest.php +++ b/core/modules/views/src/Tests/Plugin/CacheTest.php @@ -218,6 +218,8 @@ public function testCacheOutputOnPage() { ) )); $view->save(); + $this->container->get('router.builder')->rebuildIfNeeded(); + $output_key = $view->getDisplay()->getPlugin('cache')->generateOutputKey(); $this->assertFalse(\Drupal::cache('render')->get($output_key)); diff --git a/core/modules/views/src/Tests/Plugin/DisabledDisplayTest.php b/core/modules/views/src/Tests/Plugin/DisabledDisplayTest.php index b4ad910..e9052b4 100644 --- a/core/modules/views/src/Tests/Plugin/DisabledDisplayTest.php +++ b/core/modules/views/src/Tests/Plugin/DisabledDisplayTest.php @@ -73,7 +73,7 @@ public function testDisabledDisplays() { $this->assertTrue($enabled, 'Display ' . $display_id . ' is now enabled'); } - \Drupal::service('router.builder')->rebuild(); + \Drupal::service('router.builder')->rebuildIfNeeded(); // Check that the originally disabled page_2 display is now enabled. $this->drupalGet('test-disabled-display-2'); diff --git a/core/modules/views/src/Tests/Plugin/DisplayPageTest.php b/core/modules/views/src/Tests/Plugin/DisplayPageTest.php index 70c78d9..373fe5a 100644 --- a/core/modules/views/src/Tests/Plugin/DisplayPageTest.php +++ b/core/modules/views/src/Tests/Plugin/DisplayPageTest.php @@ -50,8 +50,6 @@ class DisplayPageTest extends ViewUnitTestBase { protected function setUp() { parent::setUp(); - $this->container->get('router.builder')->rebuild(); - // Setup the needed tables in order to make the drupal router working. $this->installSchema('system', array('url_alias')); } diff --git a/core/modules/views/src/Tests/Plugin/DisplayTest.php b/core/modules/views/src/Tests/Plugin/DisplayTest.php index 2d1b287..f5053b9 100644 --- a/core/modules/views/src/Tests/Plugin/DisplayTest.php +++ b/core/modules/views/src/Tests/Plugin/DisplayTest.php @@ -247,7 +247,7 @@ public function testInvalidDisplayPlugins() { // Rebuild the router, and ensure that the path is not accessible anymore. views_invalidate_cache(); - \Drupal::service('router.builder')->rebuild(); + \Drupal::service('router.builder')->rebuildIfNeeded(); $this->drupalGet('test_display_invalid'); $this->assertResponse(404); diff --git a/core/modules/views/src/Tests/ViewTestBase.php b/core/modules/views/src/Tests/ViewTestBase.php index 8e5549b..d0bc989 100644 --- a/core/modules/views/src/Tests/ViewTestBase.php +++ b/core/modules/views/src/Tests/ViewTestBase.php @@ -36,7 +36,6 @@ protected function setUp($import_test_views = TRUE) { parent::setUp(); if ($import_test_views) { ViewTestData::createTestViews(get_class($this), array('views_test_config')); - $this->container->get('router.builder')->rebuild(); } } diff --git a/core/modules/views_ui/src/Tests/DisplayTest.php b/core/modules/views_ui/src/Tests/DisplayTest.php index e9e39f2..1b4d04c 100644 --- a/core/modules/views_ui/src/Tests/DisplayTest.php +++ b/core/modules/views_ui/src/Tests/DisplayTest.php @@ -178,7 +178,7 @@ public function testPageContextualLinks() { $this->drupalLogin($this->drupalCreateUser(array('administer views', 'access contextual links'))); $view = entity_load('view', 'test_display'); $view->enable()->save(); - $this->container->get('router.builder')->rebuild(); + $this->container->get('router.builder')->rebuildIfNeeded(); $this->drupalGet('test-display'); $id = 'entity.view.edit_form:view=test_display:location=page&name=test_display&display_id=page_1';