function StatisticsAttachedTest::setUp

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

Overrides BrowserTestBase::setUp

File

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

Class

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

Namespace

Drupal\Tests\statistics\Functional

Code

protected function setUp() {
    parent::setUp();
    $this->drupalCreateContentType([
        'type' => 'page',
    ]);
    // Install "statistics_test_attached" and set it as the default theme.
    $theme = 'statistics_test_attached';
    \Drupal::service('theme_installer')->install([
        $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();
}

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