From 11ab1a0846fef9ef83cb18939eac764a01997686 Mon Sep 17 00:00:00 2001
From: Florent Torregrosa <florent.torregrosa@gmail.com>
Date: Tue, 7 Jul 2015 09:36:49 +0200
Subject: [PATCH] Issue #2277045 by Grimreaper: Add test for "protect nodes"
 action.

---
 tests/protected_node.bulk.test | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/tests/protected_node.bulk.test b/tests/protected_node.bulk.test
index 7aeabf8..fefca2c 100644
--- a/tests/protected_node.bulk.test
+++ b/tests/protected_node.bulk.test
@@ -144,6 +144,39 @@ class ProtectedNodeBulkPassword extends ProtectedNodeBaseTestCase {
   /**
    * Test function.
    *
+   * Test that a node is protected after using the bulk action to protect nodes.
+   */
+  public function testProtectNodes() {
+    // Log in as Admin.
+    $this->drupalLogin($this->adminUser);
+    // Create a new page node.
+    $node = $this->drupalCreateNode();
+    // Once the node created logout the user.
+    $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 see an unprotected node", $this->group);
+
+    // Protect the node.
+    $this->drupalLogin($this->adminUser);
+    $this->drupalPost('admin/config/content/protected_node', array(), t('Protect ALL nodes'));
+    $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 to see a protected node", $this->group);
+  }
+
+  /**
+   * Test function.
+   *
    * Test that the password has to be entered after restoring protection.
    */
   public function testRestoreProtection() {
-- 
2.1.4

