You are here

public function EntityPublicationTest::setUp in Permissions by Term 8.2

Overrides KernelTestBase::setUp

File

modules/permissions_by_entity/tests/src/Kernel/EntityPublicationTest.php, line 48

Class

EntityPublicationTest
Class EntityPublicationTest.

Namespace

Drupal\Tests\permissions_by_entity\Kernel

Code

public function setUp() {
  parent::setUp();
  $this
    ->installEntitySchema('test_entity');
  $this
    ->installEntitySchema('user');
  $this
    ->installSchema('system', [
    'key_value_expire',
    'sequences',
  ]);
  $this->nodes['node_unpublished'] = TestEntity::create([
    'langcode' => 'en',
  ]);
  $this->nodes['node_unpublished']
    ->setUnpublished()
    ->save();
  $this->nodes['node_published'] = TestEntity::create([
    'langcode' => 'en',
  ]);
  $this->nodes['node_published']
    ->setPublished()
    ->save();
  $anonymousRole = Role::create([
    'id' => 'anonymous_users',
  ]);
  $anonymousRole
    ->grantPermission('access content');
  $anonymousRole
    ->save();
  $this->anonymousUser = User::create([
    'id' => 0,
    'name' => 'anonymous',
    'email' => 'anonymous@example.com',
  ]);
  $this->anonymousUser
    ->addRole($anonymousRole
    ->id());
  $this->anonymousUser
    ->save();
}