Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit aceace0

Browse files
committed
Update BingMapsTest
1 parent 7eef54e commit aceace0

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

tests/Geocoder/Tests/Provider/BingMapsTest.php

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public function testGeocodeWithAddressGetsNullContent()
8585
public function testGeocodeReturnsMultipleResults()
8686
{
8787
$json = <<<JSON
88-
{"authenticationResultCode":"ValidCredentials","brandLogoUri":"http:\/\/dev.virtualearth.net\/Branding\/logo_powered_by.png","copyright":"Copyright © 2013 Microsoft and its suppliers. All rights reserved. This API cannot be accessed and the content and any results may not be used, reproduced or transmitted in any manner without express written permission from Microsoft Corporation.","resourceSets":[{"estimatedTotal":3,"resources":[{"__type":"Location:http:\/\/schemas.microsoft.com\/search\/local\/ws\/rest\/v1","bbox":[48.859354042429317,2.3809438666389395,48.86707947757067,2.3966003933610596],"name":"10 Avenue Gambetta, 75020 Paris","point":{"type":"Point","coordinates":[48.863216759999993,2.3887721299999995]},"address":{"addressLine":"10 Avenue Gambetta","adminDistrict":"IdF","adminDistrict2":"Paris","countryRegion":"France","formattedAddress":"10 Avenue Gambetta, 75020 Paris","locality":"Paris","postalCode":"75020"},"confidence":"Medium","entityType":"Address","geocodePoints":[{"type":"Point","coordinates":[48.863216759999993,2.3887721299999995],"calculationMethod":"Interpolation","usageTypes":["Display","Route"]}],"matchCodes":["Ambiguous","Good"]},{"__type":"Location:http:\/\/schemas.microsoft.com\/search\/local\/ws\/rest\/v1","bbox":[48.809565092429317,2.3172171827738461,48.81729052757067,2.3328581572261538],"name":"10 Avenue Léon Gambetta, 92120 Montrouge","point":{"type":"Point","coordinates":[48.813427809999993,2.32503767]},"address":{"addressLine":"10 Avenue Léon Gambetta","adminDistrict":"IdF","adminDistrict2":"Hauts-de-Seine","countryRegion":"France","formattedAddress":"10 Avenue Léon Gambetta, 92120 Montrouge","locality":"Montrouge","postalCode":"92120"},"confidence":"Medium","entityType":"Address","geocodePoints":[{"type":"Point","coordinates":[48.813427809999993,2.32503767],"calculationMethod":"Interpolation","usageTypes":["Display","Route"]}],"matchCodes":["Ambiguous","Good"]},{"__type":"Location:http:\/\/schemas.microsoft.com\/search\/local\/ws\/rest\/v1","bbox":[48.806278752429328,2.4278605052896745,48.814004187570681,2.4435004547103261],"name":"10 Avenue Gambetta, 94700 Maisons-Alfort","point":{"type":"Point","coordinates":[48.810141470000005,2.4356804800000003]},"address":{"addressLine":"10 Avenue Gambetta","adminDistrict":"IdF","adminDistrict2":"Val-De-Marne","countryRegion":"France","formattedAddress":"10 Avenue Gambetta, 94700 Maisons-Alfort","locality":"Maisons-Alfort","postalCode":"94700"},"confidence":"Medium","entityType":"Address","geocodePoints":[{"type":"Point","coordinates":[48.810141470000005,2.4356804800000003],"calculationMethod":"Interpolation","usageTypes":["Display","Route"]}],"matchCodes":["Ambiguous","Good"]}]}],"statusCode":200,"statusDescription":"OK","traceId":"fd9b0b8fe1a34ad384923b5d0937bfb2|AMSM001404|02.00.139.700|AMSMSNVM002409, AMSMSNVM001862, AMSMSNVM001322, AMSMSNVM000044"}
88+
{"authenticationResultCode":"ValidCredentials","brandLogoUri":"http:\/\/dev.virtualearth.net\/Branding\/logo_powered_by.png","copyright":"Copyright © 2013 Microsoft and its suppliers. All rights reserved. This API cannot be accessed and the content and any results may not be used, reproduced or transmitted in any manner without express written permission from Microsoft Corporation.","resourceSets":[{"estimatedTotal":3,"resources":[{"__type":"Location:http:\/\/schemas.microsoft.com\/search\/local\/ws\/rest\/v1","bbox":[48.859354042429317,2.3809438666389395,48.86707947757067,2.3966003933610596],"name":"10 Avenue Gambetta, 75020 Paris","point":{"type":"Point","coordinates":[48.863216759999993,2.3887721299999995]},"address":{"addressLine":"10 Avenue Gambetta","adminDistrict":"IdF","adminDistrict2":"Paris","countryRegion":"France","countryRegionIso2":"FR","formattedAddress":"10 Avenue Gambetta, 75020 Paris","locality":"Paris","postalCode":"75020"},"confidence":"Medium","entityType":"Address","geocodePoints":[{"type":"Point","coordinates":[48.863216759999993,2.3887721299999995],"calculationMethod":"Interpolation","usageTypes":["Display","Route"]}],"matchCodes":["Ambiguous","Good"]},{"__type":"Location:http:\/\/schemas.microsoft.com\/search\/local\/ws\/rest\/v1","bbox":[48.809565092429317,2.3172171827738461,48.81729052757067,2.3328581572261538],"name":"10 Avenue Léon Gambetta, 92120 Montrouge","point":{"type":"Point","coordinates":[48.813427809999993,2.32503767]},"address":{"addressLine":"10 Avenue Léon Gambetta","adminDistrict":"IdF","adminDistrict2":"Hauts-de-Seine","countryRegion":"France","countryRegionIso2":"FR","formattedAddress":"10 Avenue Léon Gambetta, 92120 Montrouge","locality":"Montrouge","postalCode":"92120"},"confidence":"Medium","entityType":"Address","geocodePoints":[{"type":"Point","coordinates":[48.813427809999993,2.32503767],"calculationMethod":"Interpolation","usageTypes":["Display","Route"]}],"matchCodes":["Ambiguous","Good"]},{"__type":"Location:http:\/\/schemas.microsoft.com\/search\/local\/ws\/rest\/v1","bbox":[48.806278752429328,2.4278605052896745,48.814004187570681,2.4435004547103261],"name":"10 Avenue Gambetta, 94700 Maisons-Alfort","point":{"type":"Point","coordinates":[48.810141470000005,2.4356804800000003]},"address":{"addressLine":"10 Avenue Gambetta","adminDistrict":"IdF","adminDistrict2":"Val-De-Marne","countryRegion":"France","countryRegionIso2":"FR","formattedAddress":"10 Avenue Gambetta, 94700 Maisons-Alfort","locality":"Maisons-Alfort","postalCode":"94700"},"confidence":"Medium","entityType":"Address","geocodePoints":[{"type":"Point","coordinates":[48.810141470000005,2.4356804800000003],"calculationMethod":"Interpolation","usageTypes":["Display","Route"]}],"matchCodes":["Ambiguous","Good"]}]}],"statusCode":200,"statusDescription":"OK","traceId":"fd9b0b8fe1a34ad384923b5d0937bfb2|AMSM001404|02.00.139.700|AMSMSNVM002409, AMSMSNVM001862, AMSMSNVM001322, AMSMSNVM000044"}
8989
JSON;
9090

9191
$provider = new BingMaps($this->getMockAdapterReturns($json), 'api_key', 'fr_FR');
@@ -112,8 +112,8 @@ public function testGeocodeReturnsMultipleResults()
112112
$this->assertEquals('Paris', $result->getAdminLevels()->get(2)->getName());
113113
$this->assertEquals('IdF', $result->getAdminLevels()->get(1)->getName());
114114
$this->assertEquals('France', $result->getCountry()->getName());
115+
$this->assertEquals('FR', $result->getCountry()->getCode());
115116

116-
$this->assertNull($result->getCountry()->getCode());
117117
$this->assertNull($result->getTimezone());
118118

119119
/** @var \Geocoder\Model\Address $result */
@@ -134,6 +134,7 @@ public function testGeocodeReturnsMultipleResults()
134134
$this->assertEquals('Hauts-de-Seine', $result->getAdminLevels()->get(2)->getName());
135135
$this->assertEquals('IdF', $result->getAdminLevels()->get(1)->getName());
136136
$this->assertEquals('France', $result->getCountry()->getName());
137+
$this->assertEquals('FR', $result->getCountry()->getCode());
137138

138139
/** @var \Geocoder\Model\Address $result */
139140
$result = $results->get(2);
@@ -153,12 +154,13 @@ public function testGeocodeReturnsMultipleResults()
153154
$this->assertEquals('Val-De-Marne', $result->getAdminLevels()->get(2)->getName());
154155
$this->assertEquals('IdF', $result->getAdminLevels()->get(1)->getName());
155156
$this->assertEquals('France', $result->getCountry()->getName());
157+
$this->assertEquals('FR', $result->getCountry()->getCode());
156158
}
157159

