Index: trunk/phase3/maintenance/tests/phpunit/includes/IPTest.php |
— | — | @@ -9,8 +9,8 @@ |
10 | 10 | $this->assertFalse( IP::isIPAddress( false ), 'Boolean false is not an IP' ); |
11 | 11 | $this->assertFalse( IP::isIPAddress( true ), 'Boolean true is not an IP' ); |
12 | 12 | $this->assertFalse( IP::isIPAddress( "" ), 'Empty string is not an IP' ); |
13 | | - $this->assertFalse( IP::isIPAddress( 'abc' ) ); |
14 | | - $this->assertFalse( IP::isIPAddress( ':' ) ); |
| 13 | + $this->assertFalse( IP::isIPAddress( 'abc' ), 'Garbage IP string' ); |
| 14 | + $this->assertFalse( IP::isIPAddress( ':' ), 'Single ":" is not an IP' ); |
15 | 15 | $this->assertFalse( IP::isIPAddress( '2001:0DB8::A:1::1'), 'IPv6 with a double :: occurence' ); |
16 | 16 | $this->assertFalse( IP::isIPAddress( '2001:0DB8::A:1::'), 'IPv6 with a double :: occurence, last at end' ); |
17 | 17 | $this->assertFalse( IP::isIPAddress( '::2001:0DB8::5:1'), 'IPv6 with a double :: occurence, firt at beginning' ); |
— | — | @@ -18,20 +18,17 @@ |
19 | 19 | $this->assertFalse( IP::isIPAddress( '24.324.52.13' ), 'IPv4 out of range' ); |
20 | 20 | $this->assertFalse( IP::isIPAddress( '.24.52.13' ), 'IPv4 starts with period' ); |
21 | 21 | |
22 | | - $this->assertTrue( IP::isIPAddress( 'fc:100::' ) ); |
23 | | - $this->assertTrue( IP::isIPAddress( 'fc:100:a:d:1:e:ac::' ) ); |
24 | | - $this->assertTrue( IP::isIPAddress( '::' ), 'RFC 4291 IPv6 Unspecified Address' ); |
| 22 | + $this->assertTrue( IP::isIPAddress( '::' ), 'RFC 4291 IPv6 Unspecified Address' ); |
25 | 23 | $this->assertTrue( IP::isIPAddress( '::1' ), 'RFC 4291 IPv6 Loopback Address' ); |
26 | | - $this->assertTrue( IP::isIPAddress( '::fc' ) ); |
27 | | - $this->assertTrue( IP::isIPAddress( '::fc:100:a:d:1:e:ac' ) ); |
28 | | - $this->assertTrue( IP::isIPAddress( 'fc::100' ) ); |
29 | | - $this->assertTrue( IP::isIPAddress( 'fc::100:a:d:1:e:ac' ) ); |
30 | | - $this->assertTrue( IP::isIPAddress( 'fc::100:a:d:1:e:ac/96', 'IPv6 range with "::"' ) ); |
31 | | - $this->assertTrue( IP::isIPAddress( 'fc:100:a:d:1:e:ac:0' ) ); |
32 | | - $this->assertTrue( IP::isIPAddress( 'fc:100:a:d:1:e:ac:0/24', 'IPv6 range' ) ); |
33 | | - $this->assertTrue( IP::isIPAddress( '124.24.52.13' ) ); |
34 | | - $this->assertTrue( IP::isIPAddress( '1.24.52.13' ) ); |
35 | 24 | $this->assertTrue( IP::isIPAddress( '74.24.52.13/20', 'IPv4 range' ) ); |
| 25 | + $this->assertTrue( IP::isIPAddress( 'fc:100:a:d:1:e:ac:0/24' ), 'IPv6 range' ); |
| 26 | + $this->assertTrue( IP::isIPAddress( 'fc::100:a:d:1:e:ac/96' ), 'IPv6 range with "::"' ); |
| 27 | + |
| 28 | + $validIPs = array( 'fc:100::', 'fc:100:a:d:1:e:ac::', 'fc::100', '::fc:100:a:d:1:e:ac', |
| 29 | + '::fc', 'fc::100:a:d:1:e:ac', 'fc:100:a:d:1:e:ac:0', '124.24.52.13', '1.24.52.13' ); |
| 30 | + foreach ( $validIPs as $ip ) { |
| 31 | + $this->assertTrue( IP::isIPAddress( $ip ), "$ip is a valid IP address" ); |
| 32 | + } |
36 | 33 | } |
37 | 34 | |
38 | 35 | public function testisIPv6() { |