From c4aba2185d4d9b21b872e1c4efc67c86578fada4 Mon Sep 17 00:00:00 2001
From: Sebastian Lesch <sebastian.lesch@gmail.com>
Date: Fri, 11 Mar 2011 14:55:17 -0600
Subject: [PATCH 1/2] Issue #687686 by sebsebseb123 : Content block hiding on particular pages.

---
 modules/block/block.module |    9 ++++++
 modules/block/block.test   |   59 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 68 insertions(+), 0 deletions(-)

diff --git a/modules/block/block.module b/modules/block/block.module
index dd7bf91..346b3e5 100644
--- a/modules/block/block.module
+++ b/modules/block/block.module
@@ -302,6 +302,15 @@ function block_page_build(&$page) {
       );
     }
   }
+
+  // With the block module, it's possible to disable the main content block.
+  // By default, Drupal gets mad at us if we do that to protect users from
+  // completely locking themselves out of the site by disabling page-managing
+  // modules, but since this is a page-manging module, we're in charge of the
+  // main content, not system module.
+  $system_main_content_added = &drupal_static('system_main_content_added');
+  $system_main_content_added = TRUE;
+
 }
 
 /**
diff --git a/modules/block/block.test b/modules/block/block.test
index d036d36..84ad740 100644
--- a/modules/block/block.test
+++ b/modules/block/block.test
@@ -666,3 +666,62 @@ class BlockHTMLIdTestCase extends DrupalWebTestCase {
     $this->assertRaw('block-block-test-test-html-id', t('HTML id for test block is valid.'));
   }
 }
+
+/**
+ * Test Content block visibilty settings.
+ */
+class ContentBlockTestCase extends DrupalWebTestCase {
+  protected $admin_user;
+
+  public static function getInfo() {
+    return array(
+      'name' => 'Content Block functionality',
+      'description' => '"Content" block should hide on particular pages.',
+      'group' => 'Block',
+    );
+  }
+
+  function setUp() {
+    parent::setUp();
+
+    // Create and log in an administrative user having access to the Full HTML
+    // text format.
+    $this->admin_user = $this->drupalCreateUser(array(
+      'administer blocks',
+      'access administration pages',
+      'create page content',
+    ));
+    $this->drupalLogin($this->admin_user);
+  }
+
+  /**
+   * Test content block visibility.
+   */
+  function testContentBlockVisibility() {
+    $body = $this->randomName(12);
+  
+    $my_settings = array(
+      'type' => 'page',
+      'body' => array(LANGUAGE_NONE => array(array('value' => $body))),
+    );
+    $this->drupalCreateNode($my_settings);
+
+    $settings = array(
+      'type' => 'page',
+      'body' => array(LANGUAGE_NONE => array(array('value' => $body))),
+    );
+    $this->drupalCreateNode($settings);
+
+    // Set the block to be hidden on the first node path that we just created.
+    $edit = array();
+    $edit['pages'] = 'node/1';
+    $this->drupalPost('admin/structure/block/manage/system/main/configure', $edit, t('Save block'));
+
+    $this->drupalGet('node/1');
+    $this->assertNoText($body, t('Content block is properly hiding.'));
+
+    $this->drupalGet('node/2');
+    $this->assertText($body, t('Content block is properly displaying.'));
+  }
+
+}
-- 
1.7.4.msysgit.0


From 118c086932f0369316a30280532b38138f03d673 Mon Sep 17 00:00:00 2001
From: Sebastian Lesch <sebastian.lesch@gmail.com>
Date: Fri, 11 Mar 2011 15:47:36 -0600
Subject: [PATCH 2/2] Issue #687686 by sebsebseb123 : Changed code so that we dont assume nids | Added some comments

---
 modules/block/block.test |   17 +++++++++++------
 1 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/modules/block/block.test b/modules/block/block.test
index 84ad740..1be187e 100644
--- a/modules/block/block.test
+++ b/modules/block/block.test
@@ -700,27 +700,32 @@ class ContentBlockTestCase extends DrupalWebTestCase {
   function testContentBlockVisibility() {
     $body = $this->randomName(12);
   
-    $my_settings = array(
+    // Create 2 nodes with similar body text.
+    $settings = array(
       'type' => 'page',
       'body' => array(LANGUAGE_NONE => array(array('value' => $body))),
     );
-    $this->drupalCreateNode($my_settings);
+    $node = $this->drupalCreateNode($settings);
+    $nid1 = $node->nid;
 
     $settings = array(
       'type' => 'page',
       'body' => array(LANGUAGE_NONE => array(array('value' => $body))),
     );
-    $this->drupalCreateNode($settings);
+    $node = $this->drupalCreateNode($settings);
+    $nid2 = $node->nid;
 
     // Set the block to be hidden on the first node path that we just created.
     $edit = array();
-    $edit['pages'] = 'node/1';
+    $edit['pages'] = 'node/'.$nid1;
     $this->drupalPost('admin/structure/block/manage/system/main/configure', $edit, t('Save block'));
 
-    $this->drupalGet('node/1');
+    // Check that the body text is properly hiding
+    $this->drupalGet('node/'.$nid1);
     $this->assertNoText($body, t('Content block is properly hiding.'));
 
-    $this->drupalGet('node/2');
+    // Check that the body text is properly displaying
+    $this->drupalGet('node/'.$nid2);
     $this->assertText($body, t('Content block is properly displaying.'));
   }
 
-- 
1.7.4.msysgit.0

