function ContentAccessACLTestCase::testEditAccess in Content Access 7
Same name and namespace in other branches
- 5 tests/content_access_acl.test \ContentAccessACLTestCase::testEditAccess()
- 6 tests/content_access_acl.test \ContentAccessACLTestCase::testEditAccess()
Test Editing accessibility with permissions for single users
File
- tests/
content_access_acl.test, line 97
Class
Code
function testEditAccess() {
// Exit test if ACL module could not be enabled
if (!module_exists('acl')) {
$this
->pass('No ACL module present, skipping test');
return;
}
// Enable per node access control
$this
->changeAccessPerNode();
// Allow edit access for test user
$edit = array(
'acl[update][add]' => $this->test_user->name,
);
$this
->drupalPost('node/' . $this->node->nid . '/access', $edit, t('Add User'));
$this
->drupalPost(NULL, array(), t('Submit'));
// Logout admin, try to edit the node anonymously
$this
->drupalLogout();
$this
->drupalGet('node/' . $this->node->nid . '/edit');
$this
->assertText(t('Access denied'), 'node is not editable');
// Login test user, edit access should be allowed now
$this
->drupalLogin($this->test_user);
$this
->drupalGet('node/' . $this->node->nid . '/edit');
$this
->assertNoText(t('Access denied'), 'node is editable');
// Login admin and disable per node access
$this
->drupalLogin($this->admin_user);
$this
->changeAccessPerNode(FALSE);
// Logout admin, try to edit the node anonymously
$this
->drupalLogout();
$this
->drupalGet('node/' . $this->node->nid . '/edit');
$this
->assertText(t('Access denied'), 'node is not editable');
// Login test user, edit access should be denied now
$this
->drupalLogin($this->test_user);
$this
->drupalGet('node/' . $this->node->nid . '/edit');
$this
->assertText(t('Access denied'), 'node is not editable');
}