function UserSessionTest::createUserSession
Same name in other branches
- 9 core/tests/Drupal/Tests/Core/Session/UserSessionTest.php \Drupal\Tests\Core\Session\UserSessionTest::createUserSession()
- 8.9.x core/tests/Drupal/Tests/Core/Session/UserSessionTest.php \Drupal\Tests\Core\Session\UserSessionTest::createUserSession()
- 11.x core/tests/Drupal/Tests/Core/Session/UserSessionTest.php \Drupal\Tests\Core\Session\UserSessionTest::createUserSession()
Setups a user session for the test.
Parameters
array $rids: The rids of the user.
bool $authenticated: TRUE if it is an authenticated user.
Return value
\Drupal\Core\Session\AccountInterface The created user session.
3 calls to UserSessionTest::createUserSession()
- UserSessionTest::testHasPermission in core/
tests/ Drupal/ Tests/ Core/ Session/ UserSessionTest.php - Tests the has permission method.
- UserSessionTest::testHasRole in core/
tests/ Drupal/ Tests/ Core/ Session/ UserSessionTest.php - Tests the hasRole method.
- UserSessionTest::testUserGetRoles in core/
tests/ Drupal/ Tests/ Core/ Session/ UserSessionTest.php - Tests the method getRoles exclude or include locked roles based in param.
1 method overrides UserSessionTest::createUserSession()
- UserTest::createUserSession in core/
modules/ user/ tests/ src/ Unit/ Plugin/ Core/ Entity/ UserTest.php - Setups a user session for the test.
File
-
core/
tests/ Drupal/ Tests/ Core/ Session/ UserSessionTest.php, line 30
Class
- UserSessionTest
- @coversDefaultClass \Drupal\Core\Session\UserSession @group Session
Namespace
Drupal\Tests\Core\SessionCode
protected function createUserSession(array $rids = [], $authenticated = FALSE) {
array_unshift($rids, $authenticated ? RoleInterface::AUTHENTICATED_ID : RoleInterface::ANONYMOUS_ID);
return new UserSession([
'roles' => $rids,
]);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.