You are here

public function FixtureBase::setCurrentUser in Lightning Core 8.4

Same name and namespace in other branches
  1. 8.5 tests/src/FixtureBase.php \Drupal\Tests\lightning_core\FixtureBase::setCurrentUser()
  2. 8.3 tests/src/FixtureBase.php \Drupal\Tests\lightning_core\FixtureBase::setCurrentUser()

Records the current Drupal user ID if possible.

@AfterStep

File

tests/src/FixtureBase.php, line 103

Class

FixtureBase
Base class for contexts which set up and tear down a complete test fixture.

Namespace

Drupal\Tests\lightning_core

Code

public function setCurrentUser() {
  if ($this->userManager) {
    $current_user = $this->userManager
      ->getCurrentUser();
    if ($current_user) {
      $this->users[$current_user->uid] = $current_user->uid;
    }
  }
}