Skip to content

Commit 3c67c0f

Browse files
committed
fix TomTom provider tests, doc, phpunit.dist and add new cached responses
1 parent de32039 commit 3c67c0f

10 files changed

+26
-22
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,6 @@ following lines and add your own API keys:
514514
<!-- <server name="GEOIPS_API_KEY" value="YOUR_API_KEY" /> -->
515515
<!-- <server name="MAXMIND_API_KEY" value="YOUR_API_KEY" /> -->
516516
<!-- <server name="GEONAMES_USERNAME" value="YOUR_USERNAME" /> -->
517-
<!-- <server name="TOMTOM_GEOCODING_KEY" value="YOUR_GEOCODING_KEY" /> -->
518517
<!-- <server name="TOMTOM_MAP_KEY" value="YOUR_MAP_KEY" /> -->
519518
<!-- <server name="GOOGLE_GEOCODING_KEY" value="YOUR_GEOCODING_KEY" /> -->
520519
<!-- <server name="OPENCAGE_API_KEY" value="YOUR_API_KEY" /> -->

phpunit.xml.dist

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
<!-- <server name="MAXMIND_API_KEY" value="YOUR_API_KEY" /> -->
2525
<!-- <server name="MAPQUEST_API_KEY" value="YOUR_API_KEY" /> -->
2626
<!-- <server name="GEONAMES_USERNAME" value="YOUR_USERNAME" /> -->
27-
<!-- <server name="TOMTOM_GEOCODING_KEY" value="YOUR_GEOCODING_KEY" /> -->
2827
<!-- <server name="TOMTOM_MAP_KEY" value="YOUR_MAP_KEY" /> -->
2928
<!-- <server name="GOOGLE_GEOCODING_KEY" value="YOUR_GEOCODING_KEY" /> -->
3029
<!-- <server name="OPENCAGE_API_KEY" value="YOUR_GEOCODING_KEY" /> -->

src/Geocoder/Provider/TomTom.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class TomTom extends AbstractHttpProvider implements LocaleAwareProvider
2323
/**
2424
* @var string
2525
*/
26-
const GEOCODE_ENDPOINT_URL = 'https://api.tomtom.com/lbs/geocoding/geocode?key=%s&query=%s&maxResults=%d';
26+
const GEOCODE_ENDPOINT_URL = 'https://api.tomtom.com/lbs/services/geocode/4/geocode?key=%s&query=%s&maxResults=%d';
2727

