function Tests_20120702::_methods_tester in geoPHP 7
Same name and namespace in other branches
- 8 geoPHP/tests/tests/20120702Test.php \Tests_20120702::_methods_tester()
1 call to Tests_20120702::_methods_tester()
- Tests_20120702::testMethods in geoPHP/
tests/ tests/ 20120702Test.php
File
- geoPHP/
tests/ tests/ 20120702Test.php, line 51
Class
Code
function _methods_tester($geometry, $method_name, $argument) {
if (!method_exists($geometry, $method_name)) {
$this
->fail("Method " . $method_name . '() doesn\'t exists.');
return;
}
switch ($method_name) {
case 'y':
case 'x':
if ($geometry
->geometryType() == 'Point') {
$this
->assertNotNull($geometry
->{$method_name}($argument), 'Failed on ' . $method_name);
}
if ($geometry
->geometryType() == 'LineString') {
$this
->assertNull($geometry
->{$method_name}($argument), 'Failed on ' . $method_name);
}
if ($geometry
->geometryType() == 'MultiLineString') {
$this
->assertNull($geometry
->{$method_name}($argument), 'Failed on ' . $method_name);
}
break;
case 'geometryN':
if ($geometry
->geometryType() == 'Point') {
$this
->assertNull($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;
case 'startPoint':
if ($geometry
->geometryType() == 'Point') {
$this
->assertNull($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') {
//TODO: Add a method startPoint() to MultiLineString.
//$this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
}
break;
case 'endPoint':
if ($geometry
->geometryType() == 'Point') {
$this
->assertNull($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') {
//TODO: Add a method endPoint() to MultiLineString.
//$this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
}
break;
case 'isRing':
if ($geometry
->geometryType() == 'Point') {
$this
->assertNull($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 'isClosed':
if ($geometry
->geometryType() == 'Point') {
$this
->assertNull($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;
case 'pointN':
if ($geometry
->geometryType() == 'Point') {
$this
->assertNull($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') {
//TODO: Add a method pointN() to MultiLineString.
//$this->assertNotNull($geometry->$method_name($argument), 'Failed on ' . $method_name);
}
break;
case 'exteriorRing':
if ($geometry
->geometryType() == 'Point') {
$this
->assertNull($geometry
->{$method_name}($argument), 'Failed on ' . $method_name);
}
if ($geometry
->geometryType() == 'LineString') {
$this
->assertNull($geometry
->{$method_name}($argument), 'Failed on ' . $method_name);
}
if ($geometry
->geometryType() == 'MultiLineString') {
$this
->assertNull($geometry
->{$method_name}($argument), 'Failed on ' . $method_name);
}
break;
case 'numInteriorRings':
if ($geometry
->geometryType() == 'Point') {
$this
->assertNull($geometry
->{$method_name}($argument), 'Failed on ' . $method_name);
}
if ($geometry
->geometryType() == 'LineString') {
$this
->assertNull($geometry
->{$method_name}($argument), 'Failed on ' . $method_name);
}
if ($geometry
->geometryType() == 'MultiLineString') {
$this
->assertNull($geometry
->{$method_name}($argument), 'Failed on ' . $method_name);
}
break;
case 'interiorRingN':
if ($geometry
->geometryType() == 'Point') {
$this
->assertNull($geometry
->{$method_name}($argument), 'Failed on ' . $method_name);
}
if ($geometry
->geometryType() == 'LineString') {
$this
->assertNull($geometry
->{$method_name}($argument), 'Failed on ' . $method_name);
}
if ($geometry
->geometryType() == 'MultiLineString') {
$this
->assertNull($geometry
->{$method_name}($argument), 'Failed on ' . $method_name);
}
break;
case 'setSRID':
//TODO: The method setSRID() should return TRUE.
break;
case 'SRID':
if ($geometry
->geometryType() == 'Point') {
$this
->assertNull($geometry
->{$method_name}($argument), 'Failed on ' . $method_name);
}
if ($geometry
->geometryType() == 'LineString') {
$this
->assertNull($geometry
->{$method_name}($argument), 'Failed on ' . $method_name);
}
if ($geometry
->geometryType() == 'MultiLineString') {
$this
->assertNull($geometry
->{$method_name}($argument), 'Failed on ' . $method_name);
}
break;
case 'getBBox':
if ($geometry
->geometryType() == 'Point') {
$this
->assertNull($geometry
->{$method_name}($argument), 'Failed on ' . $method_name);
}
if ($geometry
->geometryType() == 'LineString') {
$this
->assertNull($geometry
->{$method_name}($argument), 'Failed on ' . $method_name);
}
if ($geometry
->geometryType() == 'MultiLineString') {
$this
->assertNotNull($geometry
->{$method_name}($argument), 'Failed on ' . $method_name);
}
break;
case 'centroid':
if ($geometry
->geometryType() == 'Point') {
$this
->assertNull($geometry
->{$method_name}($argument), 'Failed on ' . $method_name);
}
if ($geometry
->geometryType() == 'LineString') {
$this
->assertNull($geometry
->{$method_name}($argument), 'Failed on ' . $method_name);
}
if ($geometry
->geometryType() == 'MultiLineString') {
$this
->assertNotNull($geometry
->{$method_name}($argument), 'Failed on ' . $method_name);
}
break;
case 'length':
if ($geometry
->geometryType() == 'Point') {
$this
->assertNull($geometry
->{$method_name}($argument), 'Failed on ' . $method_name);
}
if ($geometry
->geometryType() == 'LineString') {
$this
->assertNull($geometry
->{$method_name}($argument), 'Failed on ' . $method_name);
}
if ($geometry
->geometryType() == 'MultiLineString') {
$this
->assertEquals($geometry
->{$method_name}($argument), (double) '0.11624637315233', 'Failed on ' . $method_name);
}
break;
case 'numGeometries':
if ($geometry
->geometryType() == 'Point') {
$this
->assertNull($geometry
->{$method_name}($argument), 'Failed on ' . $method_name);
}
if ($geometry
->geometryType() == 'LineString') {
$this
->assertNull($geometry
->{$method_name}($argument), 'Failed on ' . $method_name);
}
if ($geometry
->geometryType() == 'MultiLineString') {
$this
->assertNotNull($geometry
->{$method_name}($argument), 'Failed on ' . $method_name);
}
break;
case 'numPoints':
if ($geometry
->geometryType() == 'Point') {
$this
->assertNull($geometry
->{$method_name}($argument), 'Failed on ' . $method_name);
}
if ($geometry
->geometryType() == 'LineString') {
$this
->assertNull($geometry
->{$method_name}($argument), 'Failed on ' . $method_name);
}
if ($geometry
->geometryType() == 'MultiLineString') {
$this
->assertNotNull($geometry
->{$method_name}($argument), 'Failed on ' . $method_name);
}
break;
case 'dimension':
if ($geometry
->geometryType() == 'Point') {
$this
->assertNull($geometry
->{$method_name}($argument), 'Failed on ' . $method_name);
}
if ($geometry
->geometryType() == 'LineString') {
$this
->assertNull($geometry
->{$method_name}($argument), 'Failed on ' . $method_name);
}
if ($geometry
->geometryType() == 'MultiLineString') {
$this
->assertNotNull($geometry
->{$method_name}($argument), 'Failed on ' . $method_name);
}
break;
case 'boundary':
if ($geometry
->geometryType() == 'Point') {
$this
->assertNull($geometry
->{$method_name}($argument), 'Failed on ' . $method_name);
}
if ($geometry
->geometryType() == 'LineString') {
$this
->assertNull($geometry
->{$method_name}($argument), 'Failed on ' . $method_name);
}
if ($geometry
->geometryType() == 'MultiLineString') {
$this
->assertNotNull($geometry
->{$method_name}($argument), 'Failed on ' . $method_name);
}
break;
case 'greatCircleLength':
if ($geometry
->geometryType() == 'Point') {
$this
->assertNull($geometry
->{$method_name}($argument), 'Failed on ' . $method_name);
}
if ($geometry
->geometryType() == 'LineString') {
$this
->assertNull($geometry
->{$method_name}($argument), 'Failed on ' . $method_name);
}
if ($geometry
->geometryType() == 'MultiLineString') {
$this
->assertNotEquals($geometry
->{$method_name}($argument), '9500.9359867418', 'Failed on ' . $method_name);
}
break;
case 'haversineLength':
case 'area':
$this
->assertNotNull($geometry
->{$method_name}($argument), 'Failed on ' . $method_name);
break;
case 'geometryType':
$this
->assertNotNull($geometry
->{$method_name}($argument), 'Failed on ' . $method_name);
break;
default:
$this
->assertTrue($geometry
->{$method_name}($argument), 'Failed on ' . $method_name);
}
}