r76788 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r76787‎ | r76788 | r76789 >
Date:10:51, 16 November 2010
Author:aaron
Status:deferred
Tags:
Comment:
* Fixed ipv6 range test calls
* Made testisIPAddress test results more readable on failure
Modified paths:
  • /trunk/phase3/maintenance/tests/phpunit/includes/IPTest.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/tests/phpunit/includes/IPTest.php
@@ -9,8 +9,8 @@
1010 $this->assertFalse( IP::isIPAddress( false ), 'Boolean false is not an IP' );
1111 $this->assertFalse( IP::isIPAddress( true ), 'Boolean true is not an IP' );
1212 $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' );
1515 $this->assertFalse( IP::isIPAddress( '2001:0DB8::A:1::1'), 'IPv6 with a double :: occurence' );
1616 $this->assertFalse( IP::isIPAddress( '2001:0DB8::A:1::'), 'IPv6 with a double :: occurence, last at end' );
1717 $this->assertFalse( IP::isIPAddress( '::2001:0DB8::5:1'), 'IPv6 with a double :: occurence, firt at beginning' );
@@ -18,20 +18,17 @@
1919 $this->assertFalse( IP::isIPAddress( '24.324.52.13' ), 'IPv4 out of range' );
2020 $this->assertFalse( IP::isIPAddress( '.24.52.13' ), 'IPv4 starts with period' );
2121
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' );
2523 $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' ) );
3524 $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+ }
3633 }
3734
3835 public function testisIPv6() {

Status & tagging log