Index: trunk/extensions/Maps/test/MapsCoordinateParserTest.php |
— | — | @@ -11,6 +11,48 @@ |
12 | 12 | */ |
13 | 13 | class MapsCoordinateParserTest extends PHPUnit_Framework_TestCase { |
14 | 14 | |
| 15 | + public static $coordinates = array( |
| 16 | + 'float' => array( |
| 17 | + '55.7557860 N, 37.6176330 W', |
| 18 | + '55.7557860, -37.6176330', |
| 19 | + '55 S, 37.6176330 W', |
| 20 | + '-55, -37.6176330', |
| 21 | + '5.5S,37W ', |
| 22 | + '-5.5,-37 ' |
| 23 | + ), |
| 24 | + '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 | + ), |
| 32 | + '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 | + ), |
| 40 | + '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 | + ), |
| 48 | + ); |
| 49 | + |
| 50 | + public static $fakeCoordinates = array( |
| 51 | + '55.7557860 E, 37.6176330 W', |
| 52 | + '55.7557860 N, 37.6176330 N', |
| 53 | + '55.7557860 S, 37.6176330 N', |
| 54 | + '55.7557860 N, 37.6176330 S', |
| 55 | + ); |
| 56 | + |
15 | 57 | /** |
16 | 58 | * @var MapsCoordinateParser |
17 | 59 | */ |
— | — | @@ -63,48 +105,36 @@ |
64 | 106 | * Tests MapsCoordinateParser::getCoordinatesType() |
65 | 107 | */ |
66 | 108 | public function testGetCoordinatesType() { |
67 | | - // Floats |
68 | | - $this->assertEquals( MapsCoordinateParser::getCoordinatesType( '55.7557860 N, 37.6176330 W' ), Maps_COORDS_FLOAT ); |
69 | | - $this->assertEquals( MapsCoordinateParser::getCoordinatesType( '55.7557860, -37.6176330' ), Maps_COORDS_FLOAT ); |
70 | | - $this->assertEquals( MapsCoordinateParser::getCoordinatesType( '55 S, 37.6176330 W' ), Maps_COORDS_FLOAT ); |
71 | | - $this->assertEquals( MapsCoordinateParser::getCoordinatesType( '-55, -37.6176330' ), Maps_COORDS_FLOAT ); |
72 | | - $this->assertEquals( MapsCoordinateParser::getCoordinatesType( '5.5S,37W ' ), Maps_COORDS_FLOAT ); |
73 | | - $this->assertEquals( MapsCoordinateParser::getCoordinatesType( '-5.5,-37 ' ), Maps_COORDS_FLOAT ); |
| 109 | + foreach( self::$coordinates['float'] as $coord ) { |
| 110 | + $this->assertEquals( MapsCoordinateParser::getCoordinatesType( $coord ), Maps_COORDS_FLOAT ); |
| 111 | + } |
74 | 112 | |
75 | | - // Decimal Degrees |
76 | | - $this->assertEquals( MapsCoordinateParser::getCoordinatesType( '55.7557860� N, 37.6176330� W' ), Maps_COORDS_DD ); |
77 | | - $this->assertEquals( MapsCoordinateParser::getCoordinatesType( '55.7557860�, -37.6176330�' ), Maps_COORDS_DD ); |
78 | | - $this->assertEquals( MapsCoordinateParser::getCoordinatesType( '55� S, 37.6176330 � W' ), Maps_COORDS_DD ); |
79 | | - $this->assertEquals( MapsCoordinateParser::getCoordinatesType( '-55�, -37.6176330 �' ), Maps_COORDS_DD ); |
80 | | - $this->assertEquals( MapsCoordinateParser::getCoordinatesType( '5.5�S,37�W ' ), Maps_COORDS_DD ); |
81 | | - $this->assertEquals( MapsCoordinateParser::getCoordinatesType( '-5.5�,-37� ' ), Maps_COORDS_DD ); |
| 113 | + foreach( self::$coordinates['dd'] as $coord ) { |
| 114 | + $this->assertEquals( MapsCoordinateParser::getCoordinatesType( $coord ), Maps_COORDS_DD ); |
| 115 | + } |
82 | 116 | |
83 | | - // Decimal Minutes |
84 | | - $this->assertEquals( MapsCoordinateParser::getCoordinatesType( "55� 45.34716' N, 37� 37.05798' W" ), Maps_COORDS_DM ); |
85 | | - $this->assertEquals( MapsCoordinateParser::getCoordinatesType( "55� 45.34716', -37� 37.05798'" ), Maps_COORDS_DM ); |
86 | | - $this->assertEquals( MapsCoordinateParser::getCoordinatesType( "55� S, 37� 37.05798'W" ), Maps_COORDS_DM ); |
87 | | - $this->assertEquals( MapsCoordinateParser::getCoordinatesType( "-55�, 37� -37.05798'" ), Maps_COORDS_DM ); |
88 | | - $this->assertEquals( MapsCoordinateParser::getCoordinatesType( "55�S, 37�37.05798'W " ), Maps_COORDS_DM ); |
89 | | - $this->assertEquals( MapsCoordinateParser::getCoordinatesType( "-55�, 37�-37.05798' " ), Maps_COORDS_DM ); |
90 | | - |
91 | | - // Degrees Minutes Seconds |
92 | | - $this->assertEquals( MapsCoordinateParser::getCoordinatesType( "55� 45' 21\" N, 37� 37' 3\" W" ), Maps_COORDS_DMS ); |
93 | | - $this->assertEquals( MapsCoordinateParser::getCoordinatesType( "55� 45' 21\" N, -37� 37' 3\"" ), Maps_COORDS_DMS ); |
94 | | - $this->assertEquals( MapsCoordinateParser::getCoordinatesType( "55� 45' S, 37� 37' 3\"W" ), Maps_COORDS_DMS ); |
95 | | - $this->assertEquals( MapsCoordinateParser::getCoordinatesType( "-55�, -37� 37' 3\"" ), Maps_COORDS_DMS ); |
96 | | - $this->assertEquals( MapsCoordinateParser::getCoordinatesType( "55�45'S,37�37'3\"W " ), Maps_COORDS_DMS ); |
97 | | - $this->assertEquals( MapsCoordinateParser::getCoordinatesType( "-55�,-37�37'3\" " ), Maps_COORDS_DMS ); |
| 117 | + foreach( self::$coordinates['dm'] as $coord ) { |
| 118 | + $this->assertEquals( MapsCoordinateParser::getCoordinatesType( $coord ), Maps_COORDS_DM ); |
| 119 | + } |
| 120 | + |
| 121 | + foreach( self::$coordinates['dms'] as $coord ) { |
| 122 | + $this->assertEquals( MapsCoordinateParser::getCoordinatesType( $coord ), Maps_COORDS_DMS ); |
| 123 | + } |
98 | 124 | } |
99 | 125 | |
100 | 126 | /** |
101 | 127 | * Tests MapsCoordinateParser::areCoordinates() |
102 | 128 | */ |
103 | 129 | public function testAreCoordinates() { |
104 | | - // TODO Auto-generated MapsCoordinateParserTest::testAreCoordinates() |
105 | | - $this->markTestIncomplete ( "areCoordinates test not implemented" ); |
| 130 | + foreach( self::$coordinates as $type ) { |
| 131 | + foreach( self::$coordinates[$type] as $coord ) { |
| 132 | + $this->assertTrue( MapsCoordinateParser::areCoordinates( $coord ) ); |
| 133 | + } |
| 134 | + } |
106 | 135 | |
107 | | - MapsCoordinateParser::areCoordinates(/* parameters */); |
108 | | - |
| 136 | + foreach ( self::$fakeCoordinates as $coord ) { |
| 137 | + $this->assertFalse( MapsCoordinateParser::areCoordinates( $coord ) ); |
| 138 | + } |
109 | 139 | } |
110 | 140 | |
111 | 141 | /** |