You are here

public static function BlockedIpsExpireTestCase::generateIpAddress in Blocked IPs Expire 7

Generate a random IP address.

Currently this only generates IPv4 addresses, i.e.: a string in the form 'a.b.c.d', where a, b, c, and d are integers between 0 and 255.

Return value

string A string containing an IP address.

1 call to BlockedIpsExpireTestCase::generateIpAddress()
BlockedIpsExpireUi::testSystemBlockedIpFormHasExpiryDate in tests/blocked_ips_expire.ui.test
Test that the module modified the blocked IPs entry form as expected.

File

tests/blocked_ips_expire.base.test, line 102
Contains \BlockedIpsExpireTestCase.

Class

BlockedIpsExpireTestCase
An object containing test functions common to all tests for this module.

Code

public static function generateIpAddress() {
  $components = array();
  for ($i = 0; $i < 4; $i++) {
    $components[] = (string) rand(0, 255);
  }
  return implode('.', $components);
}