You are here

public function NodeAccessRebuildNodeGrantsTest::testNodeAccessRebuildNoAccessModules in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/node/tests/src/Functional/NodeAccessRebuildNodeGrantsTest.php \Drupal\Tests\node\Functional\NodeAccessRebuildNodeGrantsTest::testNodeAccessRebuildNoAccessModules()

Tests rebuilding the node access permissions table with no content.

File

core/modules/node/tests/src/Functional/NodeAccessRebuildNodeGrantsTest.php, line 109

Class

NodeAccessRebuildNodeGrantsTest
Ensures that node access rebuild functions work correctly even when other modules implements hook_node_grants().

Namespace

Drupal\Tests\node\Functional

Code

public function testNodeAccessRebuildNoAccessModules() {

  // Default realm access is present.
  $this
    ->assertEquals(1, \Drupal::service('node.grant_storage')
    ->count(), 'There is an all realm access record');

  // No need to rebuild permissions.
  $this
    ->assertNull(\Drupal::state()
    ->get('node.node_access_needs_rebuild'), 'Node access permissions need to be rebuilt');

  // Rebuild permissions.
  $this
    ->drupalGet('admin/reports/status');
  $this
    ->clickLink('Rebuild permissions');
  $this
    ->submitForm([], 'Rebuild permissions');
  $this
    ->assertSession()
    ->pageTextContains('Content permissions have been rebuilt.');
  $this
    ->assertNull(\Drupal::state()
    ->get('node.node_access_needs_rebuild'), 'Node access permissions have been rebuilt');

  // Default realm access is still present.
  $this
    ->assertEquals(1, \Drupal::service('node.grant_storage')
    ->count(), 'There is an all realm access record');
}