You are here

protected function AccessTest::setUserPermissions in Apigee Edge 8

Sets team permissions.

Parameters

array $permissions: Array of team permissions to give.

2 calls to AccessTest::setUserPermissions()
AccessTest::teamAccessTest in modules/apigee_edge_teams/tests/src/Functional/AccessTest.php
Tests team, team membership level and admin permissions.
AccessTest::teamRoleAccessTest in modules/apigee_edge_teams/tests/src/Functional/AccessTest.php
Tests team roles related UIs, permissions.

File

modules/apigee_edge_teams/tests/src/Functional/AccessTest.php, line 634

Class

AccessTest
Teams module access test.

Namespace

Drupal\Tests\apigee_edge_teams\Functional

Code

protected function setUserPermissions(array $permissions) {
  $old_roles = $this->account
    ->getRoles(TRUE);
  foreach ($old_roles as $old_role) {
    $this->account
      ->removeRole($old_role);
  }
  foreach ($permissions as $permission) {
    $this->account
      ->addRole($this->roles[$permission]);
  }

  // It is not necessary to save the developer associated with this user.
  $this
    ->disableUserPresave();
  $this->account
    ->save();
  $this
    ->enableUserPresave();
}