diff --git a/core/modules/node/node.test b/core/modules/node/node.test index 058e0e7..803ce95 100644 --- a/core/modules/node/node.test +++ b/core/modules/node/node.test @@ -2584,3 +2584,72 @@ class NodeAccessFieldTestCase extends NodeWebTestCase { $this->assertRaw($default, 'The updated default value is displayed when creating a new node.'); } } +/** + * Tests the node access system with multiple node access modules installed. + */ +class NodeAccessMultipleTestCase extends NodeWebTestCase { + + public static function getInfo() { + return array( + 'name' => 'Multiple node access modules', + 'description' => 'Tests the node access system with multiple node access modules installed.', + 'group' => 'Node', + ); + } + + public function setUp() { + parent::setUp('node_access_test', 'node_access_admin_test'); + node_access_rebuild(); + + // Create and authenticate a user with grants from both modules. + $this->user = $this->drupalCreateUser(array('node access admin test', 'node test view', 'access content')); + $this->drupalLogin($this->user); + + // Create an article. + $this->node = $this->drupalCreateNode(array('type' => 'article')); + } + + /** + * Tests EFQ conditions with two node access modules. + */ + function testNodeAccessEFQConditions() { + $langcode = LANGUAGE_NOT_SPECIFIED; + + // Show the user's edit grants. + // @todo This is debug code. + $edit_grants = node_access_grants('update', $this->user); + $this->verbose('
' . print_r($edit_grants, TRUE) . '
'); + + // Show the contents of the node access table. + // @todo This is debug code. + $node_access_records = db_query("SELECT * FROM {node_access}")->fetchAll(); + $this->verbose('
' . print_r($node_access_records, TRUE) . '
'); + + // Run an EFQ with multiple EntityConditions. + // @todo This does not trigger the bug. + $query = new EntityFieldQuery(); + $query + ->entityCondition('entity_type', 'node') + ->entityCondition('bundle', 'article') + ->propertyCondition('status', 1); + + // Print out the EFQ object. + // @todo This is debug code. + $this->verbose('
' . print_r($query, TRUE) . '
'); + + $result = $query->execute(); + + // Print out the result. + // @todo This is debug code. + $this->verbose('
' . print_r($result, TRUE) . '
'); + + // Visit the node page. + // @todo This does not trigger the bug. + $this->drupalGet("node/{$this->node->nid}"); + + // Update the node. + // @todo This does not trigger the bug. + $edit["body[$langcode][0][value]"] = 'Hadrosaur from hackensack'; + $this->drupalPost("node/{$this->node->nid}/edit", $edit, t('Save')); + } +} diff --git a/core/modules/node/tests/modules/node_access_admin_test/node_access_admin_test.info b/core/modules/node/tests/modules/node_access_admin_test/node_access_admin_test.info new file mode 100644 index 0000000..252af28 --- /dev/null +++ b/core/modules/node/tests/modules/node_access_admin_test/node_access_admin_test.info @@ -0,0 +1,6 @@ +name = "Node access admin test" +description = "Test module for testing multiple node access modules." +package = Testing +version = VERSION +core = 8.x +hidden = TRUE diff --git a/core/modules/node/tests/modules/node_access_admin_test/node_access_admin_test.module b/core/modules/node/tests/modules/node_access_admin_test/node_access_admin_test.module new file mode 100644 index 0000000..19e69cf --- /dev/null +++ b/core/modules/node/tests/modules/node_access_admin_test/node_access_admin_test.module @@ -0,0 +1,54 @@ +roles) ? array_keys($account->roles) : -1; + return array('node_access_admin_test' => $roles); +} + +/** + * Implements hook_node_access_records(). + */ +function node_access_admin_test_node_access_records($node) { + $grants = array(); + + // Fetch a list of all roles that have our admin permission. + $roles = user_roles(FALSE, 'node access admin test'); + + // Grant full access for roles with the permission. + foreach ($roles as $rid => $role) { + $grants[] = array( + 'realm' => 'node_access_admin_test', + 'gid' => $rid, + 'grant_view' => 1, + 'grant_update' => 1, + 'grant_delete' => 1, + ); + } + + + return $grants; +} + +/** + * Implements hook_permission(). + * + * Sets up permissions for this module. + */ +function node_access_admin_test_permission() { + return array( + 'node access admin test' => array( + 'title' => 'View, update, or delete any published or unpublished node content', + 'restrict_access' => TRUE, + ) + ); +}