r69404 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r69403‎ | r69404 | r69405 >
Date:20:34, 15 July 2010
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Hack to get unit testing working >_>
Modified paths:
  • /trunk/extensions/Maps/Maps.php (modified) (history)
  • /trunk/extensions/Maps/test/MapsCoordinateParserTest.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Maps/test/MapsCoordinateParserTest.php
@@ -2,6 +2,12 @@
33
44 require_once 'PHPUnit\Framework\TestCase.php';
55
 6+// Trick MW into thinking this is a command line script.
 7+// This is obviously not a good approach, as it will not work on other setups then my own.
 8+unset($_SERVER['REQUEST_METHOD']);
 9+$argv = array( 'over9000failz' );
 10+require_once '../../../smw/maintenance/commandLine.inc';
 11+
612 /**
713 * MapsCoordinateParser test case.
814 *
@@ -21,28 +27,28 @@
2228 '-5.5,-37 '
2329 ),
2430 'dd' => array(
25 - '55.7557860� N, 37.6176330� W',
26 - '55.7557860�, -37.6176330�',
27 - '55� S, 37.6176330 � W',
28 - '-55�, -37.6176330 �',
29 - '5.5�S,37�W ',
30 - '-5.5�,-37� '
 31+ '55.7557860° N, 37.6176330° W',
 32+ '55.7557860°, -37.6176330°',
 33+ '55° S, 37.6176330 ° W',
 34+ '-55°, -37.6176330 °',
 35+ '5.5°S,37°W ',
 36+ '-5.5°,-37° '
3137 ),
3238 'dm' => array(
33 - "55� 45.34716' N, 37� 37.05798' W",
34 - "55� 45.34716', -37� 37.05798'",
35 - "55� S, 37� 37.05798'W",
36 - "-55�, 37� -37.05798'",
37 - "55�S, 37�37.05798'W ",
38 - "-55�, 37�-37.05798' "
 39+ "55° 45.34716' N, 37° 37.05798' W",
 40+ "55° 45.34716', -37° 37.05798'",
 41+ "55° S, 37° 37.05798'W",
 42+ "-55°, 37° -37.05798'",
 43+ "55°S, 37°37.05798'W ",
 44+ "-55°, 37°-37.05798' "
3945 ),
4046 'dms' => array(
41 - "55� 45' 21\" N, 37� 37' 3\" W",
42 - "55� 45' 21\" N, -37� 37' 3\"",
43 - "55� 45' S, 37� 37' 3\"W",
44 - "-55�, -37� 37' 3\"",
45 - "55�45'S,37�37'3\"W ",
46 - "-55�,-37�37'3\" "
 47+ "55° 45' 21\" N, 37° 37' 3\" W",
 48+ "55° 45' 21\" N, -37° 37' 3\"",
 49+ "55° 45' S, 37° 37' 3\"W",
 50+ "-55°, -37° 37' 3\"",
 51+ "55°45'S,37°37'3\"W ",
 52+ "-55°,-37°37'3\" "
4753 ),
4854 );
4955
@@ -106,19 +112,19 @@
107113 */
108114 public function testGetCoordinatesType() {
109115 foreach( self::$coordinates['float'] as $coord ) {
110 - $this->assertEquals( MapsCoordinateParser::getCoordinatesType( $coord ), Maps_COORDS_FLOAT );
 116+ $this->assertEquals( Maps_COORDS_FLOAT, MapsCoordinateParser::getCoordinatesType( $coord ), "$coord not recognized as float." );
111117 }
112118
113119 foreach( self::$coordinates['dd'] as $coord ) {
114 - $this->assertEquals( MapsCoordinateParser::getCoordinatesType( $coord ), Maps_COORDS_DD );
 120+ $this->assertEquals( Maps_COORDS_DD, MapsCoordinateParser::getCoordinatesType( $coord ), "$coord not recognized as dd." );
115121 }
116122
117123 foreach( self::$coordinates['dm'] as $coord ) {
118 - $this->assertEquals( MapsCoordinateParser::getCoordinatesType( $coord ), Maps_COORDS_DM );
 124+ $this->assertEquals( Maps_COORDS_DM, MapsCoordinateParser::getCoordinatesType( $coord ), "$coord not recognized as dm." );
119125 }
120126
121127 foreach( self::$coordinates['dms'] as $coord ) {
122 - $this->assertEquals( MapsCoordinateParser::getCoordinatesType( $coord ), Maps_COORDS_DMS );
 128+ $this->assertEquals( Maps_COORDS_DMS, MapsCoordinateParser::getCoordinatesType( $coord ), "$coord not recognized as dms." );
123129 }
124130 }
125131
@@ -126,15 +132,16 @@
127133 * Tests MapsCoordinateParser::areCoordinates()
128134 */
129135 public function testAreCoordinates() {
130 - foreach( self::$coordinates as $type ) {
131 - foreach( self::$coordinates[$type] as $coord ) {
132 - $this->assertTrue( MapsCoordinateParser::areCoordinates( $coord ) );
 136+ foreach( self::$coordinates as $coordsOfType ) {
 137+ foreach( $coordsOfType as $coord ) {
 138+ $this->assertTrue( MapsCoordinateParser::areCoordinates( $coord ), "$coord not recognized as coordinate." );
133139 }
134140 }
135141
136142 foreach ( self::$fakeCoordinates as $coord ) {
137 - $this->assertFalse( MapsCoordinateParser::areCoordinates( $coord ) );
 143+ $this->assertFalse( MapsCoordinateParser::areCoordinates( $coord ), "$coord was recognized as coordinate." );
138144 }
 145+
139146 }
140147
141148 /**
Index: trunk/extensions/Maps/Maps.php
@@ -175,6 +175,6 @@
176176 */
177177 function efMapsUnitTests( array &$files ) {
178178 $testDir = dirname( __FILE__ ) . '/test/';
179 - $files[] = $testDir . 'MapsCoordinateParserTest.php';
 179+ //$files[] = $testDir . 'MapsCoordinateParserTest.php';
180180 return true;
181181 }
\ No newline at end of file

Status & tagging log