function UserCreationTrait::setCurrentUser
Same name and namespace in other branches
- 11.x core/modules/user/tests/src/Traits/UserCreationTrait.php \Drupal\Tests\user\Traits\UserCreationTrait::setCurrentUser()
- 10 core/modules/user/tests/src/Traits/UserCreationTrait.php \Drupal\Tests\user\Traits\UserCreationTrait::setCurrentUser()
- 9 core/modules/user/tests/src/Traits/UserCreationTrait.php \Drupal\Tests\user\Traits\UserCreationTrait::setCurrentUser()
- 8.9.x core/modules/user/tests/src/Traits/UserCreationTrait.php \Drupal\Tests\user\Traits\UserCreationTrait::setCurrentUser()
Switch the current logged in user.
Parameters
\Drupal\Core\Session\AccountInterface $account: The user account object.
31 calls to UserCreationTrait::setCurrentUser()
- EntityReferenceSelectionAccessTest::testCommentHandler in core/
modules/ system/ tests/ src/ Kernel/ Entity/ EntityReferenceSelection/ EntityReferenceSelectionAccessTest.php - Tests the comment-specific overrides of the entity handler.
- EntityReferenceSelectionAccessTest::testMediaHandler in core/
modules/ system/ tests/ src/ Kernel/ Entity/ EntityReferenceSelection/ EntityReferenceSelectionAccessTest.php - Tests the selection handler for the media entity type.
- EntityReferenceSelectionAccessTest::testNodeHandler in core/
modules/ system/ tests/ src/ Kernel/ Entity/ EntityReferenceSelection/ EntityReferenceSelectionAccessTest.php - Tests the node-specific overrides of the entity handler.
- EntityReferenceSelectionAccessTest::testTermHandler in core/
modules/ system/ tests/ src/ Kernel/ Entity/ EntityReferenceSelection/ EntityReferenceSelectionAccessTest.php - Tests the term-specific overrides of the selection handler.
- EntityReferenceSelectionAccessTest::testUserHandler in core/
modules/ system/ tests/ src/ Kernel/ Entity/ EntityReferenceSelection/ EntityReferenceSelectionAccessTest.php - Tests the user-specific overrides of the entity handler.
File
-
core/
modules/ user/ tests/ src/ Traits/ UserCreationTrait.php, line 128
Class
- UserCreationTrait
- Provides test methods for user creation and authentication.
Namespace
Drupal\Tests\user\TraitsCode
protected function setCurrentUser(AccountInterface $account) : void {
\Drupal::currentUser()->setAccount($account);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.