public function UserTest::testUserGetRoles in Drupal 8
Same name and namespace in other branches
- 9 core/modules/user/tests/src/Unit/Plugin/Core/Entity/UserTest.php \Drupal\Tests\user\Unit\Plugin\Core\Entity\UserTest::testUserGetRoles()
Tests the method getRoles exclude or include locked roles based in param.
@covers ::getRoles
Overrides UserSessionTest::testUserGetRoles
See also
\Drupal\user\Entity\User::getRoles()
File
- core/
modules/ user/ tests/ src/ Unit/ Plugin/ Core/ Entity/ UserTest.php, line 45
Class
- UserTest
- @coversDefaultClass \Drupal\user\Entity\User @group user
Namespace
Drupal\Tests\user\Unit\Plugin\Core\EntityCode
public function testUserGetRoles() {
// Anonymous user.
$user = $this
->createUserSession([]);
$this
->assertEquals([
RoleInterface::ANONYMOUS_ID,
], $user
->getRoles());
$this
->assertEquals([], $user
->getRoles(TRUE));
// Authenticated user.
$user = $this
->createUserSession([], TRUE);
$this
->assertEquals([
RoleInterface::AUTHENTICATED_ID,
], $user
->getRoles());
$this
->assertEquals([], $user
->getRoles(TRUE));
}