r79118 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r79117‎ | r79118 | r79119 >
Date:18:23, 28 December 2010
Author:demon
Status:resolved (Comments)
Tags:
Comment:
Add @covers annotations to IP tests
Modified paths:
  • /trunk/phase3/tests/phpunit/includes/IPTest.php (modified) (history)

Diff [purge]

Index: trunk/phase3/tests/phpunit/includes/IPTest.php
@@ -4,7 +4,10 @@
55 */
66
77 class IPTest extends MediaWikiTestCase {
8 - // not sure it should be tested with boolean false. hashar 20100924
 8+ /**
 9+ * not sure it should be tested with boolean false. hashar 20100924
 10+ * @covers IP:isIPAddress()
 11+ */
912 public function testisIPAddress() {
1013 $this->assertFalse( IP::isIPAddress( false ), 'Boolean false is not an IP' );
1114 $this->assertFalse( IP::isIPAddress( true ), 'Boolean true is not an IP' );
@@ -32,6 +35,9 @@
3336 }
3437 }
3538
 39+ /**
 40+ * @covers IP::isIPv6()
 41+ */
3642 public function testisIPv6() {
3743 $this->assertFalse( IP::isIPv6( ':fc:100::' ), 'IPv6 starting with lone ":"' );
3844 $this->assertFalse( IP::isIPv6( 'fc:100:::' ), 'IPv6 ending with a ":::"' );
@@ -75,6 +81,9 @@
7682 $this->assertTrue( IP::isIPv6( 'fc:100:a:d:1:e:ac:0' ) );
7783 }
7884
 85+ /**
 86+ * @covers IP::isIPv4()
 87+ */
7988 public function testisIPv4() {
8089 $this->assertFalse( IP::isIPv4( false ), 'Boolean false is not an IP' );
8190 $this->assertFalse( IP::isIPv4( true ), 'Boolean true is not an IP' );
@@ -90,7 +99,9 @@
91100 $this->assertTrue( IP::isIPv4( '74.24.52.13/20', 'IPv4 range' ) );
92101 }
93102
94 - // tests isValid()
 103+ /**
 104+ * @covers IP::isValid()
 105+ */
95106 public function testValidIPs() {
96107 foreach ( range( 0, 255 ) as $i ) {
97108 $a = sprintf( "%03d", $i );
@@ -112,7 +123,9 @@
113124 }
114125 }
115126
116 - // tests isValid()
 127+ /**
 128+ * @covers IP::isValid()
 129+ */
117130 public function testInvalidIPs() {
118131 // Out of range...
119132 foreach ( range( 256, 999 ) as $i ) {
@@ -160,7 +173,9 @@
161174 }
162175 }
163176
164 - // tests isValidBlock()
 177+ /**
 178+ * @covers IP::isValidBlock()
 179+ */
165180 public function testValidBlocks() {
166181 $valid = array(
167182 '116.17.184.5/32',
@@ -181,7 +196,9 @@
182197 }
183198 }
184199
185 - // tests isValidBlock()
 200+ /**
 201+ * @covers IP::isValidBlock()
 202+ */
186203 public function testInvalidBlocks() {
187204 $invalid = array(
188205 '116.17.184.5/33',
@@ -202,7 +219,10 @@
203220 }
204221 }
205222
206 - // test wrapper around ip2long which might return -1 or false depending on PHP version
 223+ /**
 224+ * test wrapper around ip2long which might return -1 or false depending on PHP version
 225+ * @covers IP::toUnsigned()
 226+ */
207227 public function testip2longWrapper() {
208228 // fixme : add more tests ?
209229 $this->assertEquals( pow(2,32) - 1, IP::toUnsigned( '255.255.255.255' ));
@@ -210,7 +230,9 @@
211231 $this->assertFalse( IP::toUnSigned( $i ) );
212232 }
213233
214 - // tests isPublic()
 234+ /**
 235+ * @covers IP::isPublic()
 236+ */
215237 public function testPrivateIPs() {
216238 $private = array( 'fc::3', 'fc::ff', '::1', '10.0.0.1', '172.16.0.1', '192.168.0.1' );
217239 foreach ( $private as $p ) {
@@ -230,6 +252,9 @@
231253 $this->assertEquals( $expected, long2ip( $parse[0] ), "network shifting $CIDR" );
232254 }
233255
 256+ /**
 257+ * @covers IP::hexToQuad()
 258+ */
234259 public function testHexToQuad() {
235260 $this->assertEquals( '0.0.0.1' , IP::hexToQuad( '00000001' ) );
236261 $this->assertEquals( '255.0.0.0' , IP::hexToQuad( 'FF000000' ) );
@@ -242,6 +267,9 @@
243268 $this->assertEquals( '0.0.255.0' , IP::hexToQuad( 'FF00' ) );
244269 }
245270
 271+ /**
 272+ * @covers IP::hexToOctet()
 273+ */
246274 public function testHexToOctet() {
247275 $this->assertEquals( '0:0:0:0:0:0:0:1',
248276 IP::hexToOctet( '00000000000000000000000000000001' ) );
@@ -265,6 +293,7 @@
266294 /*
267295 * IP::parseCIDR() returns an array containing a signed IP address
268296 * representing the network mask and the bit mask.
 297+ * @covers IP::parseCIDR()
269298 */
270299 function testCIDRParsing() {
271300 $this->assertFalseCIDR( '192.0.2.0' , "missing mask" );

Follow-up revisions

RevisionCommit summaryAuthorDate
r79164-Set configuration automatically if not set. This allows for evasion of the m...soxred9305:38, 29 December 2010
r83389PHPUnit coverage comment must not have parentheses...hashar17:36, 6 March 2011

Comments

#Comment by 😂 (talk | contribs)   22:49, 7 January 2011

Was reverted in r79164.

#Comment by Hashar (talk | contribs)   17:38, 6 March 2011

Issue solved with r83389

Status & tagging log