function AnonymousUserSessionTest::testUserGetRoles

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/Session/AnonymousUserSessionTest.php \Drupal\Tests\Core\Session\AnonymousUserSessionTest::testUserGetRoles()
  2. 8.9.x core/tests/Drupal/Tests/Core/Session/AnonymousUserSessionTest.php \Drupal\Tests\Core\Session\AnonymousUserSessionTest::testUserGetRoles()
  3. 10 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 23

Class

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

Namespace

Drupal\Tests\Core\Session

Code

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

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