function CacheTagTest::setUp

Same name and namespace in other branches
  1. 9 core/modules/views/tests/src/Functional/Plugin/CacheTagTest.php \Drupal\Tests\views\Functional\Plugin\CacheTagTest::setUp()
  2. 8.9.x core/modules/views/tests/src/Functional/Plugin/CacheTagTest.php \Drupal\Tests\views\Functional\Plugin\CacheTagTest::setUp()
  3. 10 core/modules/views/tests/src/Functional/Plugin/CacheTagTest.php \Drupal\Tests\views\Functional\Plugin\CacheTagTest::setUp()

Overrides ViewTestBase::setUp

File

core/modules/views/tests/src/Functional/Plugin/CacheTagTest.php, line 84

Class

CacheTagTest
Tests tag cache plugin.

Namespace

Drupal\Tests\views\Functional\Plugin

Code

protected function setUp($import_test_views = TRUE, $modules = [
    'views_test_config',
]) : void {
    parent::setUp($import_test_views, $modules);
    $this->drupalCreateContentType([
        'type' => 'page',
        'name' => 'Basic page',
    ]);
    $this->drupalCreateContentType([
        'type' => 'article',
        'name' => 'Article',
    ]);
    $this->nodeStorage = $this->container
        ->get('entity_type.manager')
        ->getStorage('node');
    $this->nodeViewBuilder = $this->container
        ->get('entity_type.manager')
        ->getViewBuilder('node');
    $this->userViewBuilder = $this->container
        ->get('entity_type.manager')
        ->getViewBuilder('user');
    for ($i = 1; $i <= 5; $i++) {
        $this->pages[] = $this->drupalCreateNode([
            'title' => "Test {$i}",
            'type' => 'page',
        ]);
    }
    $this->article = $this->drupalCreateNode([
        'title' => "Test article",
        'type' => 'article',
    ]);
    $this->user = $this->drupalCreateUser();
    // Mark the current request safe, in order to make render cache working, see
    // \Drupal\Core\Render\RenderCache::get.
    \Drupal::request()->setMethod('GET');
}

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