You are here

public function GeolocationSchemaCoverageTest::testMapProvidersWithMapFeatures in Geolocation Field 8.3

Test MapFeatures with providers.

File

tests/src/Functional/GeolocationSchemaCoverageTest.php, line 64

Class

GeolocationSchemaCoverageTest
Tests the grid style plugin.

Namespace

Drupal\Tests\geolocation\Functional

Code

public function testMapProvidersWithMapFeatures() {

  /** @var \Drupal\geolocation\MapFeatureManager $mapFeatureManager */
  $mapFeatureManager = \Drupal::service('plugin.manager.geolocation.mapfeature');

  /** @var \Drupal\geolocation\MapProviderManager $mapProviderManager */
  $mapProviderManager = \Drupal::service('plugin.manager.geolocation.mapprovider');
  $view = View::load('geolocation_demo_common_map');
  foreach ($mapProviderManager
    ->getDefinitions() as $mapProviderId => $definition) {
    $mapProvider = $mapProviderManager
      ->getMapProvider($mapProviderId);
    $display =& $view
      ->getDisplay('default');
    $display['display_options']['style']['options']['map_provider_id'] = $mapProviderId;
    $display['display_options']['style']['options']['map_provider_settings'] = $mapProvider
      ->getSettings([]);
    $display['display_options']['style']['options']['map_provider_settings']['map_features'] = [];
    foreach ($mapFeatureManager
      ->getMapFeaturesByMapType($mapProviderId) as $mapFeatureId => $mapFeatureDefinition) {
      $mapFeature = $mapFeatureManager
        ->getMapFeature($mapFeatureId);
      $display['display_options']['style']['options']['map_provider_settings']['map_features'][$mapFeatureId] = [
        'enabled' => TRUE,
        'settings' => $mapFeature
          ->getSettings([]),
      ];
    }
    $view
      ->save();
    $this
      ->drupalGet('geolocation-demo/common-map');
    $this
      ->assertSession()
      ->statusCodeEquals(200);
  }
}