Completed
Push — mawiki ( ed8c52 )
by Jeroen De
08:10
created

NominatimGeocoderTest::getMethod()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 5
c 1
b 0
f 1
nc 1
nop 1
dl 0
loc 6
rs 9.4285
1
<?php
2
3
namespace Maps\Test;
4
5
use FileFetcher\InMemoryFileFetcher;
6
use Maps\Geocoders\NominatimGeocoder;
7
8
/**
9
 * @covers Maps\Geocoders\NominatimGeocoder
10
 *
11
 * @group Maps
12
 *
13
 * @licence GNU GPL v2+
14
 * @author Peter Grassberger < [email protected] >
15
 * @author Jeroen De Dauw < [email protected] >
16
 */
17
class NominatimGeocoderTest extends \PHPUnit_Framework_TestCase {
18
19
	public function testHappyPath() {
20
		$fileFetcher = new InMemoryFileFetcher( [
21
			'https://nominatim.openstreetmap.org/search?format=jsonv2&limit=1&q=New%2BYork'
22
				=> '[{"place_id":"97961780","licence":"Data © OpenStreetMap contributors, ODbL 1.0. http:\/\/www.openstreetmap.org\/copyright","osm_type":"way","osm_id":"161387758","boundingbox":["40.763858","40.7642664","-73.9548572","-73.954092"],"lat":"40.7642499","lon":"-73.9545249","display_name":"NewYork Hospital Drive, Upper East Side, Manhattan, New York County, New York City, New York, 10021, United States of America","place_rank":"27","category":"highway","type":"service","importance":0.275}]'
23
		] );
24
25
		$geocoder = new NominatimGeocoder( $fileFetcher );
26
27
		$this->assertSame( 40.7642499, $geocoder->geocode( 'New York' )->getLatitude() );
28
		$this->assertSame( -73.9545249, $geocoder->geocode( 'New York' )->getLongitude() );
29
	}
30
31
	// TODO: test no result found case
32
	// TODO: test network failure case
33
	// TODO: test malicious address escaping
34
35
}
36