function StatisticsAttachedTest::testAttached

Same name in other branches
  1. 9 core/modules/statistics/tests/src/Functional/StatisticsAttachedTest.php \Drupal\Tests\statistics\Functional\StatisticsAttachedTest::testAttached()
  2. 8.9.x core/modules/statistics/tests/src/Functional/StatisticsAttachedTest.php \Drupal\Tests\statistics\Functional\StatisticsAttachedTest::testAttached()
  3. 11.x core/modules/statistics/tests/src/Functional/StatisticsAttachedTest.php \Drupal\Tests\statistics\Functional\StatisticsAttachedTest::testAttached()

Tests if statistics.js is loaded when content is not printed.

File

core/modules/statistics/tests/src/Functional/StatisticsAttachedTest.php, line 52

Class

StatisticsAttachedTest
Tests if statistics.js is loaded when content is not printed.

Namespace

Drupal\Tests\statistics\Functional

Code

public function testAttached() : void {
    $node = Node::create([
        'type' => 'page',
        'title' => 'Page node',
        'body' => 'body text',
    ]);
    $node->save();
    $this->drupalGet('node/' . $node->id());
    $this->assertSession()
        ->responseContains('core/modules/statistics/statistics.js');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.