Updated is_ip comment and added a test for is_ip function
This commit is contained in:
parent
cdc40ca76f
commit
37d4d303b3
@ -1364,10 +1364,8 @@ function getListOfModels($db,$type,$maxfilenamelength=0)
|
||||
/**
|
||||
* This function evaluates a string that should be a valid IPv4
|
||||
*
|
||||
* @param string $ip IP Address
|
||||
* @return It returns 0 if $ip is not a valid IPv4
|
||||
* It returns 1 if $ip is a valid IPv4 and is a public IP
|
||||
* It returns 2 if $ip is a valid IPv4 and is a private lan IP
|
||||
* @param string $ip IP Address
|
||||
* @return int 0 if not valid, 1 if valid and public IP, 2 if valid and private range IP
|
||||
*/
|
||||
function is_ip($ip)
|
||||
{
|
||||
|
||||
@ -154,4 +154,23 @@ class Functions2LibTest extends PHPUnit_Framework_TestCase
|
||||
$this->assertEquals(0,$result);
|
||||
}
|
||||
|
||||
/**
|
||||
* is_ip
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testIsIp() {
|
||||
|
||||
//Test not valid IP
|
||||
$result = is_ip('192.168.1.267');
|
||||
$this->assertEquals(0, $result);
|
||||
|
||||
//Test private range IP
|
||||
$result = is_ip('192.168.1.1');
|
||||
$this->assertEquals(2, $result);
|
||||
|
||||
//Test public range IP
|
||||
$result = is_ip('91.121.33.228');
|
||||
$this->assertEquals(1, $result);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user