summaryrefslogtreecommitdiff
path: root/modules/block/block.test
diff options
context:
space:
mode:
Diffstat (limited to 'modules/block/block.test')
-rw-r--r--modules/block/block.test51
1 files changed, 51 insertions, 0 deletions
diff --git a/modules/block/block.test b/modules/block/block.test
index bb49fb57b..1a52cb23b 100644
--- a/modules/block/block.test
+++ b/modules/block/block.test
@@ -188,6 +188,57 @@ class BlockTestCase extends DrupalWebTestCase {
}
/**
+ * Test user customization of block visibility.
+ */
+ function testBlockVisibilityPerUser() {
+ $block = array();
+
+ // Create a random title for the block.
+ $title = $this->randomName(8);
+
+ // Create our custom test block.
+ $custom_block = array();
+ $custom_block['info'] = $this->randomName(8);
+ $custom_block['title'] = $title;
+ $custom_block['body[value]'] = $this->randomName(32);
+ $this->drupalPost('admin/structure/block/add', $custom_block, t('Save block'));
+
+ $bid = db_query("SELECT bid FROM {block_custom} WHERE info = :info", array(':info' => $custom_block['info']))->fetchField();
+ $block['module'] = 'block';
+ $block['delta'] = $bid;
+ $block['title'] = $title;
+
+ // Move block to the first sidebar.
+ $this->moveBlockToRegion($block, $this->regions[1]);
+
+ // Set the block to be customizable per user, visible by default.
+ $edit = array();
+ $edit['custom'] = BLOCK_CUSTOM_ENABLED;
+ $this->drupalPost('admin/structure/block/manage/' . $block['module'] . '/' . $block['delta'] . '/configure', $edit, t('Save block'));
+
+ // Disable block visibility for the admin user.
+ $edit = array();
+ $edit['block[' . $block['module'] . '][' . $block['delta'] . ']'] = FALSE;
+ $this->drupalPost('user/' . $this->admin_user->uid . '/edit', $edit, t('Save'));
+
+ $this->drupalGet('');
+ $this->assertNoText($block['title'], t('Block was not displayed according to per user block visibility setting.'));
+
+ // Set the block to be customizable per user, hidden by default.
+ $edit = array();
+ $edit['custom'] = BLOCK_CUSTOM_DISABLED;
+ $this->drupalPost('admin/structure/block/manage/' . $block['module'] . '/' . $block['delta'] . '/configure', $edit, t('Save block'));
+
+ // Enable block visibility for the admin user.
+ $edit = array();
+ $edit['block[' . $block['module'] . '][' . $block['delta'] . ']'] = TRUE;
+ $this->drupalPost('user/' . $this->admin_user->uid . '/edit', $edit, t('Save'));
+
+ $this->drupalGet('');
+ $this->assertText($block['title'], t('Block was displayed according to per user block visibility setting.'));
+ }
+
+ /**
* Test configuring and moving a module-define block to specific regions.
*/
function testBlock() {