diff --git a/core/modules/statistics/src/Tests/StatisticsAttachedTest.php b/core/modules/statistics/src/Tests/StatisticsAttachedTest.php index 74e448c..ff4e915 100644 --- a/core/modules/statistics/src/Tests/StatisticsAttachedTest.php +++ b/core/modules/statistics/src/Tests/StatisticsAttachedTest.php @@ -8,6 +8,7 @@ namespace Drupal\statistics\Tests; use Drupal\simpletest\WebTestBase; +use Drupal\node\Entity\Node; /** * Tests if statistics.js is loaded when content is not printed. @@ -23,14 +24,23 @@ class StatisticsAttachedTest extends WebTestBase { */ public static $modules = array('node', 'statistics'); + /** + * {@inheritdoc} + */ protected function setUp() { parent::setUp(); - // Set up a test theme that does not print content only content fields. - \Drupal::service('theme_handler')->install(array('statistics_test_attached')); - \Drupal::theme()->setActiveTheme(\Drupal::service('theme.initialization')->initTheme('user_test_theme')); - // Clear the theme registry. - $this->container->set('theme.registry', NULL); + $this->drupalCreateContentType(['type' => 'page']); + + // Install "block_test_theme" and set it as the default theme. + $theme = 'statistics_test_attached'; + \Drupal::service('theme_handler')->install(array($theme)); + $this->config('system.theme') + ->set('default', $theme) + ->save(); + // Installing a theme will cause the kernel terminate event to rebuild the + // router. Simulate that here. + \Drupal::service('router.builder')->rebuildIfNeeded(); } /** @@ -38,6 +48,16 @@ protected function setUp() { */ public function testAttached() { + $node = Node::create([ + 'type' => 'page', + 'title' => 'Page node', + 'body' => 'body text' + ]); + $node->save(); + $page = $this->drupalGet('node/' . $node->id()); + + global $base_root; + $this->assertNotIdentical(strpos($page, '