public function EntityMetadataNodeRevisionAccessTestCase::testNodeRevisionAccess in Entity API 7
Tests the entity_access() function for revisions.
File
- ./
entity.test, line 1329 - Entity CRUD API tests.
Class
- EntityMetadataNodeRevisionAccessTestCase
- Tests user permissions for node revisions.
Code
public function testNodeRevisionAccess() {
// $node_revisions[1] won't be the latest revision.
$revision = $this->node_revisions[1];
$parameters = array(
'op' => array_keys($this->map),
'account' => $this->accounts,
);
$permutations = $this
->generatePermutations($parameters);
$entity_type = 'node';
foreach ($permutations as $case) {
if (!empty($case['account']->is_admin) || $case['op'] == $case['account']->op) {
$access = entity_access($case['op'], $entity_type, $revision, $case['account']);
$this
->assertTrue($access, "{$this->map[$case['op']]} granted on {$entity_type}.");
}
else {
$access = entity_access($case['op'], $entity_type, $revision, $case['account']);
$this
->assertFalse($access, "{$this->map[$case['op']]} NOT granted on {$entity_type}.");
}
}
}