Skip to content

Commit 491b29b

Browse files
Krystof BernatKrystof Bernat
authored andcommitted
Added test for municipality in AzureMaps provider
1 parent f1f3e7f commit 491b29b

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/Provider/AzureMaps/Tests/AzureMapsTest.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,4 +93,26 @@ public function testReverseWithRealCoordinates(): void
9393
$this->assertEquals('Israel', $result->getCountry()->getName());
9494
$this->assertEquals('IL', $result->getCountry()->getCode());
9595
}
96+
97+
public function testGeocodeIncludesMunicipality(): void
98+
{
99+
if (!isset($_SERVER['AZURE_MAPS_SUBSCRIPTION_KEY'])) {
100+
$this->markTestSkipped('You need to configure the AZURE_MAPS_SUBSCRIPTION_KEY value in phpunit.xml');
101+
}
102+
103+
$subscriptionKey = $_SERVER['AZURE_MAPS_SUBSCRIPTION_KEY'];
104+
$provider = new AzureMaps($this->getHttpClient($subscriptionKey), $subscriptionKey);
105+
106+
$results = $provider->geocodeQuery(GeocodeQuery::create('Via Giuseppe Garibaldi 62, IT, Italy'));
107+
108+
$this->assertInstanceOf(AddressCollection::class, $results);
109+
$this->assertGreaterThan(0, $results->count(), 'No results found');
110+
111+
$result = $results->first();
112+
113+
$this->assertInstanceOf(Address::class, $result);
114+
$this->assertNotNull($result->getLocality(), 'Municipality (city) is missing in the response');
115+
$this->assertEquals('Rome', $result->getLocality());
116+
}
117+
96118
}

0 commit comments

Comments
 (0)