Skip to content

Commit

Permalink
Added test for municipality in AzureMaps provider
Browse files Browse the repository at this point in the history
  • Loading branch information
Krystof Bernat authored and Krystof Bernat committed Feb 17, 2025
1 parent f1f3e7f commit 491b29b
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/Provider/AzureMaps/Tests/AzureMapsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,26 @@ public function testReverseWithRealCoordinates(): void
$this->assertEquals('Israel', $result->getCountry()->getName());
$this->assertEquals('IL', $result->getCountry()->getCode());
}

public function testGeocodeIncludesMunicipality(): void
{
if (!isset($_SERVER['AZURE_MAPS_SUBSCRIPTION_KEY'])) {
$this->markTestSkipped('You need to configure the AZURE_MAPS_SUBSCRIPTION_KEY value in phpunit.xml');
}

$subscriptionKey = $_SERVER['AZURE_MAPS_SUBSCRIPTION_KEY'];
$provider = new AzureMaps($this->getHttpClient($subscriptionKey), $subscriptionKey);

$results = $provider->geocodeQuery(GeocodeQuery::create('Via Giuseppe Garibaldi 62, IT, Italy'));

$this->assertInstanceOf(AddressCollection::class, $results);
$this->assertGreaterThan(0, $results->count(), 'No results found');

$result = $results->first();

$this->assertInstanceOf(Address::class, $result);
$this->assertNotNull($result->getLocality(), 'Municipality (city) is missing in the response');
$this->assertEquals('Rome', $result->getLocality());
}

}

0 comments on commit 491b29b

Please sign in to comment.