You are here

protected function OgMembershipRoleReferenceTest::setUp in Organic groups 8

Overrides KernelTestBase::setUp

File

tests/src/Kernel/Entity/OgMembershipRoleReferenceTest.php, line 57

Class

OgMembershipRoleReferenceTest
Test OG membership referencing to OG role creation.

Namespace

Drupal\Tests\og\Kernel\Entity

Code

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

  // Installing needed schema.
  $this
    ->installConfig([
    'og',
  ]);
  $this
    ->installEntitySchema('og_membership');
  $this
    ->installEntitySchema('user');
  $this
    ->installEntitySchema('node');
  $this
    ->installSchema('system', 'sequences');

  // Create a "group" node type and turn it into a group type.
  $this->groupBundle = mb_strtolower($this
    ->randomMachineName());
  NodeType::create([
    'type' => $this->groupBundle,
    'name' => $this
      ->randomString(),
  ])
    ->save();
  Og::groupTypeManager()
    ->addGroup('node', $this->groupBundle);
  $this->user = User::create([
    'name' => $this
      ->randomString(),
  ]);
  $this->user
    ->save();
  $this->group = Node::create([
    'title' => $this
      ->randomString(),
    'uid' => $this->user
      ->id(),
    'type' => $this->groupBundle,
  ]);
  $this->group
    ->save();
}