You are here

protected function QueryAccessTest::setUp in Entity API 8

Overrides EntityKernelTestBase::setUp

File

tests/src/Kernel/QueryAccess/QueryAccessTest.php, line 51

Class

QueryAccessTest
Test query access filtering for EntityQuery and Views.

Namespace

Drupal\Tests\entity\Kernel\QueryAccess

Code

protected function setUp() {
  parent::setUp();
  $this
    ->installEntitySchema('entity_test_enhanced');
  $this
    ->installConfig([
    'entity_module_test',
  ]);

  // Create uid: 1 here so that it's skipped in test cases.
  $admin_user = $this
    ->createUser();
  $first_entity = EnhancedEntity::create([
    'type' => 'first',
    'label' => 'First',
    'status' => 1,
  ]);
  $first_entity
    ->save();
  $first_entity
    ->set('name', 'First!');
  $first_entity
    ->set('status', 0);
  $first_entity
    ->setNewRevision(TRUE);
  $first_entity
    ->save();
  $second_entity = EnhancedEntity::create([
    'type' => 'first',
    'label' => 'Second',
    'status' => 0,
  ]);
  $second_entity
    ->save();
  $second_entity
    ->set('name', 'Second!');
  $second_entity
    ->set('status', 1);
  $second_entity
    ->setNewRevision(TRUE);
  $second_entity
    ->save();
  $third_entity = EnhancedEntity::create([
    'type' => 'second',
    'label' => 'Third',
    'status' => 1,
  ]);
  $third_entity
    ->save();
  $third_entity
    ->set('name', 'Third!');
  $third_entity
    ->setNewRevision(TRUE);
  $third_entity
    ->save();
  $this->entities = [
    $first_entity,
    $second_entity,
    $third_entity,
  ];
  $this->storage = $this->entityTypeManager
    ->getStorage('entity_test_enhanced');
}