2828
/**
2929
* @var string
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
s:1992:"<?xml version="1.0" encoding="UTF-8" standalone="yes"?><geoResponse xmlns="http://lbs.tomtom.com/services" svnRevision="208250" count="1" version="1.14.1" duration="4" debugInformation="{Database revision=205242, Index Revision=205242, Duration of Database Search=1, Duration of Index Search=2}" consolidatedMaps="[Consolidated(205242), LBS_EU_region_CE_Europe(5301), LBS_region_Asia(5301), LBS_EU_region_Scandinavia(5301), LBS_region_India(5301), LBS_EU_region_Iberia(5301), LBS_region_Middle_East(5301), LBS_EU_region_Germany(5301), LBS_EU_region_Russia(5301), LBS_region_South_America(5301), LBS_region_Africa(5301), LBS_EU_region_France(5301), LBS_region_Egypt(5301), LBS_region_New_Zealand(5301), LBS_NA_region_Canada(5301), LBS_EU_region_ACH(5301), LBS_region_Australia(5301), LBS_EU_region_Italy(5301), LBS_region_Caribbean(5301), LBS_EU_UK_Ireland(5301), LBS_EU_region_SE_Europe(5301), LBS_NA_Mexico(5301), LBS_region_Vietnam(5301), LBS_EU_region_Benelux(5301), LBS_NA_USA(5331), LBS_connect(5301)]"><resultStatusList><status info="NND" status="NOPOCMATCH"/><status info="FTX" status="MATCH"/></resultStatusList><geoResult debugInformation="{documentId=-1}"><latitude>55.704389</latitude><longitude>12.546129</longitude><geohash>u3buvkxv9fxz</geohash><mapName>TomTomMap</mapName><houseNumber>422</houseNumber><type>poi</type><poiCategory>7311</poiCategory><poiName>Uno-X</poiName><poiImportance>0</poiImportance><poiBrandname>Uno-X</poiBrandname><poiPositionAccuracy>0</poiPositionAccuracy><poiGeocodingAccuracy>18</poiGeocodingAccuracy><distance>0.0</distance><street>Tagensvej</street><city>Copenhague</city><country>Danemark</country><countryISO3>DNK</countryISO3><postcode>2200</postcode><formattedAddress>Uno-X, Tagensvej 422, 2200, Copenhague, DNK</formattedAddress><isCensusMicropolitanFlag>false</isCensusMicropolitanFlag><widthMeters>1</widthMeters><heightMeters>1</heightMeters><score>1.0</score><confidence>1.0</confidence><iteration>0</iteration></geoResult></geoResponse>";
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
s:603:"<?xml version="1.0" encoding="UTF-8" standalone="yes"?><reverseGeoResponse xmlns="http://lbs.tomtom.com/services" version="1.0.32-mascoma"><reverseGeoResult type="Basic"><latitude>48.86323</latitude><longitude>2.38877</longitude><street>Avenue Gambetta</street><city>20e Arrondissement Paris</city><country>France</country><countryISO3>FRA</countryISO3><formattedAddress>Avenue Gambetta 3, 20e Arrondissement Paris, FR</formattedAddress><snp>S</snp><centerCoord><latitude>48.86477</latitude><longitude>2.39859</longitude></centerCoord><houseNumber>3</houseNumber></reverseGeoResult></reverseGeoResponse>";
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
s:1991:"<?xml version="1.0" encoding="UTF-8" standalone="yes"?><geoResponse xmlns="http://lbs.tomtom.com/services" svnRevision="208250" count="1" version="1.14.1" duration="2" debugInformation="{Database revision=205242, Index Revision=205242, Duration of Database Search=1, Duration of Index Search=1}" consolidatedMaps="[Consolidated(205242), LBS_EU_region_CE_Europe(5301), LBS_region_Asia(5301), LBS_EU_region_Scandinavia(5301), LBS_region_India(5301), LBS_EU_region_Iberia(5301), LBS_region_Middle_East(5301), LBS_EU_region_Germany(5301), LBS_EU_region_Russia(5301), LBS_region_South_America(5301), LBS_region_Africa(5301), LBS_EU_region_France(5301), LBS_region_Egypt(5301), LBS_region_New_Zealand(5301), LBS_NA_region_Canada(5301), LBS_EU_region_ACH(5301), LBS_region_Australia(5301), LBS_EU_region_Italy(5301), LBS_region_Caribbean(5301), LBS_EU_UK_Ireland(5301), LBS_EU_region_SE_Europe(5301), LBS_NA_Mexico(5301), LBS_region_Vietnam(5301), LBS_EU_region_Benelux(5301), LBS_NA_USA(5331), LBS_connect(5301)]"><resultStatusList><status info="NND" status="NOPOCMATCH"/><status info="FTX" status="MATCH"/></resultStatusList><geoResult debugInformation="{documentId=-1}"><latitude>55.704389</latitude><longitude>12.546129</longitude><geohash>u3buvkxv9fxz</geohash><mapName>TomTomMap</mapName><houseNumber>422</houseNumber><type>poi</type><poiCategory>7311</poiCategory><poiName>Uno-X</poiName><poiImportance>0</poiImportance><poiBrandname>Uno-X</poiBrandname><poiPositionAccuracy>0</poiPositionAccuracy><poiGeocodingAccuracy>18</poiGeocodingAccuracy><distance>0.0</distance><street>Tagensvej</street><city>Köpenhamn</city><country>Danmark</country><countryISO3>DNK</countryISO3><postcode>2200</postcode><formattedAddress>Uno-X, Tagensvej 422, 2200, Köpenhamn, DNK</formattedAddress><isCensusMicropolitanFlag>false</isCensusMicropolitanFlag><widthMeters>1</widthMeters><heightMeters>1</heightMeters><score>1.0</score><confidence>1.0</confidence><iteration>0</iteration></geoResult></geoResponse>";
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
s:566:"<?xml version="1.0" encoding="UTF-8" standalone="yes"?><reverseGeoResponse xmlns="http://lbs.tomtom.com/services" version="1.0.32-mascoma"><reverseGeoResult type="Basic"><latitude>56.52436</latitude><longitude>10.06743</longitude><street>Stabelsvej</street><city>Spentrup</city><country>Denmark</country><countryISO3>DNK</countryISO3><formattedAddress>Stabelsvej 16, Spentrup, DK</formattedAddress><snp>S</snp><centerCoord><latitude>56.54027</latitude><longitude>10.03094</longitude></centerCoord><houseNumber>16</houseNumber></reverseGeoResult></reverseGeoResponse>";
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
s:1992:"<?xml version="1.0" encoding="UTF-8" standalone="yes"?><geoResponse xmlns="http://lbs.tomtom.com/services" svnRevision="208250" count="1" version="1.14.1" duration="17" debugInformation="{Database revision=205242, Index Revision=205242, Duration of Database Search=9, Duration of Index Search=8}" consolidatedMaps="[Consolidated(205242), LBS_EU_region_CE_Europe(5301), LBS_region_Asia(5301), LBS_EU_region_Scandinavia(5301), LBS_region_India(5301), LBS_EU_region_Iberia(5301), LBS_region_Middle_East(5301), LBS_EU_region_Germany(5301), LBS_EU_region_Russia(5301), LBS_region_South_America(5301), LBS_region_Africa(5301), LBS_EU_region_France(5301), LBS_region_Egypt(5301), LBS_region_New_Zealand(5301), LBS_NA_region_Canada(5301), LBS_EU_region_ACH(5301), LBS_region_Australia(5301), LBS_EU_region_Italy(5301), LBS_region_Caribbean(5301), LBS_EU_UK_Ireland(5301), LBS_EU_region_SE_Europe(5301), LBS_NA_Mexico(5301), LBS_region_Vietnam(5301), LBS_EU_region_Benelux(5301), LBS_NA_USA(5331), LBS_connect(5301)]"><resultStatusList><status info="NND" status="NOPOCMATCH"/><status info="FTX" status="MATCH"/></resultStatusList><geoResult debugInformation="{documentId=-1}"><latitude>55.704389</latitude><longitude>12.546129</longitude><geohash>u3buvkxv9fxz</geohash><mapName>TomTomMap</mapName><houseNumber>422</houseNumber><type>poi</type><poiCategory>7311</poiCategory><poiName>Uno-X</poiName><poiImportance>0</poiImportance><poiBrandname>Uno-X</poiBrandname><poiPositionAccuracy>0</poiPositionAccuracy><poiGeocodingAccuracy>18</poiGeocodingAccuracy><distance>0.0</distance><street>Tagensvej</street><city>Copenhagen</city><country>Denmark</country><countryISO3>DNK</countryISO3><postcode>2200</postcode><formattedAddress>Uno-X, Tagensvej 422, 2200, Copenhagen, DNK</formattedAddress><isCensusMicropolitanFlag>false</isCensusMicropolitanFlag><widthMeters>1</widthMeters><heightMeters>1</heightMeters><score>1.0</score><confidence>1.0</confidence><iteration>0</iteration></geoResult></geoResponse>";
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
s:3935:"<?xml version="1.0" encoding="UTF-8" standalone="yes"?><geoResponse xmlns="http://lbs.tomtom.com/services" svnRevision="208250" count="5" version="1.14.1" duration="14" debugInformation="{Database revision=205242, Index Revision=205242, Duration of Database Search=8, Duration of Index Search=6}" consolidatedMaps="[Consolidated(205242), LBS_EU_region_CE_Europe(5301), LBS_region_Asia(5301), LBS_EU_region_Scandinavia(5301), LBS_region_India(5301), LBS_EU_region_Iberia(5301), LBS_region_Middle_East(5301), LBS_EU_region_Germany(5301), LBS_EU_region_Russia(5301), LBS_region_South_America(5301), LBS_region_Africa(5301), LBS_EU_region_France(5301), LBS_region_Egypt(5301), LBS_region_New_Zealand(5301), LBS_NA_region_Canada(5301), LBS_EU_region_ACH(5301), LBS_region_Australia(5301), LBS_EU_region_Italy(5301), LBS_region_Caribbean(5301), LBS_EU_UK_Ireland(5301), LBS_EU_region_SE_Europe(5301), LBS_NA_Mexico(5301), LBS_region_Vietnam(5301), LBS_EU_region_Benelux(5301), LBS_NA_USA(5331), LBS_connect(5301)]"><resultStatusList><status info="NND" status="NOPOCMATCH"/><status info="FTX" status="MATCH"/></resultStatusList><geoResult debugInformation="{documentId=-1}"><latitude>48.856898</latitude><longitude>2.350844</longitude><geohash>u09tvqpu49uk</geohash><mapName>TomTomMap</mapName><type>city</type><city>Paris</city><state>Ile-de-France</state><country>France</country><countryISO3>FRA</countryISO3><formattedAddress>Paris, Ile-de-France, FR</formattedAddress><isCensusMicropolitanFlag>false</isCensusMicropolitanFlag><widthMeters>1</widthMeters><heightMeters>1</heightMeters><score>1.0</score><confidence>0.053527977</confidence><iteration>0</iteration></geoResult><geoResult debugInformation="{documentId=-1}"><latitude>33.661426</latitude><longitude>-95.556321</longitude><geohash>9vup3xfh02dg</geohash><mapName>TomTomMap</mapName><type>city</type><city>Paris</city><state>Texas</state><country>United States</country><countryISO3>USA</countryISO3><formattedAddress>Paris, Texas, US</formattedAddress><isCensusMicropolitanFlag>false</isCensusMicropolitanFlag><widthMeters>1</widthMeters><heightMeters>1</heightMeters><score>0.9545453786849976</score><confidence>0.051094882</confidence><iteration>0</iteration></geoResult><geoResult debugInformation="{documentId=-1}"><latitude>36.302754</latitude><longitude>-88.326359</longitude><geohash>dn3nw0dwyev4</geohash><mapName>TomTomMap</mapName><type>city</type><city>Paris</city><state>Tennessee</state><country>United States</country><countryISO3>USA</countryISO3><formattedAddress>Paris, Tennessee, US</formattedAddress><isCensusMicropolitanFlag>false</isCensusMicropolitanFlag><widthMeters>1</widthMeters><heightMeters>1</heightMeters><score>0.9545453786849976</score><confidence>0.051094882</confidence><iteration>0</iteration></geoResult><geoResult debugInformation="{documentId=-1}"><latitude>-19.039448</latitude><longitude>29.560445</longitude><geohash>kst58tvr0m9k</geohash><mapName>TomTomMap</mapName><type>city</type><city>Paris</city><state>Midlands</state><country>Zimbabwe</country><countryISO3>ZWE</countryISO3><formattedAddress>Paris, Midlands, ZW</formattedAddress><isCensusMicropolitanFlag>false</isCensusMicropolitanFlag><widthMeters>1</widthMeters><heightMeters>1</heightMeters><score>0.9431817531585693</score><confidence>0.05048661</confidence><iteration>0</iteration></geoResult><geoResult debugInformation="{documentId=-1}"><latitude>35.292105</latitude><longitude>-93.729922</longitude><geohash>9ym2g0ezqt0w</geohash><mapName>TomTomMap</mapName><type>city</type><city>Paris</city><state>Arkansas</state><country>United States</country><countryISO3>USA</countryISO3><formattedAddress>Paris, Arkansas, US</formattedAddress><isCensusMicropolitanFlag>false</isCensusMicropolitanFlag><widthMeters>1</widthMeters><heightMeters>1</heightMeters><score>0.9431817531585693</score><confidence>0.05048661</confidence><iteration>0</iteration></geoResult></geoResponse>";

tests/Geocoder/Tests/Provider/TomTomTest.php

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function testGeocodeWithNullApiKey()
2626

2727
/**
2828
* @expectedException \Geocoder\Exception\NoResult
29-
* @expectedExceptionMessage Could not execute query "https://api.tomtom.com/lbs/geocoding/geocode?key=api_key&query=&maxResults=5".
29+
* @expectedExceptionMessage Could not execute query "https://api.tomtom.com/lbs/services/geocode/4/geocode?key=api_key&query=&maxResults=5".
3030
*/
3131
public function testGeocodeWithNull()
3232
{
@@ -36,7 +36,7 @@ public function testGeocodeWithNull()
3636

3737
/**
3838
* @expectedException \Geocoder\Exception\NoResult
39-
* @expectedExceptionMessage Could not execute query "https://api.tomtom.com/lbs/geocoding/geocode?key=api_key&query=&maxResults=5".
39+
* @expectedExceptionMessage Could not execute query "https://api.tomtom.com/lbs/services/geocode/4/geocode?key=api_key&query=&maxResults=5".
4040
*/
4141
public function testGeocodeWithEmpty()
4242
{
@@ -46,7 +46,7 @@ public function testGeocodeWithEmpty()
4646

4747
/**
4848
* @expectedException \Geocoder\Exception\NoResult
49-
* @expectedExceptionMessage Could not execute query "https://api.tomtom.com/lbs/geocoding/geocode?key=api_key&query=Tagensvej%2047%2C%202200%20K%C3%B8benhavn%20N&maxResults=5".
49+
* @expectedExceptionMessage Could not execute query "https://api.tomtom.com/lbs/services/geocode/4/geocode?key=api_key&query=Tagensvej%2047%2C%202200%20K%C3%B8benhavn%20N&maxResults=5".
5050
*/
5151
public function testGeocodeWithAddressContentReturnNull()
5252
{
@@ -56,7 +56,7 @@ public function testGeocodeWithAddressContentReturnNull()
5656

5757
/**
5858
* @expectedException \Geocoder\Exception\NoResult
59-
* @expectedExceptionMessage Could not execute query "https://api.tomtom.com/lbs/geocoding/geocode?key=api_key&query=Tagensvej%2047%2C%202200%20K%C3%B8benhavn%20N&maxResults=5".
59+
* @expectedExceptionMessage Could not execute query "https://api.tomtom.com/lbs/services/geocode/4/geocode?key=api_key&query=Tagensvej%2047%2C%202200%20K%C3%B8benhavn%20N&maxResults=5".
6060
*/
6161
public function testGeocodeWithAddress()
6262
{
@@ -66,7 +66,7 @@ public function testGeocodeWithAddress()
6666

6767
/**
6868
* @expectedException \Geocoder\Exception\NoResult
69-
* @expectedExceptionMessage Could not execute query "https://api.tomtom.com/lbs/geocoding/geocode?key=api_key&query=foo&maxResults=5".
69+
* @expectedExceptionMessage Could not execute query "https://api.tomtom.com/lbs/services/geocode/4/geocode?key=api_key&query=foo&maxResults=5".
7070
*/
7171
public function testGeocodeNoResult()
7272
{
@@ -80,11 +80,11 @@ public function testGeocodeNoResult()
8080

8181
public function testGeocodeWithRealAddress()
8282
{
83-
if (!isset($_SERVER['TOMTOM_GEOCODING_KEY'])) {
84-
$this->markTestSkipped('You need to configure the TOMTOM_GEOCODING_KEY value in phpunit.xml');
83+
if (!isset($_SERVER['TOMTOM_MAP_KEY'])) {
84+
$this->markTestSkipped('You need to configure the TOMTOM_MAP_KEY value in phpunit.xml');
8585
}
8686

87-
$provider = new TomTom($this->getAdapter(), $_SERVER['TOMTOM_GEOCODING_KEY']);
87+
$provider = new TomTom($this->getAdapter(), $_SERVER['TOMTOM_MAP_KEY']);
8888
$results = $provider->geocode('Tagensvej 47, 2200 København N');
8989

9090
$this->assertInternalType('array', $results);
@@ -110,11 +110,11 @@ public function testGeocodeWithRealAddress()
110110

111111
public function testGeocodeWithRealAddressWithFrenchLocale()
112112
{
113-
if (!isset($_SERVER['TOMTOM_GEOCODING_KEY'])) {
114-
$this->markTestSkipped('You need to configure the TOMTOM_GEOCODING_KEY value in phpunit.xml');
113+
if (!isset($_SERVER['TOMTOM_MAP_KEY'])) {
114+
$this->markTestSkipped('You need to configure the TOMTOM_MAP_KEY value in phpunit.xml');
115115
}
116116

117-
$provider = new TomTom($this->getAdapter(), $_SERVER['TOMTOM_GEOCODING_KEY'], 'fr_FR');
117+
$provider = new TomTom($this->getAdapter(), $_SERVER['TOMTOM_MAP_KEY'], 'fr_FR');
118118
$results = $provider->geocode('Tagensvej 47, 2200 København N');
119119

120120
$this->assertInternalType('array', $results);
@@ -138,13 +138,13 @@ public function testGeocodeWithRealAddressWithFrenchLocale()
138138
$this->assertNull($result->getTimezone());
139139
}
140140

141-
public function testGeocodeWithRealAddressWithSwidishLocale()
141+
public function testGeocodeWithRealAddressWithSwedishLocale()
142142
{
143-
if (!isset($_SERVER['TOMTOM_GEOCODING_KEY'])) {
144-
$this->markTestSkipped('You need to configure the TOMTOM_GEOCODING_KEY value in phpunit.xml');
143+
if (!isset($_SERVER['TOMTOM_MAP_KEY'])) {
144+
$this->markTestSkipped('You need to configure the TOMTOM_MAP_KEY value in phpunit.xml');
145145
}
146146

147-
$provider = new TomTom($this->getAdapter(), $_SERVER['TOMTOM_GEOCODING_KEY'], 'sv-SE');
147+
$provider = new TomTom($this->getAdapter(), $_SERVER['TOMTOM_MAP_KEY'], 'sv-SE');
148148
$results = $provider->geocode('Tagensvej 47, 2200 København N');
149149

150150
$this->assertInternalType('array', $results);
@@ -163,18 +163,18 @@ public function testGeocodeWithRealAddressWithSwidishLocale()
163163
$this->assertNull($result->getSubLocality());
164164
$this->assertNull($result->getRegion()->getName());
165165
$this->assertNull($result->getRegion()->getCode());
166-
$this->assertEquals('Dania', $result->getCountry()->getName());
166+
$this->assertEquals('Danmark', $result->getCountry()->getName());
167167
$this->assertEquals('DNK', $result->getCountry()->getCode());
168168
$this->assertNull($result->getTimezone());
169169
}
170170

171171
public function testGeocodeWithRealAddressReturnsMultipleResults()
172172
{
173-
if (!isset($_SERVER['TOMTOM_GEOCODING_KEY'])) {
174-
$this->markTestSkipped('You need to configure the TOMTOM_GEOCODING_KEY value in phpunit.xml');
173+
if (!isset($_SERVER['TOMTOM_MAP_KEY'])) {
174+
$this->markTestSkipped('You need to configure the TOMTOM_MAP_KEY value in phpunit.xml');
175175
}
176176

177-
$provider = new TomTom($this->getAdapter(), $_SERVER['TOMTOM_GEOCODING_KEY']);
177+
$provider = new TomTom($this->getAdapter(), $_SERVER['TOMTOM_MAP_KEY']);
178178
$results = $provider->geocode('Paris');
179179

180180
$this->assertInternalType('array', $results);

0 commit comments

Comments
 (0)