function RowRenderCacheTest::setUpFixtures

Same name and namespace in other branches
  1. 9 core/modules/views/tests/src/Kernel/Plugin/RowRenderCacheTest.php \Drupal\Tests\views\Kernel\Plugin\RowRenderCacheTest::setUpFixtures()
  2. 8.9.x core/modules/views/tests/src/Kernel/Plugin/RowRenderCacheTest.php \Drupal\Tests\views\Kernel\Plugin\RowRenderCacheTest::setUpFixtures()
  3. 11.x core/modules/views/tests/src/Kernel/Plugin/RowRenderCacheTest.php \Drupal\Tests\views\Kernel\Plugin\RowRenderCacheTest::setUpFixtures()

Sets up the configuration and schema of views and views_test_data modules.

Because the schema of views_test_data.module is dependent on the test using it, it cannot be enabled normally.

Overrides ViewsKernelTestBase::setUpFixtures

File

core/modules/views/tests/src/Kernel/Plugin/RowRenderCacheTest.php, line 62

Class

RowRenderCacheTest
Tests row render caching.

Namespace

Drupal\Tests\views\Kernel\Plugin

Code

protected function setUpFixtures() {
  parent::setUpFixtures();
  $this->installEntitySchema('user');
  $this->installEntitySchema('node');
  $this->installSchema('node', 'node_access');
  NodeType::create([
    'type' => 'test',
    'name' => 'Test',
  ])->save();
  $this->editorUser = $this->createUser([
    'bypass node access',
  ]);
  $this->powerUser = $this->createUser([
    'access content',
    'create test content',
    'edit own test content',
    'delete own test content',
  ]);
  $this->regularUser = $this->createUser([
    'access content',
  ]);
  // Create some test entities.
  for ($i = 0; $i < 5; $i++) {
    Node::create([
      'title' => 'b' . $i . $this->randomMachineName(),
      'type' => 'test',
    ])
      ->save();
  }
  // Create a power user node.
  Node::create([
    'title' => 'z' . $this->randomMachineName(),
    'uid' => $this->powerUser
      ->id(),
    'type' => 'test',
  ])
    ->save();
}

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