You are here

protected function RowRenderCacheTest::setUpFixtures in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/views/tests/src/Kernel/Plugin/RowRenderCacheTest.php \Drupal\Tests\views\Kernel\Plugin\RowRenderCacheTest::setUpFixtures()
  2. 10 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 60

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');
  $type = NodeType::create([
    'type' => 'test',
  ]);
  $type
    ->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();
}