You are here

public function MethodsTests::testMethods in geoPHP 8

Same name and namespace in other branches
  1. 7 geoPHP/tests/tests/methodsTest.php \MethodsTests::testMethods()

File

geoPHP/tests/tests/methodsTest.php, line 20

Class

MethodsTests

Code

public function testMethods() {
  foreach (scandir('./input') as $file) {
    $parts = explode('.', $file);
    if ($parts[0]) {
      $format = $parts[1];
      $value = file_get_contents('./input/' . $file);
      $geometry = geoPHP::load($value, $format);
      $methods = [
        [
          'name' => 'area',
        ],
        [
          'name' => 'boundary',
        ],
        [
          'name' => 'getBBox',
        ],
        [
          'name' => 'centroid',
        ],
        [
          'name' => 'length',
        ],
        [
          'name' => 'greatCircleLength',
        ],
        [
          'name' => 'haversineLength',
        ],
        [
          'name' => 'y',
        ],
        [
          'name' => 'x',
        ],
        [
          'name' => 'numGeometries',
        ],
        [
          'name' => 'geometryN',
          'argument' => '1',
        ],
        [
          'name' => 'startPoint',
        ],
        [
          'name' => 'endPoint',
        ],
        [
          'name' => 'isRing',
        ],
        [
          'name' => 'isClosed',
        ],
        [
          'name' => 'numPoints',
        ],
        [
          'name' => 'pointN',
          'argument' => '1',
        ],
        [
          'name' => 'exteriorRing',
        ],
        [
          'name' => 'numInteriorRings',
        ],
        [
          'name' => 'interiorRingN',
          'argument' => '1',
        ],
        [
          'name' => 'dimension',
        ],
        [
          'name' => 'geometryType',
        ],
        [
          'name' => 'SRID',
        ],
        [
          'name' => 'setSRID',
          'argument' => '4326',
        ],
      ];
      foreach ($methods as $method) {
        $argument = NULL;
        $method_name = $method['name'];
        if (isset($method['argument'])) {
          $argument = $method['argument'];
        }
        $this
          ->_methods_tester($geometry, $method_name, $argument);
      }
      $this
        ->_methods_tester_with_geos($geometry);
    }
  }
}