You are here

public function AnonymousUserSessionTest::testUserGetRoles in Drupal 9

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Core/Session/AnonymousUserSessionTest.php \Drupal\Tests\Core\Session\AnonymousUserSessionTest::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/AnonymousUserSessionTest.php, line 21

Class

AnonymousUserSessionTest
@coversDefaultClass \Drupal\Core\Session\AnonymousUserSession @group Session

Namespace

Drupal\Tests\Core\Session

Code

public function testUserGetRoles() {
  $anonymous_user = new AnonymousUserSession();
  $this
    ->assertEquals([
    RoleInterface::ANONYMOUS_ID,
  ], $anonymous_user
    ->getRoles());
  $this
    ->assertEquals([], $anonymous_user
    ->getRoles(TRUE));
}