You are here

public function UserCancelTest::testUserDeleteWithContentAndNodeAccess in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/user/tests/src/Functional/UserCancelTest.php \Drupal\Tests\user\Functional\UserCancelTest::testUserDeleteWithContentAndNodeAccess()

Tests user cancel with node access.

File

core/modules/user/tests/src/Functional/UserCancelTest.php, line 598

Class

UserCancelTest
Ensure that account cancellation methods work as expected.

Namespace

Drupal\Tests\user\Functional

Code

public function testUserDeleteWithContentAndNodeAccess() {
  \Drupal::service('module_installer')
    ->install([
    'node_access_test',
  ]);

  // Rebuild node access.
  node_access_rebuild();
  $account = $this
    ->drupalCreateUser([
    'access content',
  ]);
  $node = $this
    ->drupalCreateNode([
    'type' => 'page',
    'uid' => $account
      ->id(),
  ]);
  $account
    ->delete();
  $load2 = \Drupal::entityTypeManager()
    ->getStorage('node')
    ->load($node
    ->id());
  $this
    ->assertTrue(empty($load2));
}