You are here

public function WktGeneratorTest::testRandomGeometry in Geofield 8

Tests the generation of random WKT geometries.

File

tests/src/Kernel/WktGeneratorTest.php, line 147

Class

WktGeneratorTest
Tests WktGenerator.

Namespace

Drupal\Tests\geofield\Kernel

Code

public function testRandomGeometry() {
  $find = FALSE;
  $geometry = $this->wktGenerator
    ->wktGenerateGeometry();
  $patterns = [
    $this->pointRegex,
    $this->multipointRegex,
    $this->linestringRegex,
    $this->multilinestringRegex,
    $this->polygonRegex,
    $this->multipolygonRegex,
  ];
  foreach ($patterns as $pattern) {
    if (preg_match($pattern, $geometry)) {
      $find = TRUE;
      break;
    }
  }
  $this
    ->assertTrue($find, 'Random geometry generated properly');
}