158160
public function testReverseReturnsSingleResult()
159161
{
160162
$json = <<<JSON
161-
{"authenticationResultCode":"ValidCredentials","brandLogoUri":"http:\/\/dev.virtualearth.net\/Branding\/logo_powered_by.png","copyright":"Copyright © 2013 Microsoft and its suppliers. All rights reserved. This API cannot be accessed and the content and any results may not be used, reproduced or transmitted in any manner without express written permission from Microsoft Corporation.","resourceSets":[{"estimatedTotal":1,"resources":[{"__type":"Location:http:\/\/schemas.microsoft.com\/search\/local\/ws\/rest\/v1","bbox":[48.859353771982775,2.3809437325832983,48.867079207124128,2.3966002592208246],"name":"10 Avenue Gambetta, 75020 20e Arrondissement","point":{"type":"Point","coordinates":[48.863216489553452,2.3887719959020615]},"address":{"addressLine":"10 Avenue Gambetta","adminDistrict":"IdF","adminDistrict2":"Paris","countryRegion":"France","formattedAddress":"10 Avenue Gambetta, 75020 20e Arrondissement","locality":"20e Arrondissement","postalCode":"75020"},"confidence":"Medium","entityType":"Address","geocodePoints":[{"type":"Point","coordinates":[48.863216489553452,2.3887719959020615],"calculationMethod":"Interpolation","usageTypes":["Display","Route"]}],"matchCodes":["Good"]}]}],"statusCode":200,"statusDescription":"OK","traceId":"0691dabd257043b381b678fbfaf799dd|AMSM001401|02.00.139.700|AMSMSNVM001951, AMSMSNVM002152"}
163+
{"authenticationResultCode":"ValidCredentials","brandLogoUri":"http:\/\/dev.virtualearth.net\/Branding\/logo_powered_by.png","copyright":"Copyright © 2013 Microsoft and its suppliers. All rights reserved. This API cannot be accessed and the content and any results may not be used, reproduced or transmitted in any manner without express written permission from Microsoft Corporation.","resourceSets":[{"estimatedTotal":1,"resources":[{"__type":"Location:http:\/\/schemas.microsoft.com\/search\/local\/ws\/rest\/v1","bbox":[48.859353771982775,2.3809437325832983,48.867079207124128,2.3966002592208246],"name":"10 Avenue Gambetta, 75020 20e Arrondissement","point":{"type":"Point","coordinates":[48.863216489553452,2.3887719959020615]},"address":{"addressLine":"10 Avenue Gambetta","adminDistrict":"IdF","adminDistrict2":"Paris","countryRegion":"France","countryRegionIso2":"FR","formattedAddress":"10 Avenue Gambetta, 75020 20e Arrondissement","locality":"20e Arrondissement","postalCode":"75020"},"confidence":"Medium","entityType":"Address","geocodePoints":[{"type":"Point","coordinates":[48.863216489553452,2.3887719959020615],"calculationMethod":"Interpolation","usageTypes":["Display","Route"]}],"matchCodes":["Good"]}]}],"statusCode":200,"statusDescription":"OK","traceId":"0691dabd257043b381b678fbfaf799dd|AMSM001401|02.00.139.700|AMSMSNVM001951, AMSMSNVM002152"}
162164
JSON;
163165

164166
$provider = new BingMaps($this->getMockAdapterReturns($json), 'api_key');
@@ -185,8 +187,8 @@ public function testReverseReturnsSingleResult()
185187
$this->assertEquals('Paris', $result->getAdminLevels()->get(2)->getName());
186188
$this->assertEquals('IdF', $result->getAdminLevels()->get(1)->getName());
187189
$this->assertEquals('France', $result->getCountry()->getName());
190+
$this->assertEquals('FR', $result->getCountry()->getCode());
188191

189-
$this->assertNull($result->getCountry()->getCode());
190192
$this->assertNull($result->getTimezone());
191193
}
192194

