function UserTest::createUserSession
Same name in other branches
- 8.9.x core/modules/user/tests/src/Unit/Plugin/Core/Entity/UserTest.php \Drupal\Tests\user\Unit\Plugin\Core\Entity\UserTest::createUserSession()
- 10 core/modules/user/tests/src/Unit/Plugin/Core/Entity/UserTest.php \Drupal\Tests\user\Unit\Plugin\Core\Entity\UserTest::createUserSession()
- 11.x core/modules/user/tests/src/Unit/Plugin/Core/Entity/UserTest.php \Drupal\Tests\user\Unit\Plugin\Core\Entity\UserTest::createUserSession()
Overrides UserSessionTest::createUserSession
1 call to UserTest::createUserSession()
- UserTest::testUserGetRoles in core/
modules/ user/ tests/ src/ Unit/ Plugin/ Core/ Entity/ UserTest.php - Tests the method getRoles exclude or include locked roles based in param.
File
-
core/
modules/ user/ tests/ src/ Unit/ Plugin/ Core/ Entity/ UserTest.php, line 17
Class
- UserTest
- @coversDefaultClass \Drupal\user\Entity\User @group user
Namespace
Drupal\Tests\user\Unit\Plugin\Core\EntityCode
protected function createUserSession(array $rids = [], $authenticated = FALSE) {
$user = $this->getMockBuilder('Drupal\\user\\Entity\\User')
->disableOriginalConstructor()
->onlyMethods([
'get',
'id',
])
->getMock();
$user->expects($this->any())
->method('id')
->willReturn($authenticated ? 2 : 0);
$roles = [];
foreach ($rids as $rid) {
$roles[] = (object) [
'target_id' => $rid,
];
}
$user->expects($this->any())
->method('get')
->with('roles')
->willReturn($roles);
return $user;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.