r69462 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r69461‎ | r69462 | r69463 >
Date:02:47, 17 July 2010
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Added more tests
Modified paths:
  • /trunk/extensions/Maps/test/MapsCoordinateParserTest.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Maps/test/MapsCoordinateParserTest.php
@@ -52,6 +52,12 @@
5353 ),
5454 );
5555
 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+
5662 public static $fakeCoordinates = array(
5763 '55.7557860 E, 37.6176330 W',
5864 '55.7557860 N, 37.6176330 N',
@@ -69,10 +75,6 @@
7076 */
7177 protected function setUp() {
7278 parent::setUp ();
73 -
74 - // TODO Auto-generated MapsCoordinateParserTest::setUp()
75 -
76 -
7779 $this->MapsCoordinateParser = new MapsCoordinateParser(/* parameters */);
7880
7981 }
@@ -81,11 +83,7 @@
8284 * Cleans up the environment after running a test.
8385 */
8486 protected function tearDown() {
85 - // TODO Auto-generated MapsCoordinateParserTest::tearDown()
86 -
87 -
8887 $this->MapsCoordinateParser = null;
89 -
9088 parent::tearDown ();
9189 }
9290
@@ -93,7 +91,6 @@
9492 * Constructs the test case.
9593 */
9694 public function __construct() {
97 - // TODO Auto-generated constructor
9895 }
9996
10097 /**
@@ -101,10 +98,9 @@
10299 */
103100 public function testParseCoordinates() {
104101 // 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+ }
109105 }
110106
111107 /**
@@ -233,10 +229,20 @@
234230 */
235231 public function testParseAndFormat() {
236232 // 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+ }
238236
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+ }
241247 }
242248
243249 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r69463Fixed bug found by tests added in r69462jeroendedauw02:49, 17 July 2010

Status & tagging log