You are here

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

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

Test function.

Test that a node is unprotected after using the bulk action to remove protection.

File

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

Class

ProtectedNodeBulkPassword
Configure protected_node to use mixin password.

Code

public function testRemoveProtection() {

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

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

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

  // An authenticated user can't see the node without password.
  $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);

  // Log in as Admin to remove protection.
  $this
    ->drupalLogin($this->adminUser);
  $this
    ->drupalPost('admin/config/content/protected_node', array(), t('Remove password protection from all nodes'));
  $this
    ->drupalLogout();

  // An authenticated user can see the node without password.
  $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);
}