You are here

protected function EntityCreateAccessTest::setUp in Organic groups 8

Overrides KernelTestBase::setUp

File

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

Class

EntityCreateAccessTest
Tests access to the create entity form through the user interface.

Namespace

Drupal\Tests\og\Kernel\Entity

Code

protected function setUp() : void {
  parent::setUp();
  $this
    ->installConfig([
    'og',
  ]);
  $this
    ->installEntitySchema('node');
  $this
    ->installEntitySchema('og_membership');
  $this
    ->installEntitySchema('user');
  $this
    ->installSchema('system', 'sequences');

  // Create a "group" node type and turn it into a group type.
  $this->groupType = NodeType::create([
    'type' => 'group',
    'name' => $this
      ->randomString(),
  ]);
  $this->groupType
    ->save();
  Og::groupTypeManager()
    ->addGroup('node', 'group');

  // Add a group audience field to the "post" node type, turning it into a
  // group content type.
  $this->groupContentType = NodeType::create([
    'type' => 'post',
    'name' => $this
      ->randomString(),
  ]);
  $this->groupContentType
    ->save();
  Og::createField(OgGroupAudienceHelperInterface::DEFAULT_FIELD, 'node', 'post');
}