You are here

public function GeofieldFormatterTest::testDefaultFormatter in Geofield 8

Tests geofield field default formatter.

File

tests/src/Kernel/GeofieldFormatterTest.php, line 68

Class

GeofieldFormatterTest
Tests the geofield formatters functionality.

Namespace

Drupal\Tests\geofield\Kernel

Code

public function testDefaultFormatter() {

  // Create the entity to be referenced.
  $entity = EntityTest::create([
    'name' => $this
      ->randomMachineName(),
  ]);
  $value = \Drupal::service('geofield.wkt_generator')
    ->WktGenerateGeometry();
  $entity->geofield = [
    'value' => $value,
  ];
  $entity
    ->save();

  // Verify the geofield field formatter's render array.
  $build = $entity
    ->get('geofield')
    ->view([
    'type' => 'geofield_default',
  ]);
  \Drupal::service('renderer')
    ->renderRoot($build[0]);
  $this
    ->assertEquals($value, $build[0]['#markup']);
}