I was running a lint check on the examples module (see contrib) and IDE was picking up lots of warnings related to loggedInUser.

Making this small change removed 19 errors/warnings. ( 2% of total )

Looking at my IDE's report of the uses of $loggedInUser it is both variable I would want to be called $isUserLoggedIn and a \Drupal\Core\Session\AccountInterface object.

There is nothing particularly wrong with this design choice...

Writes to loggedInUser

WebTestBase::drupalLogin()
$this->loggedInUser = $account; // $account is of type \Drupal\Core\Session\AccountInterface;

WebTestBase::drupalLogout()
$this->loggedInUser = FALSE;

Read from loggedInUser

SimpleTestExampleTest::testSimeplTestExampleCreate()
reads $this->loggedInUser->getUsername(),

RouterTest::testUserAccount()
reads $this->loggedInUser->id()

Comments

martin107’s picture

StatusFileSize
new440 bytes

Opps stray white space.

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

yeah, why not

jhodgdon’s picture

Status: Reviewed & tested by the community » Fixed

Indeed. Thanks! Committed to 8.0.x.

  • jhodgdon committed 62da091 on 8.0.x
    Issue #2360683 by martin107: Fix docs for WebTestBase::loggedInUser...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.