function NodeAccessRebuildNodeGrantsTest::testNodeAccessRebuildNoAccessModules

Same name in other branches
  1. 9 core/modules/node/tests/src/Functional/NodeAccessRebuildNodeGrantsTest.php \Drupal\Tests\node\Functional\NodeAccessRebuildNodeGrantsTest::testNodeAccessRebuildNoAccessModules()
  2. 8.9.x core/modules/node/tests/src/Functional/NodeAccessRebuildNodeGrantsTest.php \Drupal\Tests\node\Functional\NodeAccessRebuildNodeGrantsTest::testNodeAccessRebuildNoAccessModules()
  3. 10 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 111

Class

NodeAccessRebuildNodeGrantsTest
Tests node access rebuild functions with multiple node access modules.

Namespace

Drupal\Tests\node\Functional

Code

public function testNodeAccessRebuildNoAccessModules() : void {
    // 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');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.