You are here

protected function ActionTestBase::createUsers in Organic groups 8

Creates test users.

1 call to ActionTestBase::createUsers()
ActionTestBase::setUp in tests/src/Kernel/Action/ActionTestBase.php

File

tests/src/Kernel/Action/ActionTestBase.php, line 140

Class

ActionTestBase
Base class for testing action plugins.

Namespace

Drupal\Tests\og\Kernel\Action

Code

protected function createUsers() {

  // An anonymous user.
  $this->users['anonymous'] = new AnonymousUserSession();

  // A normal authenticated user.
  $this->users['authenticated'] = $this
    ->createUser();

  // An administrator with the right to administer groups globally.
  $this->users['administrator'] = $this
    ->createUser([
    'administer organic groups',
  ]);

  // A normal member of the test group.
  $this->users['member'] = $this
    ->createUser();
  $this->memberships['member'] = $this
    ->createOgMembership($this->group, $this->users['member']);

  // A pending member of the test group.
  $this->users['pending'] = $this
    ->createUser();
  $this->memberships['pending'] = $this
    ->createOgMembership($this->group, $this->users['pending'], NULL, OgMembershipInterface::STATE_PENDING);

  // A blocked member of the test group.
  $this->users['blocked'] = $this
    ->createUser();
  $this->memberships['blocked'] = $this
    ->createOgMembership($this->group, $this->users['blocked'], NULL, OgMembershipInterface::STATE_BLOCKED);

  // A group administrator. This is a special case since this role is
  // considered to have all permissions.
  $this->users['group_administrator'] = $this
    ->createUser();
  $this->memberships['group_administrator'] = $this
    ->createOgMembership($this->group, $this->users['group_administrator'], [
    OgRoleInterface::AUTHENTICATED,
    OgRoleInterface::ADMINISTRATOR,
  ]);

  // A group moderator that has the right to administer group members.
  $this->users['group_moderator'] = $this
    ->createUser();
  $this->memberships['group_moderator'] = $this
    ->createOgMembership($this->group, $this->users['group_moderator'], [
    OgRoleInterface::AUTHENTICATED,
    'moderator',
  ]);
}