@@ -220,10 +222,10 @@ public function testGeocodeWithRealAddressReturnsSingleResults()
220222
$this->assertEquals('Paris', $result->getAdminLevels()->get(2)->getName());
221223
$this->assertEquals('IdF', $result->getAdminLevels()->get(1)->getName());
222224
$this->assertEquals('France', $result->getCountry()->getName());
225+
$this->assertEquals('FR', $result->getCountry()->getCode());
223226

224227
$this->assertNull($result->getAdminLevels()->get(2)->getCode());
225228
$this->assertNull($result->getAdminLevels()->get(1)->getCode());
226-
$this->assertNull($result->getCountry()->getCode());
227229
$this->assertNull($result->getTimezone());
228230

229231
}
@@ -258,6 +260,7 @@ public function testGeocodeWithRealAddressReturnsMultipleResults()
258260
$this->assertEquals('AT', $result->getAdminLevels()->get(2)->getName());
259261
$this->assertEquals('Piem.', $result->getAdminLevels()->get(1)->getName());
260262
$this->assertEquals('Italie', $result->getCountry()->getName());
263+
$this->assertEquals('IT', $result->getCountry()->getCode());
261264

262265
/** @var \Geocoder\Model\Address $result */
263266
$result = $results->get(1);
@@ -277,6 +280,7 @@ public function testGeocodeWithRealAddressReturnsMultipleResults()
277280
$this->assertEquals('TN', $result->getAdminLevels()->get(2)->getName());
278281
$this->assertEquals('Tr.A.A.', $result->getAdminLevels()->get(1)->getName());
279282
$this->assertEquals('Italie', $result->getCountry()->getName());
283+
$this->assertEquals('IT', $result->getCountry()->getCode());
280284

