You are here

public function ProtectedNodeBulkPassword::testUseGlobalPassword in Protected Node 7

Same name and namespace in other branches
  1. 1.0.x tests/protected_node.bulk.test \ProtectedNodeBulkPassword::testUseGlobalPassword()

Test function.

Test that the node password is erased after using global password.

File

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

Class

ProtectedNodeBulkPassword
Configure protected_node to use mixin password.

Code

public function testUseGlobalPassword() {

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

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

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

  // Use global password.
  $this
    ->drupalPost('admin/config/content/protected_node', array(), t('Use global password on ALL nodes'));

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

  // An authenticated user can't see the node with the node password.
  $this
    ->drupalLogin($this->normalAccessAllowedUser);
  $form = array(
    'password' => $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 the node's password", $this->group);

  // An authenticated user can see the node with global password.
  $this
    ->drupalLogin($this->normalAccessAllowedUser);
  $form = array(
    'password' => $this->global_password,
  );
  $this
    ->drupalPost('node/' . $node->nid, $form, t('OK'));
  $text = $node->body[LANGUAGE_NONE][0]['value'];
  $this
    ->assertText($text, "User with right permission has to enter the global password", $this->group);
}