GeolocationGoogleMapsGeocodingTest.php in Geolocation Field 8.3
File
modules/geolocation_google_maps/tests/src/Functional/GeolocationGoogleMapsGeocodingTest.php
View source
<?php
namespace Drupal\Tests\geolocation_google_maps\Functional;
use Drupal\Tests\BrowserTestBase;
class GeolocationGoogleMapsGeocodingTest extends BrowserTestBase {
public static $modules = [
'geolocation',
'geolocation_google_maps',
'geolocation_google_maps_test',
];
protected $defaultTheme = 'stark';
public function testGeocoder() {
$geocoder = \Drupal::service('plugin.manager.geolocation.geocoder')
->getGeocoder('google_geocoding_api');
$location = $geocoder
->geocode('H.Congreso de la Unión 66, El Parque, Venustiano Carranza, 15960 Ciudad de México, CDMX, Mexiko');
$this
->assertArrayHasKey('location', $location);
}
public function testReverseGeocoder() {
$geocoder = \Drupal::service('plugin.manager.geolocation.geocoder')
->getGeocoder('google_geocoding_api');
$latitude = 38.56;
$longitude = 68.773889;
$address = $geocoder
->reverseGeocode($latitude, $longitude);
$this
->assertArrayHasKey('atomics', $address);
}
}