|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Geocoder\Tests\Provider; |
| 4 | + |
| 5 | +use Geocoder\Tests\TestCase; |
| 6 | +use Geocoder\Provider\OGDViennaAustriaProvider; |
| 7 | + |
| 8 | +/** |
| 9 | + * @author Robert Harm <www.harm.co.at> |
| 10 | + * Data source: City of Vienna, http://data.wien.gv.at |
| 11 | + */ |
| 12 | +class OGDViennaAustriaProviderTest extends TestCase |
| 13 | +{ |
| 14 | + public function testGetName() |
| 15 | + { |
| 16 | + $provider = new OGDViennaAustriaProvider($this->getMockAdapter($this->never())); |
| 17 | + $this->assertEquals('ogd_vienna_austria', $provider->getName()); |
| 18 | + } |
| 19 | + |
| 20 | + /** |
| 21 | + * @expectedException \Geocoder\Exception\NoResultException |
| 22 | + * @expectedExceptionMessage Could not execute query http://data.wien.gv.at/daten/OGDAddressService.svc/GetAddressInfo?CRS=EPSG:4326&Address=Stephansplatz |
| 23 | + */ |
| 24 | + public function testGetGeocodedDataWithAddress() |
| 25 | + { |
| 26 | + $provider = new OGDViennaAustriaProvider($this->getMockAdapter()); |
| 27 | + $provider->getGeocodedData('Stephansplatz'); |
| 28 | + } |
| 29 | + |
| 30 | + /** |
| 31 | + * @expectedException \Geocoder\Exception\NoResultException |
| 32 | + * @expectedExceptionMessage Could not execute query http://data.wien.gv.at/daten/OGDAddressService.svc/GetAddressInfo?CRS=EPSG:4326&Address=yyyyyyy |
| 33 | + */ |
| 34 | + public function testGetGeocodedDataWithWrongAddress() |
| 35 | + { |
| 36 | + $provider = new OGDViennaAustriaProvider($this->getAdapter()); |
| 37 | + $provider->getGeocodedData('yyyyyyy'); |
| 38 | + } |
| 39 | + |
| 40 | + public function testGetGeocodedDataWithRealAddress() |
| 41 | + { |
| 42 | + $provider = new OGDViennaAustriaProvider($this->getAdapter()); |
| 43 | + $result = $provider->getGeocodedData('Stephansplatz'); |
| 44 | + |
| 45 | + $this->assertInternalType('array', $result); |
| 46 | + $this->assertCount(1, $result); |
| 47 | + |
| 48 | + $result = $result[0]; |
| 49 | + $this->assertInternalType('array', $result); |
| 50 | + $this->assertEquals(48.208583576583, $result['latitude'], '', 0.0001); |
| 51 | + $this->assertEquals(16.373089928434, $result['longitude'], '', 0.0001); |
| 52 | + $this->assertNull($result['bounds']); |
| 53 | + //$this->assertNull($result['streetNumber']); |
| 54 | + $this->assertNull($result['streetName']); |
| 55 | + $this->assertNull($result['zipcode']); |
| 56 | + $this->assertNull($result['city']); |
| 57 | + //$this->assertNull($result['cityDistrict']); |
| 58 | + $this->assertNull($result['region']); |
| 59 | + $this->assertNull($result['regionCode']); |
| 60 | + //$this->assertNull($result['country']); |
| 61 | + $this->assertNull($result['countryCode']); |
| 62 | + $this->assertNull($result['timezone']); |
| 63 | + } |
| 64 | + |
| 65 | + /** |
| 66 | + * @expectedException \Geocoder\Exception\UnsupportedException |
| 67 | + * @expectedExceptionMessage The OGDViennaAustriaProvider does not support IP addresses. |
| 68 | + */ |
| 69 | + public function testGetGeocodedDataWithLocalhostIPv4() |
| 70 | + { |
| 71 | + $provider = new OGDViennaAustriaProvider($this->getMockAdapter($this->never())); |
| 72 | + $provider->getGeocodedData('127.0.0.1'); |
| 73 | + } |
| 74 | + |
| 75 | + /** |
| 76 | + * @expectedException \Geocoder\Exception\UnsupportedException |
| 77 | + * @expectedExceptionMessage The OGDViennaAustriaProvider does not support IP addresses. |
| 78 | + */ |
| 79 | + public function testGetGeocodedDataWithLocalhostIPv6() |
| 80 | + { |
| 81 | + $provider = new OGDViennaAustriaProvider($this->getMockAdapter($this->never())); |
| 82 | + $provider->getGeocodedData('::1'); |
| 83 | + } |
| 84 | + |
| 85 | + /** |
| 86 | + * @expectedException \Geocoder\Exception\UnsupportedException |
| 87 | + * @expectedExceptionMessage The OGDViennaAustriaProvider does not support IP addresses. |
| 88 | + */ |
| 89 | + public function testGetGeocodedDataWithIPv4() |
| 90 | + { |
| 91 | + $provider = new OGDViennaAustriaProvider($this->getAdapter()); |
| 92 | + $provider->getGeocodedData('74.200.247.59'); |
| 93 | + } |
| 94 | + |
| 95 | + /** |
| 96 | + * @expectedException \Geocoder\Exception\UnsupportedException |
| 97 | + * @expectedExceptionMessage The OGDViennaAustriaProvider does not support IP addresses. |
| 98 | + */ |
| 99 | + public function testGetGeocodedDataWithIPv6() |
| 100 | + { |
| 101 | + $provider = new OGDViennaAustriaProvider($this->getAdapter()); |
| 102 | + $provider->getGeocodedData('::ffff:74.200.247.59'); |
| 103 | + } |
| 104 | + |
| 105 | + /** |
| 106 | + * @expectedException \Geocoder\Exception\UnsupportedException |
| 107 | + * @expectedExceptionMessage The OGDViennaAustriaProvider is not able to do reverse geocoding. |
| 108 | + */ |
| 109 | + public function testGetReverseData() |
| 110 | + { |
| 111 | + $provider = new OGDViennaAustriaProvider($this->getMockAdapter($this->never())); |
| 112 | + $provider->getReversedData(array(1, 2)); |
| 113 | + } |
| 114 | +} |
0 commit comments