function StatisticsAdminTest::setUp

Same name in other branches
  1. 9 core/modules/statistics/tests/src/Functional/StatisticsAdminTest.php \Drupal\Tests\statistics\Functional\StatisticsAdminTest::setUp()
  2. 8.9.x core/modules/statistics/tests/src/Functional/StatisticsAdminTest.php \Drupal\Tests\statistics\Functional\StatisticsAdminTest::setUp()
  3. 11.x 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 59

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();
}

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