You are here

public function NodeAccessRebuildNodeGrantsTest::testNodeAccessRebuildNoAccessModules in Zircon Profile 8

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

Tests rebuilding the node access permissions table with no content.

File

core/modules/node/src/Tests/NodeAccessRebuildNodeGrantsTest.php, line 67
Contains \Drupal\node\Tests\NodeAccessRebuildNodeGrantsTest.

Class

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

Namespace

Drupal\node\Tests

Code

public function testNodeAccessRebuildNoAccessModules() {

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

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

  // Rebuild permissions.
  $this
    ->drupalGet('admin/reports/status');
  $this
    ->clickLink(t('Rebuild permissions'));
  $this
    ->drupalPostForm(NULL, array(), t('Rebuild permissions'));
  $this
    ->assertText(t('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
    ->assertEqual(1, \Drupal::service('node.grant_storage')
    ->count(), 'There is an all realm access record');
}