You are here

protected function UserCreationTrait::setCurrentUser in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/user/tests/src/Traits/UserCreationTrait.php \Drupal\Tests\user\Traits\UserCreationTrait::setCurrentUser()
  2. 9 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.

7 calls to UserCreationTrait::setCurrentUser()
ArgumentValidatorTermNameTest::testArgumentValidatorTermNameAccess in core/modules/taxonomy/tests/src/Kernel/Views/ArgumentValidatorTermNameTest.php
Tests the access checking in term name argument validator plugin.
EntityReferenceSelectionAccessTest::testCommentHandler in core/modules/system/tests/src/Functional/Entity/EntityReferenceSelection/EntityReferenceSelectionAccessTest.php
Tests the comment-specific overrides of the entity handler.
EntityReferenceSelectionAccessTest::testMediaHandler in core/modules/system/tests/src/Functional/Entity/EntityReferenceSelection/EntityReferenceSelectionAccessTest.php
Tests the selection handler for the media entity type.
EntityReferenceSelectionAccessTest::testNodeHandler in core/modules/system/tests/src/Functional/Entity/EntityReferenceSelection/EntityReferenceSelectionAccessTest.php
Tests the node-specific overrides of the entity handler.
EntityReferenceSelectionAccessTest::testTermHandler in core/modules/system/tests/src/Functional/Entity/EntityReferenceSelection/EntityReferenceSelectionAccessTest.php
Tests the term-specific overrides of the selection handler.

... See full list

File

core/modules/user/tests/src/Traits/UserCreationTrait.php, line 135

Class

UserCreationTrait
Provides methods to create additional test users and switch the currently logged in one.

Namespace

Drupal\Tests\user\Traits

Code

protected function setCurrentUser(AccountInterface $account) {
  \Drupal::currentUser()
    ->setAccount($account);
}