Add @covers annotations to IP tests
authorChad Horohoe <demon@users.mediawiki.org>
Tue, 28 Dec 2010 18:23:43 +0000 (18:23 +0000)
committerChad Horohoe <demon@users.mediawiki.org>
Tue, 28 Dec 2010 18:23:43 +0000 (18:23 +0000)
tests/phpunit/includes/IPTest.php

index 3655e51..f811bf1 100644 (file)
@@ -4,7 +4,10 @@
  */
 
 class IPTest extends MediaWikiTestCase {
-       // not sure it should be tested with boolean false. hashar 20100924
+       /**
+        *  not sure it should be tested with boolean false. hashar 20100924
+        * @covers IP:isIPAddress()
+        */
        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' );
@@ -32,6 +35,9 @@ class IPTest extends MediaWikiTestCase {
                }
        }
 
+       /**
+        * @covers IP::isIPv6()
+        */
        public function testisIPv6() {
                $this->assertFalse( IP::isIPv6( ':fc:100::' ), 'IPv6 starting with lone ":"' );
                $this->assertFalse( IP::isIPv6( 'fc:100:::' ), 'IPv6 ending with a ":::"' );
@@ -75,6 +81,9 @@ class IPTest extends MediaWikiTestCase {
                $this->assertTrue( IP::isIPv6( 'fc:100:a:d:1:e:ac:0' ) );
        }
 
+       /**
+        * @covers IP::isIPv4()
+        */
        public function testisIPv4() {
                $this->assertFalse( IP::isIPv4( false ), 'Boolean false is not an IP' );
                $this->assertFalse( IP::isIPv4( true  ), 'Boolean true is not an IP' );
@@ -90,7 +99,9 @@ class IPTest extends MediaWikiTestCase {
                $this->assertTrue( IP::isIPv4( '74.24.52.13/20', 'IPv4 range' ) );
        }
 
-       // tests isValid()
+       /**
+        * @covers IP::isValid()
+        */
        public function testValidIPs() {
                foreach ( range( 0, 255 ) as $i ) {
                        $a = sprintf( "%03d", $i );
@@ -112,7 +123,9 @@ class IPTest extends MediaWikiTestCase {
                }
        }
 
-       // tests isValid()
+       /**
+        * @covers IP::isValid()
+        */
        public function testInvalidIPs() {
                // Out of range...
                foreach ( range( 256, 999 ) as $i ) {
@@ -160,7 +173,9 @@ class IPTest extends MediaWikiTestCase {
                }
        }
 
-       // tests isValidBlock()
+       /**
+        * @covers IP::isValidBlock()
+        */
        public function testValidBlocks() {
                $valid = array(
                        '116.17.184.5/32',
@@ -181,7 +196,9 @@ class IPTest extends MediaWikiTestCase {
                }
        }
 
-       // tests isValidBlock()
+       /**
+        * @covers IP::isValidBlock()
+        */
        public function testInvalidBlocks() {
                $invalid = array(
                        '116.17.184.5/33',
@@ -202,7 +219,10 @@ class IPTest extends MediaWikiTestCase {
                }
        }
 
-       // test wrapper around ip2long which might return -1 or false depending on PHP version
+       /**
+        * test wrapper around ip2long which might return -1 or false depending on PHP version
+        * @covers IP::toUnsigned()
+        */
        public function testip2longWrapper() {
                // fixme : add more tests ?
                $this->assertEquals( pow(2,32) - 1, IP::toUnsigned( '255.255.255.255' ));
@@ -210,7 +230,9 @@ class IPTest extends MediaWikiTestCase {
                $this->assertFalse( IP::toUnSigned( $i ) );
        }
 
-       // tests isPublic()
+       /**
+        * @covers IP::isPublic()
+        */
        public function testPrivateIPs() {
                $private = array( 'fc::3', 'fc::ff', '::1', '10.0.0.1', '172.16.0.1', '192.168.0.1' );
                foreach ( $private as $p ) {
@@ -230,6 +252,9 @@ class IPTest extends MediaWikiTestCase {
                $this->assertEquals( $expected, long2ip( $parse[0] ), "network shifting $CIDR" );
        }
 
+       /**
+        * @covers IP::hexToQuad()
+        */
        public function testHexToQuad() {
                $this->assertEquals( '0.0.0.1'        , IP::hexToQuad( '00000001' ) );
                $this->assertEquals( '255.0.0.0'      , IP::hexToQuad( 'FF000000' ) );
@@ -242,6 +267,9 @@ class IPTest extends MediaWikiTestCase {
                $this->assertEquals( '0.0.255.0'   , IP::hexToQuad( 'FF00' ) );
        }
 
+       /**
+        * @covers IP::hexToOctet()
+        */
        public function testHexToOctet() {
                $this->assertEquals( '0:0:0:0:0:0:0:1',
                        IP::hexToOctet( '00000000000000000000000000000001' ) );
@@ -265,6 +293,7 @@ class IPTest extends MediaWikiTestCase {
        /*
         * IP::parseCIDR() returns an array containing a signed IP address
         * representing the network mask and the bit mask.
+        * @covers IP::parseCIDR()
         */
        function testCIDRParsing() {
                $this->assertFalseCIDR( '192.0.2.0' , "missing mask"    );