function NodetypeAccessTestCase::testDirectNodeAccess in Nodetype access 7
Ensure that nodes are properly protected when viewed directly.
File
- ./
nodetype_access.test, line 103 - Tests for Nodetype access module.
Class
- NodetypeAccessTestCase
- Tests for Nodetype access module.
Code
function testDirectNodeAccess() {
$article_nid = $this->article->nid;
$page_nid = $this->page->nid;
// Log in as admin user and go to article and page nodes directly. They
// should be allowed.
$this
->drupalLogin($this->admin_user);
$this
->drupalGet("node/{$article_nid}");
$this
->assertResponse(200, 'Direct article access is allowed for admin user.');
$this
->drupalGet("node/{$page_nid}");
$this
->assertResponse(200, 'Direct page access is allowed for admin user.');
// Log in as power user and go to article and page nodes directly. They
// should be allowed to see article, but not page.
$this
->drupalLogin($this->power_user);
$this
->drupalGet("node/{$article_nid}");
$this
->assertResponse(200, 'Direct article access is allowed for power user.');
$this
->drupalGet("node/{$page_nid}");
$this
->assertResponse(403, 'Direct page access is denied for power user.');
// Log in as peon user and go to article and page nodes directly. They
// should not be allowed to see either.
$this
->drupalLogin($this->peon_user);
$this
->drupalGet("node/{$article_nid}");
$this
->assertResponse(403, 'Direct article access is denied for peon user.');
$this
->drupalGet("node/{$page_nid}");
$this
->assertResponse(403, 'Direct page access is denied for peon user.');
}