You are here

public function ProtectedNodeBulkPassword::testRestoreProtection in Protected Node 1.0.x

Same name and namespace in other branches
  1. 7 tests/protected_node.bulk.test \ProtectedNodeBulkPassword::testRestoreProtection()

Test function.

Test that the password has to be entered after restoring protection.

File

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

Class

ProtectedNodeBulkPassword
Configure protected_node to use mixin password.

Code

public function testRestoreProtection() {

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

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

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

  // Remove protection.
  $this
    ->drupalPost('admin/config/content/protected_node', array(), t('Remove password protection from all nodes'));

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

  // An authenticated user sees the node.
  $this
    ->drupalLogin($this->normalAccessAllowedUser);
  $this
    ->drupalGet('node/' . $node->nid);
  $text = $node->body[LANGUAGE_NONE][0]['value'];
  $this
    ->assertText($text, "User with right permission can access an unprotected node", $this->group);

  // Log in as Admin to clear sessions.
  $this
    ->drupalLogin($this->adminUser);
  $this
    ->drupalPost('admin/config/content/protected_node', array(), t('Protect nodes that already have a password'));
  $this
    ->drupalLogout();

  // An authenticated user has to enter the password to see the node.
  $this
    ->drupalLogin($this->normalAccessAllowedUser);
  $this
    ->drupalGet('node/' . $node->nid);
  $text = 'Protected page -- Enter password';
  $this
    ->assertText($text, "User with right permission has to enter the password", $this->group);
}