function IPAddressBlockingTestCase::testDuplicateIpAddress

Test duplicate IP addresses are not present in the 'blocked_ips' table.

File

modules/system/system.test, line 777

Class

IPAddressBlockingTestCase

Code

function testDuplicateIpAddress() {
    drupal_static_reset('ip_address');
    $submit_ip = $_SERVER['REMOTE_ADDR'] = '192.168.1.1';
    system_block_ip_action();
    system_block_ip_action();
    $ip_count = db_query("SELECT COUNT(*) from {blocked_ips} WHERE ip = :ip", array(
        ':ip' => $submit_ip,
    ))->fetchColumn();
    $this->assertEqual('1', $ip_count);
    drupal_static_reset('ip_address');
    $submit_ip = $_SERVER['REMOTE_ADDR'] = ' ';
    system_block_ip_action();
    system_block_ip_action();
    system_block_ip_action();
    $ip_count = db_query("SELECT COUNT(*) from {blocked_ips} WHERE ip = :ip", array(
        ':ip' => $submit_ip,
    ))->fetchColumn();
    $this->assertEqual('1', $ip_count);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.