function ModuleGrantsBaseTestCase::assetNodeViewAccess in Module Grants 7
node_accesses: array of node title => true/false
3 calls to ModuleGrantsBaseTestCase::assetNodeViewAccess()
File
- ./
module_grants.test, line 115
Class
Code
function assetNodeViewAccess($node_accesses, $permissions = array()) {
// first, delete all nodes
$nodes = node_load_multiple(false);
node_delete_multiple(array_keys($nodes));
// then, create the nodes
$this->nodes = array();
$vocabulary = taxonomy_vocabulary_machine_name_load('tags');
$this->term = $this
->createTerm($vocabulary);
$tags[LANGUAGE_NONE][0]['tid'] = $this->term->tid;
foreach ($node_accesses as $node_title => $access) {
$body[LANGUAGE_NONE][0]['value'] = 'A' . $node_title;
$node = $this
->drupalCreateNode(array(
'title' => $node_title,
'type' => 'article',
'field_tags' => $tags,
'body' => $body,
));
$this->nodes[$node_title] = $node;
}
// then create the user
$permissions += array(
'access content',
);
$this->webUser = $this
->drupalCreateUser($permissions);
$this
->drupalLogin($this->webUser);
// test node_access
foreach ($node_accesses as $node_title => $access) {
$node = $this->nodes[$node_title];
$this
->assertNodeAccess(array(
'view' => $access,
), $node, $this->webUser);
}
// test query alter
$this
->assertNodeQueryAlter($node_accesses, $this->webUser);
$this
->assertEntityFieldQueryAlter($node_accesses, $this->webUser);
$this
->assertNonBaseTableViewAccess($node_accesses, $this->webUser);
}