Index: trunk/extensions/GeoData/tests/TagTest.php |
— | — | @@ -18,6 +18,7 @@ |
19 | 19 | return; |
20 | 20 | } |
21 | 21 | $all = $out->geoData->getAll(); |
| 22 | + $this->assertEquals( 1, count( $all ), 'A result was expected' ); |
22 | 23 | $coord = $all[0]; |
23 | 24 | foreach ( $expected as $field => $value ) { |
24 | 25 | $this->assertEquals( $value, $coord->$field, "Checking field $field" ); |
— | — | @@ -42,6 +43,10 @@ |
43 | 44 | '{{#coordinates:10|20|globe:Moon dim:10_region:RU-mos}}', |
44 | 45 | array( 'lat' => 10, 'lon' => 20, 'globe' => 'moon', 'country' => 'RU', 'region' => 'MOS' ), |
45 | 46 | ), |
| 47 | + array( |
| 48 | + '{{#coordinates:10|20|globe:Moon dim:10_region:RU}}', |
| 49 | + array( 'lat' => 10, 'lon' => 20, 'globe' => 'moon', 'country' => 'RU' ), |
| 50 | + ), |
46 | 51 | array( |
47 | 52 | '{{#coordinates: 10|20|primary|_dim:3Km_}}', |
48 | 53 | array( 'lat' => 10, 'lon' => 20, 'globe' => 'earth', 'primary' => true, 'dim' => 3000 ), |
Index: trunk/extensions/GeoData/CoordinatesParserFunction.php |
— | — | @@ -146,9 +146,9 @@ |
147 | 147 | $coord->name = isset( $args['name'] ) ? $args['name'] : null; |
148 | 148 | if ( isset( $args['region'] ) ) { |
149 | 149 | $code = strtoupper( $args['region'] ); |
150 | | - if ( preg_match( '/([A-Z]{2})(?:-([A-Z0-9]{1,3}))/', $code, $m ) ) { |
| 150 | + if ( preg_match( '/([A-Z]{2})(?:-([A-Z0-9]{1,3}))?/', $code, $m ) ) { |
151 | 151 | $coord->country = $m[1]; |
152 | | - $coord->region = $m[2]; |
| 152 | + $coord->region = isset( $m[2] ) ? $m[2] : null; |
153 | 153 | } else { |
154 | 154 | $result->warning( 'geodata-bad-region', $args['region'] ); //@todo: actually use this warning |
155 | 155 | } |