You are here

public function ProtectedNodePerNodePassword::testAllowedViewWrongPassword in Protected Node 7

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

Test function.

Test that a node protected with per node protection can't be seen with the wrong password.

File

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

Class

ProtectedNodePerNodePassword
Configure protected_node to use per node password.

Code

public function testAllowedViewWrongPassword() {

  // 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();

  // An authenticated user does not see the node.
  $this
    ->drupalLogin($this->normalAccessAllowedUser);
  $another_password = $this
    ->randomName(12);
  $form = array(
    'password' => $another_password,
  );
  $this
    ->drupalPost('node/' . $node->nid, $form, t('OK'));
  $text = $node->body[LANGUAGE_NONE][0]['value'];
  $this
    ->assertNoText($text, "User with right permission can't access a protected node with wrong password", $this->group);
}