function UserSessionTest::testUserGetRoles

Same name and namespace in other branches
  1. 11.x core/tests/Drupal/Tests/Core/Session/UserSessionTest.php \Drupal\Tests\Core\Session\UserSessionTest::testUserGetRoles()
  2. 10 core/tests/Drupal/Tests/Core/Session/UserSessionTest.php \Drupal\Tests\Core\Session\UserSessionTest::testUserGetRoles()
  3. 8.9.x core/tests/Drupal/Tests/Core/Session/UserSessionTest.php \Drupal\Tests\Core\Session\UserSessionTest::testUserGetRoles()

Tests the method getRoles exclude or include locked roles based in param.

@covers ::getRoles
@todo Move roles constants to a class/interface

File

core/tests/Drupal/Tests/Core/Session/UserSessionTest.php, line 160

Class

UserSessionTest
@coversDefaultClass \Drupal\Core\Session\UserSession[[api-linebreak]] @group Session

Namespace

Drupal\Tests\Core\Session

Code

public function testUserGetRoles() {
  $this->assertEquals([
    RoleInterface::AUTHENTICATED_ID,
    'role_two',
  ], $this->users['user_three']
    ->getRoles());
  $this->assertEquals([
    'role_two',
  ], $this->users['user_three']
    ->getRoles(TRUE));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.