protected function NodeaccesssRoleTestCase::checkRoleGrantAccesses in Nodeaccess 7
This method will check the access for the node based on grants supplied.
Parameters
array $grants: Array of role grants to check.
5 calls to NodeaccesssRoleTestCase::checkRoleGrantAccesses()
- NodeaccesssRoleTestCase::testRoleNodeVisibilityAllAuthenticatedOnly in tests/
nodeaccess_role.test - Test node access when authenticated only should have full access.
- NodeaccesssRoleTestCase::testRoleNodeVisibilityFullAccess in tests/
nodeaccess_role.test - Test node access when anon and authenticated users should have full access.
- NodeaccesssRoleTestCase::testRoleNodeVisibilityNoAccess in tests/
nodeaccess_role.test - Test node access when there should be no access whatsoever.
- NodeaccesssRoleTestCase::testRoleNodeVisibilityViewAuthenticatedOnly in tests/
nodeaccess_role.test - Test node access when only Authenticated users should have view access.
- NodeaccesssRoleTestCase::testRoleNodeVisibilityViewEditAuthenticatedOnly in tests/
nodeaccess_role.test - Test node access when authenticated only should have view/edit perms.
File
- tests/
nodeaccess_role.test, line 191 - Tests for the nodeaccess module.
Class
- NodeaccesssRoleTestCase
- Tests the functionality of the nodeaccess module.
Code
protected function checkRoleGrantAccesses($grants = array()) {
// Anonymous user should not be able to access this regular node.
foreach ($grants as $grant) {
$logout = FALSE;
if (!empty($grant['realm']) && $grant['realm'] == 'nodeaccess_rid') {
if (isset($grant['gid']) && $grant['gid'] == DRUPAL_AUTHENTICATED_RID) {
$this
->drupalLogin($this->user);
$logout = TRUE;
}
// Check View Access
$this
->drupalGet("node/{$this->node->nid}");
if (!empty($grant['grant_view']) && $grant['grant_view']) {
$this
->assertResponse(200, 'User is allowed to view the content.');
}
else {
$this
->assertResponse(403, 'User is not allowed to view the content.');
}
// Check Edit Access
$this
->drupalGet("node/{$this->node->nid}/edit");
if (!empty($grant['grant_update']) && $grant['grant_update']) {
$this
->assertResponse(200, 'User is allowed to edit the content.');
}
else {
$this
->assertResponse(403, 'User is not allowed to edit the content.');
}
// Check Delete Access
$this
->drupalGet("node/{$this->node->nid}/delete");
if (!empty($grant['grant_delete']) && $grant['grant_delete']) {
$this
->assertResponse(200, 'User is allowed to delete the content.');
}
else {
$this
->assertResponse(403, 'User is not allowed to delete the content.');
}
if ($logout) {
$this
->drupalLogout();
}
}
}
}