You are here

protected function OgRoleTest::setUp in Organic groups 8

Overrides KernelTestBase::setUp

File

tests/src/Kernel/Entity/OgRoleTest.php, line 65

Class

OgRoleTest
Test OG role creation.

Namespace

Drupal\Tests\og\Kernel\Entity

Code

protected function setUp() : void {
  parent::setUp();

  // Installing needed schema.
  $this
    ->installConfig([
    'og',
  ]);
  $this
    ->installEntitySchema('entity_test');
  $this->actionStorage = $this->container
    ->get('entity_type.manager')
    ->getStorage('action');
  $this->groupTypeManager = $this->container
    ->get('og.group_type_manager');
  $this->entityTypeManager = $this->container
    ->get('entity_type.manager');

  // Create two test group types.
  foreach ([
    'node_type',
    'entity_test_bundle',
  ] as $entity_type_id) {
    $definition = $this->entityTypeManager
      ->getDefinition($entity_type_id);
    $values = [
      $definition
        ->getKey('id') => 'group',
      $definition
        ->getKey('label') => 'Group',
    ];
    $group_type = $this->entityTypeManager
      ->getStorage($entity_type_id)
      ->create($values);
    $group_type
      ->save();
    $this->groupTypes[$entity_type_id] = $group_type;
  }
}