You are here

public function ProtectedNodeFork::testAlreadyEnteredPassword in Protected Node 7

Same name and namespace in other branches
  1. 1.0.x tests/protected_node.fork.test \ProtectedNodeFork::testAlreadyEnteredPassword()

Test function.

Test that the user it redirected to the node he/she has already entered the password.

File

tests/protected_node.fork.test, line 121
Test protected node fork functionality.

Class

ProtectedNodeFork
Configure protected_node to use per node password.

Code

public function testAlreadyEnteredPassword() {

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

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

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

  // Once the nodes created logout the user.
  $this
    ->drupalLogout();
  $this
    ->drupalLogin($this->normalAccessAllowedUser);

  // Access to the node the first time.
  $form = array(
    'password' => $password,
  );
  $this
    ->drupalPost('protected-nodes', $form, t('OK'), array(
    'query' => array(
      'protected_pages' => $node->nid,
    ),
  ));
  $text = $node->body[LANGUAGE_NONE][0]['value'];
  $this
    ->assertText($text, "User with right permission is redirected to a protected node with right password", $this->group);

  // Access to the node the second time.
  $this
    ->drupalGet('protected-nodes', array(
    'query' => array(
      'protected_pages' => $node->nid,
    ),
  ));
  $this
    ->assertText($text, "User with right permission is redirected to a protected node with right password previously entered", $this->group);
}