r83389 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r83388‎ | r83389 | r83390 >
Date:17:36, 6 March 2011
Author:hashar
Status:ok
Tags:
Comment:
PHPUnit coverage comment must not have parentheses

Those comments have the format:
@covers Class::Method

In PHPUnit 3.5.12, the comment is split by :: and method_exist called on
the resulting string. When one use Class::Method(), the result is a call
to method_exist( 'Method()' ) which is always false and raise an exception

Removing parentheses from r79118 solve the issue. This also kind of
revert r79164.
Modified paths:
  • /trunk/phase3/tests/phpunit/includes/IPTest.php (modified) (history)

Diff [purge]

Index: trunk/phase3/tests/phpunit/includes/IPTest.php
@@ -6,6 +6,7 @@
77 class IPTest extends MediaWikiTestCase {
88 /**
99 * not sure it should be tested with boolean false. hashar 20100924
 10+ * @covers IP::isIPAddress
1011 */
1112 public function testisIPAddress() {
1213 $this->assertFalse( IP::isIPAddress( false ), 'Boolean false is not an IP' );
@@ -34,6 +35,9 @@
3536 }
3637 }
3738
 39+ /**
 40+ * @covers IP::isIPv6
 41+ */
3842 public function testisIPv6() {
3943 $this->assertFalse( IP::isIPv6( ':fc:100::' ), 'IPv6 starting with lone ":"' );
4044 $this->assertFalse( IP::isIPv6( 'fc:100:::' ), 'IPv6 ending with a ":::"' );
@@ -86,6 +90,9 @@
8791 $this->assertTrue( IP::isIPv6( 'fc:100:a:d:1:e:ac:0' ) );
8892 }
8993
 94+ /**
 95+ * @covers IP::isIPv4
 96+ */
9097 public function testisIPv4() {
9198 $this->assertFalse( IP::isIPv4( false ), 'Boolean false is not an IP' );
9299 $this->assertFalse( IP::isIPv4( true ), 'Boolean true is not an IP' );
@@ -101,6 +108,9 @@
102109 $this->assertTrue( IP::isIPv4( '74.24.52.13/20', 'IPv4 range' ) );
103110 }
104111
 112+ /**
 113+ * @covers IP::isValid
 114+ */
105115 public function testValidIPs() {
106116 foreach ( range( 0, 255 ) as $i ) {
107117 $a = sprintf( "%03d", $i );
@@ -142,6 +152,9 @@
143153 $this->assertFalse( IP::isValid( 'fc:100:a:d:1:e:ac:0:1::' ), 'IPv6 with 9 words ending with "::"' );
144154 }
145155
 156+ /**
 157+ * @covers IP::isValid
 158+ */
146159 public function testInvalidIPs() {
147160 // Out of range...
148161 foreach ( range( 256, 999 ) as $i ) {
@@ -189,6 +202,9 @@
190203 }
191204 }
192205
 206+ /**
 207+ * @covers IP::isValidBlock
 208+ */
193209 public function testValidBlocks() {
194210 $valid = array(
195211 '116.17.184.5/32',
@@ -209,6 +225,9 @@
210226 }
211227 }
212228
 229+ /**
 230+ * @covers IP::isValidBlock
 231+ */
213232 public function testInvalidBlocks() {
214233 $invalid = array(
215234 '116.17.184.5/33',
@@ -240,6 +259,7 @@
241260
242261 /**
243262 * test wrapper around ip2long which might return -1 or false depending on PHP version
 263+ * @covers IP::toUnsigned
244264 */
245265 public function testip2longWrapper() {
246266 // fixme : add more tests ?
@@ -248,6 +268,9 @@
249269 $this->assertFalse( IP::toUnSigned( $i ) );
250270 }
251271
 272+ /**
 273+ * @covers IP::isPublic
 274+ */
252275 public function testPrivateIPs() {
253276 $private = array( 'fc::3', 'fc::ff', '::1', '10.0.0.1', '172.16.0.1', '192.168.0.1' );
254277 foreach ( $private as $p ) {
@@ -267,6 +290,9 @@
268291 $this->assertEquals( $expected, long2ip( $parse[0] ), "network shifting $CIDR" );
269292 }
270293
 294+ /**
 295+ * @covers IP::hexToQuad
 296+ */
271297 public function testHexToQuad() {
272298 $this->assertEquals( '0.0.0.1' , IP::hexToQuad( '00000001' ) );
273299 $this->assertEquals( '255.0.0.0' , IP::hexToQuad( 'FF000000' ) );
@@ -279,6 +305,9 @@
280306 $this->assertEquals( '0.0.255.0' , IP::hexToQuad( 'FF00' ) );
281307 }
282308
 309+ /**
 310+ * @covers IP::hexToOctet
 311+ */
283312 public function testHexToOctet() {
284313 $this->assertEquals( '0:0:0:0:0:0:0:1',
285314 IP::hexToOctet( '00000000000000000000000000000001' ) );
@@ -302,6 +331,7 @@
303332 /*
304333 * IP::parseCIDR() returns an array containing a signed IP address
305334 * representing the network mask and the bit mask.
 335+ * @covers IP::parseCIDR
306336 */
307337 function testCIDRParsing() {
308338 $this->assertFalseCIDR( '192.0.2.0' , "missing mask" );

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r79118Add @covers annotations to IP testsdemon18:23, 28 December 2010
r79164-Set configuration automatically if not set. This allows for evasion of the m...soxred9305:38, 29 December 2010

Status & tagging log