function IPAddressBlockingTestCase::testDuplicateIpAddress in Drupal 7
Test duplicate IP addresses are not present in the 'blocked_ips' table.
File
- modules/
system/ system.test, line 777 - Tests for system.module.
Class
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);
}