281285
/** @var \Geocoder\Model\Address $result */
282286
$result = $results->get(2);
@@ -296,6 +300,7 @@ public function testGeocodeWithRealAddressReturnsMultipleResults()
296300
$this->assertEquals('PC', $result->getAdminLevels()->get(2)->getName());
297301
$this->assertEquals('Em.Rom.', $result->getAdminLevels()->get(1)->getName());
298302
$this->assertEquals('Italie', $result->getCountry()->getName());
303+
$this->assertEquals('IT', $result->getCountry()->getCode());
299304

300305
/** @var \Geocoder\Model\Address $result */
301306
$result = $results->get(3);
@@ -315,6 +320,7 @@ public function testGeocodeWithRealAddressReturnsMultipleResults()
315320
$this->assertEquals('PO', $result->getAdminLevels()->get(2)->getName());
316321
$this->assertEquals('Tosc.', $result->getAdminLevels()->get(1)->getName());
317322
$this->assertEquals('Italie', $result->getCountry()->getName());
323+
$this->assertEquals('IT', $result->getCountry()->getCode());
318324

319325
/** @var \Geocoder\Model\Address $result */
320326
$result = $results->get(4);
@@ -334,6 +340,7 @@ public function testGeocodeWithRealAddressReturnsMultipleResults()
334340
$this->assertEquals('AQ', $result->getAdminLevels()->get(2)->getName());
335341
$this->assertEquals('Abr.', $result->getAdminLevels()->get(1)->getName());
336342
$this->assertEquals('Italie', $result->getCountry()->getName());
343+
$this->assertEquals('IT', $result->getCountry()->getCode());
337344
}
338345

339346
/**
@@ -386,8 +393,8 @@ public function testReverseWithRealCoordinatesReturnsSingleResult()
386393
$this->assertEquals('Paris', $result->getAdminLevels()->get(2)->getName());
387394
$this->assertEquals('IdF', $result->getAdminLevels()->get(1)->getName());
388395
$this->assertEquals('France', $result->getCountry()->getName());
396+
$this->assertEquals('FR', $result->getCountry()->getCode());
389397

390-
$this->assertNull($result->getCountry()->getCode());
391398
$this->assertNull($result->getTimezone());
392399
}
393400

0 commit comments

Comments
 (0)