diff options
author | Aaron <aschulz@wikimedia.org> | 2012-05-11 10:53:14 -0700 |
---|---|---|
committer | Aaron <aschulz@wikimedia.org> | 2012-05-11 10:53:14 -0700 |
commit | 456177bdee4fb7690773ef1aa995bb9737573d1b (patch) | |
tree | ce4fe14b026136b5fc20c20b3dd7e0fa6ae783c6 /tests/phpunit/includes/IPTest.php | |
parent | 05e656af5b8f7740ad99889998978e7d3144df94 (diff) | |
download | mediawikicore-456177bdee4fb7690773ef1aa995bb9737573d1b.tar.gz mediawikicore-456177bdee4fb7690773ef1aa995bb9737573d1b.zip |
[IP] Added an IP::prettifyIP() function for displaying IPs.
Change-Id: I53b3fe70bd0091ef02740f2b8950c36a0e4cf32e
Diffstat (limited to 'tests/phpunit/includes/IPTest.php')
-rw-r--r-- | tests/phpunit/includes/IPTest.php | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/phpunit/includes/IPTest.php b/tests/phpunit/includes/IPTest.php index e38fa7e43cad..f50b2fe9beb2 100644 --- a/tests/phpunit/includes/IPTest.php +++ b/tests/phpunit/includes/IPTest.php @@ -1,6 +1,7 @@ <?php /** * Tests for IP validity functions. Ported from /t/inc/IP.t by avar. + * @group IP */ class IPTest extends MediaWikiTestCase { @@ -505,4 +506,37 @@ class IPTest extends MediaWikiTestCase { array( '0:c1:A2:3:4:5:c6:7', '0:C1:A2:3:4:5:C6:7', 'IPv6 non range' ), ); } + + /** + * Test for IP::prettifyIP() + * @dataProvider provideIPsToPrettify + */ + function testPrettifyIP( $ip, $prettified ) { + $this->assertEquals( $prettified, IP::prettifyIP( $ip ), "Prettify of $ip" ); + } + + /** + * Provider for IP::testPrettifyIP() + */ + function provideIPsToPrettify() { + return array( + array( '0:0:0:0:0:0:0:0', '::' ), + array( '0:0:0::0:0:0', '::' ), + array( '0:0:0:1:0:0:0:0', '0:0:0:1::' ), + array( '0:0::f', '::f' ), + array( '0::0:0:0:33:fef:b', '::33:fef:b' ), + array( '3f:535:0:0:0:0:e:fbb', '3f:535::e:fbb' ), + array( '0:0:fef:0:0:0:e:fbb', '0:0:fef::e:fbb' ), + array( 'abbc:2004::0:0:0:0', 'abbc:2004::' ), + array( 'cebc:2004:f:0:0:0:0:0', 'cebc:2004:f::' ), + array( '0:0:0:0:0:0:0:0/16', '::/16' ), + array( '0:0:0::0:0:0/64', '::/64' ), + array( '0:0::f/52', '::f/52' ), + array( '::0:0:33:fef:b/52', '::33:fef:b/52' ), + array( '3f:535:0:0:0:0:e:fbb/48', '3f:535::e:fbb/48' ), + array( '0:0:fef:0:0:0:e:fbb/96', '0:0:fef::e:fbb/96' ), + array( 'abbc:2004:0:0::0:0/40', 'abbc:2004::/40' ), + array( 'aebc:2004:f:0:0:0:0:0/80', 'aebc:2004:f::/80' ), + ); + } } |