You are here

public function ProtectedNodePerNodePassword::testAuthenticatedNonAllowedView in Protected Node 7

Same name and namespace in other branches
  1. 1.0.x tests/protected_node.per_node.test \ProtectedNodePerNodePassword::testAuthenticatedNonAllowedView()

Test function.

Test that a node protected with per node protection can't be seen by an authenticated but not allowed user.

File

tests/protected_node.per_node.test, line 117
Test protected node per node functionality.

Class

ProtectedNodePerNodePassword
Configure protected_node to use per node password.

Code

public function testAuthenticatedNonAllowedView() {

  // Log in as Admin.
  $this
    ->drupalLogin($this->adminUser);

  // Generate random password.
  $password = $this
    ->randomName(10);

  // Create a new page node.
  $node = $this
    ->createProtectedNode($password);

  // Once the node created logout the user.
  $this
    ->drupalLogout();

  // User that can see published content sees the node.
  $this
    ->drupalLogin($this->normalNonAccessAllowedUser);
  $this
    ->drupalGet('node/' . $node->nid);
  $this
    ->assertResponse(403, "User with no access permission is not allowed to access a protected node");
}