function IntegrationTest::setUp

Same name in this branch
  1. 9 core/modules/aggregator/tests/src/Kernel/Views/IntegrationTest.php \Drupal\Tests\aggregator\Kernel\Views\IntegrationTest::setUp()
Same name and namespace in other branches
  1. 8.9.x core/modules/aggregator/tests/src/Kernel/Views/IntegrationTest.php \Drupal\Tests\aggregator\Kernel\Views\IntegrationTest::setUp()
  2. 8.9.x core/modules/statistics/tests/src/Functional/Views/IntegrationTest.php \Drupal\Tests\statistics\Functional\Views\IntegrationTest::setUp()
  3. 10 core/modules/statistics/tests/src/Functional/Views/IntegrationTest.php \Drupal\Tests\statistics\Functional\Views\IntegrationTest::setUp()
  4. 11.x core/modules/statistics/tests/src/Functional/Views/IntegrationTest.php \Drupal\Tests\statistics\Functional\Views\IntegrationTest::setUp()

Sets up the test.

Parameters

bool $import_test_views: Should the views specified on the test class be imported. If you need to setup some additional stuff, like fields, you need to call false and then call createTestViews for your own.

array $modules: The module directories to look in for test views.

Overrides ViewTestBase::setUp

File

core/modules/statistics/tests/src/Functional/Views/IntegrationTest.php, line 59

Class

IntegrationTest
Tests basic integration of views data from the statistics module.

Namespace

Drupal\Tests\statistics\Functional\Views

Code

protected function setUp($import_test_views = TRUE, $modules = [
    'statistics_test_views',
]) : void {
    parent::setUp($import_test_views, $modules);
    // Create a new user for viewing nodes and statistics.
    $this->webUser = $this->drupalCreateUser([
        'access content',
        'view post access counter',
    ]);
    // Create a new user for viewing nodes only.
    $this->deniedUser = $this->drupalCreateUser([
        'access content',
    ]);
    $this->drupalCreateContentType([
        'type' => 'page',
    ]);
    $this->node = $this->drupalCreateNode([
        'type' => 'page',
    ]);
    // Enable counting of content views.
    $this->config('statistics.settings')
        ->set('count_content_views', 1)
        ->save();
}

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