public function NodeAccessRebuildNodeGrantsTest::testNodeAccessRebuildNodeGrants in Zircon Profile 8.0
Same name and namespace in other branches
- 8 core/modules/node/src/Tests/NodeAccessRebuildNodeGrantsTest.php \Drupal\node\Tests\NodeAccessRebuildNodeGrantsTest::testNodeAccessRebuildNodeGrants()
Tests rebuilding the node access permissions table with content.
File
- core/
modules/ node/ src/ Tests/ NodeAccessRebuildNodeGrantsTest.php, line 40 - 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\TestsCode
public function testNodeAccessRebuildNodeGrants() {
\Drupal::service('module_installer')
->install([
'node_access_test',
]);
$this
->resetAll();
$node = $this
->drupalCreateNode(array(
'uid' => $this->webUser
->id(),
));
// Default realm access and node records are present.
$this
->assertTrue(\Drupal::service('node.grant_storage')
->access($node, 'view', $this->webUser), 'The expected node access records are present');
$this
->assertEqual(1, \Drupal::service('node.grant_storage')
->checkAll($this->webUser), 'There is an all realm access record');
$this
->assertTrue(\Drupal::state()
->get('node.node_access_needs_rebuild'), 'Node access permissions need to be rebuilt');
// Rebuild permissions.
$this
->drupalGet('admin/reports/status/rebuild');
$this
->drupalPostForm(NULL, array(), t('Rebuild permissions'));
$this
->assertText(t('The content access permissions have been rebuilt.'));
// Test if the rebuild has been successful.
$this
->assertNull(\Drupal::state()
->get('node.node_access_needs_rebuild'), 'Node access permissions have been rebuilt');
$this
->assertTrue(\Drupal::service('node.grant_storage')
->access($node, 'view', $this->webUser), 'The expected node access records are present');
$this
->assertFalse(\Drupal::service('node.grant_storage')
->checkAll($this->webUser), 'There is no all realm access record');
}