You are here

protected function NotLoggedDeleteAnonymizeTest::checkTestResults in Auto Purge Users 8.3

Check the state of each user.

2 calls to NotLoggedDeleteAnonymizeTest::checkTestResults()
NotLoggedDeleteAnonymizeTest::checkConfirmFormResults in tests/src/Functional/NotLoggedDeleteAnonymizeTest.php
Verifies the expected results of each test.
NotLoggedDeleteAnonymizeTest::checkCronResults in tests/src/Functional/NotLoggedDeleteAnonymizeTest.php
Verifies the expected results of each test.

File

tests/src/Functional/NotLoggedDeleteAnonymizeTest.php, line 59

Class

NotLoggedDeleteAnonymizeTest
Purge users who did not log in for a specific period.

Namespace

Drupal\Tests\purge_users\Functional

Code

protected function checkTestResults() : void {
  $account = $this->userStorage
    ->load($this->admin
    ->id());
  $this
    ->assertNotNull($account);

  // Never logged in user.
  $account = $this->userStorage
    ->load($this->neverLoggedUser
    ->id());
  $this
    ->assertNotNull($account);

  // Active user to be deleted.
  $account = $this->userStorage
    ->load($this->activeUserToDelete
    ->id());
  $this
    ->assertNull($account);

  // Confirm that user's content has been attributed to anonymous user.
  $test_node = $this->nodeStorage
    ->loadUnchanged($this->node
    ->id());
  $this
    ->assertTrue($test_node
    ->getOwnerId() == 0 && $test_node
    ->isPublished());

  // Active user.
  $account = $this->userStorage
    ->load($this->activeUser
    ->id());
  $this
    ->assertNotNull($account);
}