You are here

protected function StatisticsAdminTest::setUp in Zircon Profile 8

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

Sets up a Drupal site for running functional and integration tests.

Installs Drupal with the installation profile specified in \Drupal\simpletest\WebTestBase::$profile into the prefixed database.

Afterwards, installs any additional modules specified in the static \Drupal\simpletest\WebTestBase::$modules property of each class in the class hierarchy.

After installation all caches are flushed and several configuration values are reset to the values of the parent site executing the test, since the default values may be incompatible with the environment in which tests are being executed.

Overrides WebTestBase::setUp

File

core/modules/statistics/src/Tests/StatisticsAdminTest.php, line 47
Contains \Drupal\statistics\Tests\StatisticsAdminTest.

Class

StatisticsAdminTest
Tests the statistics admin.

Namespace

Drupal\statistics\Tests

Code

protected function setUp() {
  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(array(
      'type' => 'page',
      'name' => 'Basic page',
    ));
  }
  $this->privilegedUser = $this
    ->drupalCreateUser(array(
    'administer statistics',
    'view post access counter',
    'create page content',
  ));
  $this
    ->drupalLogin($this->privilegedUser);
  $this->testNode = $this
    ->drupalCreateNode(array(
    'type' => 'page',
    'uid' => $this->privilegedUser
      ->id(),
  ));
  $this->client = \Drupal::service('http_client_factory')
    ->fromOptions([
    'config/curl' => [
      CURLOPT_TIMEOUT => 10,
    ],
  ]);
}