You are here

protected function GroupContentCreateAccessTest::setUp in Group 8

Same name and namespace in other branches
  1. 2.0.x tests/src/Kernel/GroupContentCreateAccessTest.php \Drupal\Tests\group\Kernel\GroupContentCreateAccessTest::setUp()

Overrides GroupKernelTestBase::setUp

File

tests/src/Kernel/GroupContentCreateAccessTest.php, line 54

Class

GroupContentCreateAccessTest
Tests the group content create access for groups.

Namespace

Drupal\Tests\group\Kernel

Code

protected function setUp() {
  parent::setUp();
  $this
    ->installSchema('node', [
    'node_access',
  ]);
  $this
    ->installEntitySchema('node');
  $this
    ->installEntitySchema('entity_test_with_owner');
  $this
    ->createNodeType([
    'type' => 'page',
  ]);
  $this->accessManager = $this->container
    ->get('access_manager');
  $this->routeProvider = $this->container
    ->get('router.route_provider');
  $this->groupType = $this
    ->createGroupType([
    'id' => 'create_access_test',
    'creator_membership' => FALSE,
  ]);

  // Enable the test plugins on the group type.

  /** @var \Drupal\group\Entity\Storage\GroupContentTypeStorageInterface $storage */
  $storage = $this->entityTypeManager
    ->getStorage('group_content_type');
  $storage
    ->save($storage
    ->createFromPlugin($this->groupType, 'entity_test_as_content'));
  $storage
    ->save($storage
    ->createFromPlugin($this->groupType, 'node_as_content:page'));
  $this->adminRole = $this->entityTypeManager
    ->getStorage('group_role')
    ->create([
    'id' => 'create_access_test-admin',
    'label' => 'Create test admin',
    'weight' => 0,
    'group_type' => $this->groupType
      ->id(),
  ]);
  $this->adminRole
    ->grantPermission('administer group')
    ->save();
}