You are here

public function UserCancelTest::testUserDeleteWithContentAndNodeAccess in Drupal 10

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

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
    ->assertEmpty($load2);
}