public function IPBanFunctionalTest::testReadOnlyWithDisabledBlock in IP Ban 7
Same name and namespace in other branches
- 8 ip_ban.test \IPBanFunctionalTest::testReadOnlyWithDisabledBlock()
Test the read-only and complete ban functionality.
File
- ./
ip_ban.test, line 242 - Tests for ip_ban.module.
Class
- IPBanFunctionalTest
- Tests the complete ban and read only functionality of the IP Ban module.
Code
public function testReadOnlyWithDisabledBlock() {
// node/1.
$this
->addBanNode("Read only page");
$this
->drupalGet(IP_BAN_ADMIN_FORM_PATH);
$edit = array(
// Set the United States to Read Only
// 0 = no action / 1 = Read Only / 2 = Complete Ban.
'ip_ban_US' => 1,
// Set the test IP address to a known Google US address.
'ip_ban_test_ip' => '66.249.84.22',
// Configure the path for read-only.
'ip_ban_readonly_path' => 'node/1',
// Disable user login and powered by Drupal blocks for read-only users.
// These blocks are set by default to the left sidebar and footer for
// fresh installs, so no need to configure below.
'ip_ban_disabled_blocks' => 'system,powered-by' . PHP_EOL . 'user,login',
);
$this
->drupalPost(IP_BAN_ADMIN_FORM_PATH, $edit, t('Save configuration'));
$this
->assertOptionSelected('edit-ip-ban-us', 1, 'Read only set correctly in country list table.');
// Set block title to confirm that the interface is available.
// No need to do the following on D7 sites since the user login and powered
// by Drupal are enabled by default.
// $edit = array(
// 'title' => $this->randomName(),
// 'pages' => 'node/1',
// );
// $this->drupalPost('admin/structure/block/manage/search/form/configure', $edit, t('Save block'));
// $this->assertText(t('The block configuration has been saved.'), 'Block configuration set.');
// // Set the block to a region to confirm block is available.
// $edit = array();
// $edit['blocks[search_form][region]'] = 'footer';
// $this->drupalPost('admin/structure/block', $edit, t('Save blocks'));
// $this->assertText(t('The block settings have been updated.'), 'Block successfully move to footer region.');
// Attempt to access user page after logging privileged user out.
$this
->drupalGet('node/1');
global $theme;
$all_regions = system_region_list($theme);
debug($all_regions);
$blocks = block_list('footer');
debug($blocks);
$this
->drupalGet('user/logout');
$this
->drupalGet('user/password');
// Should be redirected to read only page.
$this
->assertUrl('node/1');
// Not sure how to actually test if a block is not visible as I would have
// thought the following would work, but I only see an empty array (even
// when run before the privileged user is logged out).
// $blocks = block_list('footer');
// debug($blocks);
// Note: a simple visual inspection confirms both the user login and powered
// by Drupal blocks are missing when viewing the test results.
}