You are here

class PlaceholdersTests in geoPHP 8

Same name and namespace in other branches
  1. 7 geoPHP/tests/tests/placeholdersTest.php \PlaceholdersTests

Hierarchy

Expanded class hierarchy of PlaceholdersTests

File

geoPHP/tests/tests/placeholdersTest.php, line 8

View source
class PlaceholdersTests extends PHPUnit_Framework_TestCase {

  /**
   *
   */
  public function setUp() {
  }

  /**
   *
   */
  public function testPlaceholders() {
    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);
        $placeholders = [
          [
            'name' => 'hasZ',
          ],
          [
            'name' => 'is3D',
          ],
          [
            'name' => 'isMeasured',
          ],
          [
            'name' => 'isEmpty',
          ],
          [
            'name' => 'coordinateDimension',
          ],
          [
            'name' => 'z',
          ],
          [
            'name' => 'm',
          ],
        ];
        foreach ($placeholders as $method) {
          $argument = NULL;
          $method_name = $method['name'];
          if (isset($method['argument'])) {
            $argument = $method['argument'];
          }
          switch ($method_name) {
            case 'm':
            case 'z':
              if ($geometry
                ->geometryType() == 'Point') {
                $this
                  ->assertNotNull($geometry
                  ->{$method_name}($argument), 'Failed on ' . $method_name);
              }
              if ($geometry
                ->geometryType() == 'LineString') {
                $this
                  ->assertNotNull($geometry
                  ->{$method_name}($argument), 'Failed on ' . $method_name);
              }
              if ($geometry
                ->geometryType() == 'MultiLineString') {
                $this
                  ->assertNull($geometry
                  ->{$method_name}($argument), 'Failed on ' . $method_name);
              }
              break;
            case 'coordinateDimension':
            case 'isEmpty':
            case 'isMeasured':
            case 'is3D':
            case 'hasZ':
              if ($geometry
                ->geometryType() == 'Point') {
                $this
                  ->assertNotNull($geometry
                  ->{$method_name}($argument), 'Failed on ' . $method_name);
              }
              if ($geometry
                ->geometryType() == 'LineString') {
                $this
                  ->assertNotNull($geometry
                  ->{$method_name}($argument), 'Failed on ' . $method_name);
              }
              if ($geometry
                ->geometryType() == 'MultiLineString') {
                $this
                  ->assertNotNull($geometry
                  ->{$method_name}($argument), 'Failed on ' . $method_name);
              }
              break;
            default:
              $this
                ->assertTrue($geometry
                ->{$method_name}($argument), 'Failed on ' . $method_name);
          }
        }
      }
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
PlaceholdersTests::setUp public function Sets up the fixture, for example, open a network connection. This method is called before a test is executed.
PlaceholdersTests::testPlaceholders public function