protected function ActionTestBase::setUp in Organic groups 8
Overrides KernelTestBase::setUp
1 call to ActionTestBase::setUp()
- ChangeMultipleOgMembershipRolesActionTestBase::setUp in tests/
src/ Kernel/ Action/ ChangeMultipleOgMembershipRolesActionTestBase.php
1 method overrides ActionTestBase::setUp()
- ChangeMultipleOgMembershipRolesActionTestBase::setUp in tests/
src/ Kernel/ Action/ ChangeMultipleOgMembershipRolesActionTestBase.php
File
- tests/
src/ Kernel/ Action/ ActionTestBase.php, line 83
Class
- ActionTestBase
- Base class for testing action plugins.
Namespace
Drupal\Tests\og\Kernel\ActionCode
protected function setUp() : void {
parent::setUp();
$this
->installEntitySchema('og_membership');
$this
->installEntitySchema('user');
$this
->installEntitySchema('node');
$this
->installSchema('system', [
'sequences',
]);
$this->membershipManager = $this->container
->get('og.membership_manager');
$this->groupTypeManager = $this->container
->get('og.group_type_manager');
// The first user created (with UID 1) is the super user.
$this->users['uid1'] = $this
->createUser();
// Create the group owner. This user will have all rights in the group if
// the 'group_manager_full_access' configuration option is set.
$this->users['group_owner'] = $this
->createUser();
// Create a group entity type.
$group_bundle = mb_strtolower($this
->randomMachineName());
NodeType::create([
'type' => $group_bundle,
'name' => $this
->randomString(),
])
->save();
$this->groupTypeManager
->addGroup('node', $group_bundle);
// Create a test group.
$this->group = Node::create([
'title' => $this
->randomString(),
'type' => $group_bundle,
'uid' => $this->users['group_owner']
->id(),
]);
$this->group
->save();
// Store a reference to the group owner membership that is automatically
// created along with the group.
$this->memberships['group_owner'] = $this->membershipManager
->getMembership($this->group, $this->users['group_owner']
->id());
// Store a reference to the administrator role for our group type.
$this->roles['administrator'] = OgRole::getRole('node', $group_bundle, OgRoleInterface::ADMINISTRATOR);
// Create a 'moderator' role that is allowed to manage group members.
$this->roles['moderator'] = OgRole::create();
$this->roles['moderator']
->setGroupType('node')
->setGroupBundle($group_bundle)
->setName('moderator')
->grantPermission('manage members')
->save();
// Create the remainder of the test users.
$this
->createUsers();
}