Index: trunk/extensions/Maps/test/MapsCoordinateParserTest.php |
— | — | @@ -2,6 +2,12 @@ |
3 | 3 | |
4 | 4 | require_once 'PHPUnit\Framework\TestCase.php'; |
5 | 5 | |
| 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 | + |
6 | 12 | /** |
7 | 13 | * MapsCoordinateParser test case. |
8 | 14 | * |
— | — | @@ -21,28 +27,28 @@ |
22 | 28 | '-5.5,-37 ' |
23 | 29 | ), |
24 | 30 | '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° ' |
31 | 37 | ), |
32 | 38 | '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' " |
39 | 45 | ), |
40 | 46 | '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\" " |
47 | 53 | ), |
48 | 54 | ); |
49 | 55 | |
— | — | @@ -106,19 +112,19 @@ |
107 | 113 | */ |
108 | 114 | public function testGetCoordinatesType() { |
109 | 115 | 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." ); |
111 | 117 | } |
112 | 118 | |
113 | 119 | 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." ); |
115 | 121 | } |
116 | 122 | |
117 | 123 | 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." ); |
119 | 125 | } |
120 | 126 | |
121 | 127 | 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." ); |
123 | 129 | } |
124 | 130 | } |
125 | 131 | |
— | — | @@ -126,15 +132,16 @@ |
127 | 133 | * Tests MapsCoordinateParser::areCoordinates() |
128 | 134 | */ |
129 | 135 | 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." ); |
133 | 139 | } |
134 | 140 | } |
135 | 141 | |
136 | 142 | foreach ( self::$fakeCoordinates as $coord ) { |
137 | | - $this->assertFalse( MapsCoordinateParser::areCoordinates( $coord ) ); |
| 143 | + $this->assertFalse( MapsCoordinateParser::areCoordinates( $coord ), "$coord was recognized as coordinate." ); |
138 | 144 | } |
| 145 | + |
139 | 146 | } |
140 | 147 | |
141 | 148 | /** |
Index: trunk/extensions/Maps/Maps.php |
— | — | @@ -175,6 +175,6 @@ |
176 | 176 | */ |
177 | 177 | function efMapsUnitTests( array &$files ) { |
178 | 178 | $testDir = dirname( __FILE__ ) . '/test/'; |
179 | | - $files[] = $testDir . 'MapsCoordinateParserTest.php'; |
| 179 | + //$files[] = $testDir . 'MapsCoordinateParserTest.php'; |
180 | 180 | return true; |
181 | 181 | } |
\ No newline at end of file |