public function NodeaccesssPublishTestCase::testUnpublishedView in Nodeaccess 7
Test unpublished node visibility.
File
- tests/
nodeaccess_publish.test, line 119 - Tests for the nodeaccess module.
Class
- NodeaccesssPublishTestCase
- Tests the functionality of the nodeaccess module.
Code
public function testUnpublishedView() {
nodeaccess_set_grants($this->unpublished_node, $this->grant);
// Anonymous users should NOT see the content.
$this
->drupalGet("node/{$this->unpublished_node->nid}");
$this
->assertResponse(403, 'Anonymous user is not allowed to view the unpublished content.');
// Authenticated User, should NOT see content.
$this
->drupalLogin($this->basic_user);
$this
->drupalGet("node/{$this->unpublished_node->nid}");
$this
->assertResponse(403, 'Authenticated user is not allowed to view the unpublished content.');
$this
->drupalLogout();
// Author User, should NOT see the content, not author of this node.
$this
->drupalLogin($this->author_user);
$this
->drupalGet("node/{$this->unpublished_node->nid}");
$this
->assertResponse(403, 'Author user is not allowed to view the unpublished content.');
$this
->drupalLogout();
// Admin User should see content, has administer content permission.
$this
->drupalLogin($this->admin_user);
$this
->drupalGet("node/{$this->unpublished_node->nid}");
$this
->assertResponse(200, 'Admin user is allowed to view the unpublished content (bypass).');
$this
->drupalLogout();
}