3 namespace Drupal\Tests\statistics\Functional;
5 use Drupal\Tests\BrowserTestBase;
6 use Drupal\node\Entity\Node;
9 * Tests if statistics.js is loaded when content is not printed.
13 class StatisticsAttachedTest extends BrowserTestBase {
20 public static $modules = ['node', 'statistics'];
25 protected function setUp() {
28 $this->drupalCreateContentType(['type' => 'page']);
30 // Install "statistics_test_attached" and set it as the default theme.
31 $theme = 'statistics_test_attached';
32 \Drupal::service('theme_handler')->install([$theme]);
33 $this->config('system.theme')
34 ->set('default', $theme)
36 // Installing a theme will cause the kernel terminate event to rebuild the
37 // router. Simulate that here.
38 \Drupal::service('router.builder')->rebuildIfNeeded();
42 * Tests if statistics.js is loaded when content is not printed.
44 public function testAttached() {
46 $node = Node::create([
48 'title' => 'Page node',
52 $this->drupalGet('node/' . $node->id());
54 $this->assertRaw('core/modules/statistics/statistics.js', 'Statistics library is available');