Index: trunk/extensions/Maps/test/MapsCoordinateParserTest.php |
— | — | @@ -52,6 +52,12 @@ |
53 | 53 | ), |
54 | 54 | ); |
55 | 55 | |
| 56 | + public static $coordinateMappings = array( |
| 57 | + 'float-dms' => array( |
| 58 | + '42° 30\' 0", -42° 30\' 0"' => array( '42.5, -42.5', '42.5 N, 42.5 W' ) |
| 59 | + ), |
| 60 | + ); |
| 61 | + |
56 | 62 | public static $fakeCoordinates = array( |
57 | 63 | '55.7557860 E, 37.6176330 W', |
58 | 64 | '55.7557860 N, 37.6176330 N', |
— | — | @@ -69,10 +75,6 @@ |
70 | 76 | */ |
71 | 77 | protected function setUp() { |
72 | 78 | parent::setUp (); |
73 | | - |
74 | | - // TODO Auto-generated MapsCoordinateParserTest::setUp() |
75 | | - |
76 | | - |
77 | 79 | $this->MapsCoordinateParser = new MapsCoordinateParser(/* parameters */); |
78 | 80 | |
79 | 81 | } |
— | — | @@ -81,11 +83,7 @@ |
82 | 84 | * Cleans up the environment after running a test. |
83 | 85 | */ |
84 | 86 | protected function tearDown() { |
85 | | - // TODO Auto-generated MapsCoordinateParserTest::tearDown() |
86 | | - |
87 | | - |
88 | 87 | $this->MapsCoordinateParser = null; |
89 | | - |
90 | 88 | parent::tearDown (); |
91 | 89 | } |
92 | 90 | |
— | — | @@ -93,7 +91,6 @@ |
94 | 92 | * Constructs the test case. |
95 | 93 | */ |
96 | 94 | public function __construct() { |
97 | | - // TODO Auto-generated constructor |
98 | 95 | } |
99 | 96 | |
100 | 97 | /** |
— | — | @@ -101,10 +98,9 @@ |
102 | 99 | */ |
103 | 100 | public function testParseCoordinates() { |
104 | 101 | // TODO Auto-generated MapsCoordinateParserTest::testParseCoordinates() |
105 | | - $this->markTestIncomplete ( "parseCoordinates test not implemented" ); |
106 | | - |
107 | | - MapsCoordinateParser::parseCoordinates(/* parameters */); |
108 | | - |
| 102 | + foreach ( self::$fakeCoordinates as $coord ) { |
| 103 | + $this->assertFalse( MapsCoordinateParser::parseCoordinates( $coord ), "parseCoordinates did not return false for $coord." ); |
| 104 | + } |
109 | 105 | } |
110 | 106 | |
111 | 107 | /** |
— | — | @@ -233,10 +229,20 @@ |
234 | 230 | */ |
235 | 231 | public function testParseAndFormat() { |
236 | 232 | // TODO Auto-generated MapsCoordinateParserTest::testParseAndFormat() |
237 | | - $this->markTestIncomplete ( "parseAndFormat test not implemented" ); |
| 233 | + foreach ( self::$fakeCoordinates as $coord ) { |
| 234 | + $this->assertFalse( MapsCoordinateParser::parseAndFormat( $coord ), "parseAndFormat did not return false for $coord." ); |
| 235 | + } |
238 | 236 | |
239 | | - MapsCoordinateParser::parseAndFormat(/* parameters */); |
240 | | - |
| 237 | + foreach ( self::$coordinateMappings['float-dms'] as $destination => $sources ) { |
| 238 | + foreach ( $sources as $source ) { |
| 239 | + $result = MapsCoordinateParser::parseAndFormat( $source, Maps_COORDS_DMS, false ); |
| 240 | + $this->assertEquals( |
| 241 | + $destination, |
| 242 | + $result, |
| 243 | + "$source parsed to $result, not $destination" |
| 244 | + ); |
| 245 | + } |
| 246 | + } |
241 | 247 | } |
242 | 248 | |
243 | 249 | } |