You are here

public function NodeaccesssPublishTestCase::testAuthoredView in Nodeaccess 7

Test unpublished node visibility.

File

tests/nodeaccess_publish.test, line 149
Tests for the nodeaccess module.

Class

NodeaccesssPublishTestCase
Tests the functionality of the nodeaccess module.

Code

public function testAuthoredView() {
  nodeaccess_set_grants($this->authored_node, $this->grant);

  // Anonymous users should NOT see the content.
  $this
    ->drupalGet("node/{$this->authored_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->authored_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->authored_node->nid}");
  $this
    ->assertResponse(200, 'Author user is allowed to view their own unpublished content.');
  $this
    ->drupalLogout();

  // Admin User should see content, has administer content permission.
  $this
    ->drupalLogin($this->admin_user);
  $this
    ->drupalGet("node/{$this->authored_node->nid}");
  $this
    ->assertResponse(200, 'Admin user is allowed to view the unpublished content (bypass).');
  $this
    ->drupalLogout();
}