You are here

protected function FieldEntityLinkTest::setUpFixtures in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/views/tests/src/Kernel/Handler/FieldEntityLinkTest.php \Drupal\Tests\views\Kernel\Handler\FieldEntityLinkTest::setUpFixtures()
  2. 10 core/modules/views/tests/src/Kernel/Handler/FieldEntityLinkTest.php \Drupal\Tests\views\Kernel\Handler\FieldEntityLinkTest::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/Handler/FieldEntityLinkTest.php, line 45

Class

FieldEntityLinkTest
Tests the core Drupal\views\Plugin\views\field\EntityOperations handler.

Namespace

Drupal\Tests\views\Kernel\Handler

Code

protected function setUpFixtures() {
  parent::setUpFixtures();

  // Create the anonymous user account and set it as current user.
  $this
    ->setUpCurrentUser([
    'uid' => 0,
  ]);
  $this
    ->installEntitySchema('entity_test');
  $this
    ->installConfig([
    'user',
  ]);

  // Create some test entities.
  for ($i = 0; $i < 5; $i++) {
    EntityTest::create([
      'name' => $this
        ->randomString(),
    ])
      ->save();
  }

  // Create and admin user.
  $this->adminUser = $this
    ->createUser([
    'view test entity',
  ], FALSE, TRUE);
  Role::load(AccountInterface::ANONYMOUS_ROLE)
    ->grantPermission('view test entity')
    ->save();
}