You are here

protected function StatisticsAttachedTest::setUp in Drupal 9

Same name and namespace in other branches
  1. 8 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() : void {
  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();
}