public function IPBanFunctionalTest::testCompleteBan in IP Ban 8
Same name in this branch
- 8 ip_ban.test \IPBanFunctionalTest::testCompleteBan()
- 8 src/Tests/IPBanFunctionalTest.php \Drupal\ip_ban\Tests\IPBanFunctionalTest::testCompleteBan()
Same name and namespace in other branches
- 7 ip_ban.test \IPBanFunctionalTest::testCompleteBan()
Test the complete ban functionality.
File
- ./
ip_ban.test, line 217 - Tests for ip_ban.module.
Class
- IPBanFunctionalTest
- Tests the complete ban and read only functionality of the IP Ban module.
Code
public function testCompleteBan() {
// node/1.
$this
->addBanNode("Read only page");
// node/2.
$this
->addBanNode("Complete ban 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' => 2,
// Set the test IP address to a known Google US address.
'ip_ban_test_ip' => '66.249.84.22',
// Configure the paths for read-only and complete ban.
// Todo: use $node = $this->drupalGetNodeByTitle($node_title) to get nids.
'ip_ban_readonly_path' => 'node/1',
'ip_ban_completeban_path' => 'node/2',
);
$this
->drupalPost(IP_BAN_ADMIN_FORM_PATH, $edit, t('Save configuration'));
$this
->assertOptionSelected('edit-ip-ban-us', 2, 'Complete ban set correctly in country list table.');
// Attempt to access read only page after logging privileged user out.
$this
->drupalGet('user/logout');
$this
->drupalGet('node/1');
// Should be redirected to complete ban page.
$this
->assertUrl('node/2');
}