_validator = new Zend_Validate_Ip(); } /** * Ensures that the validator follows expected behavior * * @return void */ public function testBasic() { $this->assertTrue($this->_validator->isValid('1.2.3.4')); $this->assertTrue($this->_validator->isValid('10.0.0.1')); $this->assertTrue($this->_validator->isValid('255.255.255.255')); $this->assertFalse($this->_validator->isValid('0.0.0.256')); $this->assertFalse($this->_validator->isValid('1.2.3.4.5')); } public function testZeroIpForZF2420() { $this->assertTrue($this->_validator->isValid('0.0.0.0')); } /** * Ensures that getMessages() returns expected default value * * @return void */ public function testGetMessages() { $this->assertEquals(array(), $this->_validator->getMessages()); } public function testInvalidIpForZF4809() { $this->assertFalse($this->_validator->isValid('1.2.333')); } public function testInvalidIpForZF3435() { $this->assertFalse($this->_validator->isValid('192.168.0.2 adfs')); } /** * @see ZF-2694 */ public function testIPv6addresses() { if (!function_exists('inet_pton')) { $this->markTestIncomplete('No IPv6 support within this PHP release'); } $this->assertTrue($this->_validator->isValid('::127.0.0.1')); } /** * @ZF-4352 */ public function testNonStringValidation() { $this->assertFalse($this->_validator->isValid(array(1 => 1))); } }