- public function testisIPAddress() {
- $this->assertFalse( IP::isIPAddress( false ), 'Boolean false is not an IP' );
- $this->assertFalse( IP::isIPAddress( true ), 'Boolean true is not an IP' );
- $this->assertFalse( IP::isIPAddress( "" ), 'Empty string is not an IP' );
- $this->assertFalse( IP::isIPAddress( 'abc' ), 'Garbage IP string' );
- $this->assertFalse( IP::isIPAddress( ':' ), 'Single ":" is not an IP' );
- $this->assertFalse( IP::isIPAddress( '2001:0DB8::A:1::1' ), 'IPv6 with a double :: occurrence' );
- $this->assertFalse(
- IP::isIPAddress( '2001:0DB8::A:1::' ),
- 'IPv6 with a double :: occurrence, last at end'
- );
- $this->assertFalse(
- IP::isIPAddress( '::2001:0DB8::5:1' ),
- 'IPv6 with a double :: occurrence, firt at beginning'
+ public function isNotIPAddress( $val, $desc ) {
+ $this->assertFalse( IP::isIPAddress( $val ), $desc );
+ }
+
+ /**
+ * Provide a list of things that aren't IP addresses
+ */
+ public function provideInvalidIPs() {
+ return array(
+ array( false, 'Boolean false is not an IP' ),
+ array( true, 'Boolean true is not an IP' ),
+ array( '', 'Empty string is not an IP' ),
+ array( 'abc', 'Garbage IP string' ),
+ array( ':', 'Single ":" is not an IP' ),
+ array( '2001:0DB8::A:1::1', 'IPv6 with a double :: occurrence' ),
+ array( '2001:0DB8::A:1::', 'IPv6 with a double :: occurrence, last at end' ),
+ array( '::2001:0DB8::5:1', 'IPv6 with a double :: occurrence, firt at beginning' ),
+ array( '124.24.52', 'IPv4 not enough quads' ),
+ array( '24.324.52.13', 'IPv4 out of range' ),
+ array( '.24.52.13', 'IPv4 starts with period' ),
+ array( 'fc:100:300', 'IPv6 with only 3 words' ),