You are here

protected function StatisticsAdminTest::setUp in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/statistics/tests/src/Functional/StatisticsAdminTest.php \Drupal\Tests\statistics\Functional\StatisticsAdminTest::setUp()

Overrides BrowserTestBase::setUp

File

core/modules/statistics/tests/src/Functional/StatisticsAdminTest.php, line 51

Class

StatisticsAdminTest
Tests the statistics admin.

Namespace

Drupal\Tests\statistics\Functional

Code

protected function setUp() : void {
  parent::setUp();

  // Set the max age to 0 to simplify testing.
  $this
    ->config('statistics.settings')
    ->set('display_max_age', 0)
    ->save();

  // Create Basic page node type.
  if ($this->profile != 'standard') {
    $this
      ->drupalCreateContentType([
      'type' => 'page',
      'name' => 'Basic page',
    ]);
  }
  $this->privilegedUser = $this
    ->drupalCreateUser([
    'administer statistics',
    'view post access counter',
    'create page content',
  ]);
  $this
    ->drupalLogin($this->privilegedUser);
  $this->testNode = $this
    ->drupalCreateNode([
    'type' => 'page',
    'uid' => $this->privilegedUser
      ->id(),
  ]);
  $this->client = \Drupal::httpClient();
}