Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/Endpoint/GeocodingEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class GeocodingEndpoint extends AbstractEndpoint
* @throws UnexpectedErrorException
* @throws ValidationException
*/
public function getCoordinatesByLocationName(string $locationName, int $numResults = self::NUM_RESULTS): array
public function getByLocationName(string $locationName, int $numResults = self::NUM_RESULTS): array
{
$this->validateBlank('locationName', $locationName);
$this->validateGreaterThan('numResults', $numResults, 0);
Expand All @@ -69,7 +69,7 @@ public function getCoordinatesByLocationName(string $locationName, int $numResul
* @throws UnexpectedErrorException
* @throws ValidationException
*/
public function getCoordinatesByZipCode(string $zipCode, string $countryCode): ZipCodeLocation
public function getByZipCode(string $zipCode, string $countryCode): ZipCodeLocation
{
$this->validateBlank('zipCode', $zipCode);
$this->validateBlank('countryCode', $countryCode);
Expand All @@ -95,7 +95,7 @@ public function getCoordinatesByZipCode(string $zipCode, string $countryCode): Z
* @throws UnexpectedErrorException
* @throws ValidationException
*/
public function getLocationNameByCoordinates(float $latitude, float $longitude, int $numResults = self::NUM_RESULTS): array
public function getByCoordinate(float $latitude, float $longitude, int $numResults = self::NUM_RESULTS): array
{
$this->validateCoordinate($latitude, $longitude);
$this->validateGreaterThan('numResults', $numResults, 0);
Expand Down
32 changes: 16 additions & 16 deletions tests/GeocodingEndpointTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

class GeocodingEndpointTest extends AbstractTest
{
public function testGeocodingGetCoordinatesByLocationName()
public function testGeocodingGetByLocationName()
{
$this->mockHttpClient->addResponse(
new Response(
Expand All @@ -22,17 +22,17 @@ public function testGeocodingGetCoordinatesByLocationName()
)
);

$response = $this->getApi()->getGeocoding()->getCoordinatesByLocationName('lisbon, pt');
$response = $this->getApi()->getGeocoding()->getByLocationName('lisbon, pt');
$this->assertLocationListResponse($response);
}

public function testGeocodingGetCoordinatesByLocationNameWithBlankValue()
public function testGeocodingGetByLocationNameWithBlankValue()
{
$this->expectException(ValidationException::class);
$this->getApi()->getGeocoding()->getCoordinatesByLocationName('');
$this->getApi()->getGeocoding()->getByLocationName('');
}

public function testGeocodingGetCoordinatesByZipCode()
public function testGeocodingGetByZipCode()
{
$this->mockHttpClient->addResponse(
new Response(
Expand All @@ -41,7 +41,7 @@ public function testGeocodingGetCoordinatesByZipCode()
)
);

$response = $this->getApi()->getGeocoding()->getCoordinatesByZipCode('1000-001', 'pt');
$response = $this->getApi()->getGeocoding()->getByZipCode('1000-001', 'pt');
$this->assertInstanceOf(ZipCodeLocation::class, $response);

$this->assertSame('1000-001', $response->getZipCode());
Expand All @@ -54,20 +54,20 @@ public function testGeocodingGetCoordinatesByZipCode()
$this->assertSame(-9.1333, $coordinate->getLongitude());
}

#[DataProvider('provideGeocodingGetCoordinatesByZipCodeWithBlankValueData')]
public function testGeocodingGetCoordinatesByZipCodeWithBlankValue(string $zipCode, string $countryCode)
#[DataProvider('provideGeocodingGetByZipCodeWithBlankValueData')]
public function testGeocodingGetByZipCodeWithBlankValue(string $zipCode, string $countryCode)
{
$this->expectException(ValidationException::class);
$this->getApi()->getGeocoding()->getCoordinatesByZipCode($zipCode, $countryCode);
$this->getApi()->getGeocoding()->getByZipCode($zipCode, $countryCode);
}

public static function provideGeocodingGetCoordinatesByZipCodeWithBlankValueData(): \Generator
public static function provideGeocodingGetByZipCodeWithBlankValueData(): \Generator
{
yield 'blank zip code' => ['', 'pt'];
yield 'blank country code' => ['1000-100', ''];
}

public function testGeocodingGetLocationNameByCoordinates()
public function testGeocodingGetByCoordinate()
{
$this->mockHttpClient->addResponse(
new Response(
Expand All @@ -76,29 +76,29 @@ public function testGeocodingGetLocationNameByCoordinates()
)
);

$response = $this->getApi()->getGeocoding()->getLocationNameByCoordinates(38.7077507, -9.1365919);
$response = $this->getApi()->getGeocoding()->getByCoordinate(38.7077507, -9.1365919);
$this->assertLocationListResponse($response);
}

#[DataProviderExternal(InvalidParamDataProvider::class, 'provideInvalidCoordinateData')]
public function testGeocodingGetLocationNameByCoordinatesWithInvalidCoordinate(
public function testGeocodingGetByCoordinateWithInvalidCoordinate(
float $latitude,
float $longitude,
string $expectedException
)
{
$this->expectException($expectedException);
$this->getApi()->getGeocoding()->getLocationNameByCoordinates($latitude, $longitude);
$this->getApi()->getGeocoding()->getByCoordinate($latitude, $longitude);
}

#[DataProviderExternal(InvalidParamDataProvider::class, 'provideInvalidNumResultsData')]
public function testGeocodingGetLocationNameByCoordinatesWithInvalidNumResults(
public function testGeocodingGetByCoordinateWithInvalidNumResults(
int $numResults,
string $expectedException
)
{
$this->expectException($expectedException);
$this->getApi()->getGeocoding()->getLocationNameByCoordinates(38.7077507, -9.1365919, $numResults);
$this->getApi()->getGeocoding()->getByCoordinate(38.7077507, -9.1365919, $numResults);
}

/**
Expand Down