Chris@0: drupalCreateContentType(['type' => 'page']); Chris@0: Chris@0: // Install "statistics_test_attached" and set it as the default theme. Chris@0: $theme = 'statistics_test_attached'; Chris@0: \Drupal::service('theme_handler')->install([$theme]); Chris@0: $this->config('system.theme') Chris@0: ->set('default', $theme) Chris@0: ->save(); Chris@0: // Installing a theme will cause the kernel terminate event to rebuild the Chris@0: // router. Simulate that here. Chris@0: \Drupal::service('router.builder')->rebuildIfNeeded(); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Tests if statistics.js is loaded when content is not printed. Chris@0: */ Chris@0: public function testAttached() { Chris@0: Chris@0: $node = Node::create([ Chris@0: 'type' => 'page', Chris@0: 'title' => 'Page node', Chris@17: 'body' => 'body text', Chris@0: ]); Chris@0: $node->save(); Chris@0: $this->drupalGet('node/' . $node->id()); Chris@0: Chris@0: $this->assertRaw('core/modules/statistics/statistics.js', 'Statistics library is available'); Chris@0: } Chris@0: Chris@0: }