From f9082c667a572875977b9615b515e9cdd7695929 Mon Sep 17 00:00:00 2001 From: Yasitha Pandithawatta Date: Fri, 15 Jun 2012 12:37:28 +0530 Subject: [PATCH] improve code coverage of gis library --- libraries/gis/pma_gis_geometrycollection.php | 2 +- test/classes/gis/PMA_GIS_Geometry_test.php | 67 +++++ .../gis/PMA_GIS_Geometrycollection_test.php | 279 ++++++++++++++++++ test/classes/gis/PMA_GIS_Linestring_test.php | 142 +++++++++ .../gis/PMA_GIS_Multilinestring_test.php | 143 +++++++++ test/classes/gis/PMA_GIS_Multipoint_test.php | 143 +++++++++ .../classes/gis/PMA_GIS_Multipolygon_test.php | 143 +++++++++ test/classes/gis/PMA_GIS_Point_test.php | 142 +++++++++ test/classes/gis/PMA_GIS_Polygon_test.php | 169 +++++++++++ 9 files changed, 1229 insertions(+), 1 deletion(-) create mode 100644 test/classes/gis/PMA_GIS_Geometrycollection_test.php diff --git a/libraries/gis/pma_gis_geometrycollection.php b/libraries/gis/pma_gis_geometrycollection.php index 01e0a54645..6cbd4e7f2f 100644 --- a/libraries/gis/pma_gis_geometrycollection.php +++ b/libraries/gis/pma_gis_geometrycollection.php @@ -59,7 +59,7 @@ class PMA_GIS_Geometrycollection extends PMA_GIS_Geometry // Trim to remove leading 'GEOMETRYCOLLECTION(' and trailing ')' $goem_col = substr($spatial, 19, (strlen($spatial) - 20)); - + // Split the geometry collection object to get its constituents. $sub_parts = $this->_explodeGeomCol($goem_col); diff --git a/test/classes/gis/PMA_GIS_Geometry_test.php b/test/classes/gis/PMA_GIS_Geometry_test.php index 080707addd..f2fe0e0256 100644 --- a/test/classes/gis/PMA_GIS_Geometry_test.php +++ b/test/classes/gis/PMA_GIS_Geometry_test.php @@ -244,5 +244,72 @@ class PMA_GIS_GeometryTest extends PHPUnit_Framework_TestCase ), ); } + + /** + * + * @param type $srid + * @param type $scale_data + * @param type $output + * + *@dataProvider providerForGetBoundsForOl + */ + public function testGetBoundsForOl($srid, $scale_data, $output) { + $this->assertEquals( + $this->_callProtectedFunction( + 'getBoundsForOl', + array($srid, $scale_data) + ), + $output + ); + } + + public function providerForGetBoundsForOl(){ + + return array( + array( + 4326, + array( + 'minX' => '0', + 'minY' => '0', + 'maxX' => '1', + 'maxY' => '1', + ), + 'bound = new OpenLayers.Bounds(); bound.extend(new OpenLayers.LonLat(0, 0).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject())); bound.extend(new OpenLayers.LonLat(1, 1).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject()));' + ) + + ); + } + + /** + * + * @param type $polygons + * @param type $srid + * @param type $output + * + *@dataProvider providerForGetPolygonArrayForOpenLayers + */ + public function testGetPolygonArrayForOpenLayers($polygons, $srid, $output) { + $this->assertEquals( + $this->_callProtectedFunction( + 'getPolygonArrayForOpenLayers', + array($polygons, $srid) + ), + $output + ); + } + + public function providerForGetPolygonArrayForOpenLayers(){ + + return array( + array( + array('Triangle'), + 4326, + 'new Array(new OpenLayers.Geometry.Polygon(new Array(new OpenLayers.Geometry.LinearRing(new Array((new OpenLayers.Geometry.Point(,)).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject()))))))' + ) + + ); + } + + } ?> diff --git a/test/classes/gis/PMA_GIS_Geometrycollection_test.php b/test/classes/gis/PMA_GIS_Geometrycollection_test.php new file mode 100644 index 0000000000..ede67d4d28 --- /dev/null +++ b/test/classes/gis/PMA_GIS_Geometrycollection_test.php @@ -0,0 +1,279 @@ +object = PMA_GIS_Geometrycollection::singleton(); + } + + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test is executed. + * + * @access protected + * @return void + */ + protected function tearDown() { + unset($this->object); + } + + /** + * + * @param type $spatial + * + * @dataProvider providerForScaleRow + */ + public function testScaleRow($spatial, $output) { + + $this->assertEquals($this->object->scaleRow($spatial), $output); + } + + public function providerForScaleRow() { + + return array( + array( + 'GEOMETRYCOLLECTION(POLYGON((35 10,10 20,15 40,45 45,35 10),(20 30,35 32,30 20,20 30)))', + Array( + 'maxX' => 45.0, + 'minX' => 10.0, + 'maxY' => 45.0, + 'minY' => 10.0 + ) + ) + ); + } + + /** + * + * @param type $gis_data + * @param type $index + * @param string $empty + * @param type $output + * + * @dataProvider providerForGenerateWkt + */ + public function testGenerateWkt($gis_data, $index, $empty, $output) { + + $this->assertEquals($this->object->generateWkt($gis_data, $index, $empty = ''), $output); + } + + public function providerForGenerateWkt() { + + $temp1 = array( + 0 => array( + 'gis_type' => 'LINESTRING', + 'LINESTRING' => array( + 'no_of_points' => 2, + 0 => array('x' => 5.02, 'y' => 8.45), + 1 => array('x' => 6.14, 'y' => 0.15) + ) + ) + ); + + return array( + array( + $temp1, + 0, + null, + 'GEOMETRYCOLLECTION(LINESTRING(5.02 8.45,6.14 0.15))' + ) + ); + } + + public function testGenerateWkt($gis_data, $index, $empty, $output) { + + $this->assertEquals($this->object->generateParams($value), $output); + } + + public function providerForGenerateWkt() { + + $temp1 = array( + 0 => array( + 'gis_type' => 'LINESTRING', + 'LINESTRING' => array( + 'no_of_points' => 2, + 0 => array('x' => 5.02, 'y' => 8.45), + 1 => array('x' => 6.14, 'y' => 0.15) + ) + ) + ); + + return array( + array( + $temp1, + 0, + null, + 'GEOMETRYCOLLECTION(LINESTRING(5.02 8.45,6.14 0.15))' + ) + ); + } + + /** + * + * @param type $spatial + * @param type $label + * @param type $line_color + * @param type $scale_data + * @param type $image + * @param type $output + * + * @dataProvider providerForPrepareRowAsPng + */ + public function testPrepareRowAsPng($spatial, $label, $line_color, $scale_data, $image, $output) { + + $return = $this->object->prepareRowAsPng($spatial, $label, $line_color, $scale_data, $image); + $this->assertTrue(true); + } + + public function providerForPrepareRowAsPng() { + + return array( + array( + 'GEOMETRYCOLLECTION(POLYGON((35 10,10 20,15 40,45 45,35 10),(20 30,35 32,30 20,20 30)))', + 'image', + '#B02EE0', + array( + 'x' => 12, + 'y' => 69, + 'scale' => 2, + 'height' => 150 + ), + imagecreatetruecolor('120', '150'), + '' + ) + ); + } + + /** + * + * @param type $spatial + * @param type $label + * @param type $line_color + * @param type $scale_data + * @param type $pdf + * + * @dataProvider providerForPrepareRowAsPdf + */ + public function testPrepareRowAsPdf($spatial, $label, $line_color, $scale_data, $pdf) { + + $return = $this->object->prepareRowAsPdf($spatial, $label, $line_color, $scale_data, $pdf); + $this->assertTrue($return instanceof TCPDF); + } + + public function providerForPrepareRowAsPdf() { + + return array( + array( + 'GEOMETRYCOLLECTION(POLYGON((35 10,10 20,15 40,45 45,35 10),(20 30,35 32,30 20,20 30)))', + 'pdf', + '#B02EE0', + array( + 'x' => 12, + 'y' => 69, + 'scale' => 2, + 'height' => 150 + ), + new TCPDF(), + ) + ); + } + + /** + * + * @param type $spatial + * @param type $label + * @param type $line_color + * @param type $scale_data + * @param type $output + * + * @dataProvider providerForPrepareRowAsSvg + */ + public function testPrepareRowAsSvg($spatial, $label, $line_color, $scale_data, $output) { + + $string = $this->object->prepareRowAsSvg($spatial, $label, $line_color, $scale_data); + $this->assertEquals(1, preg_match($output, $string)); +// $this->assertEquals($this->object->prepareRowAsSvg($spatial, $label, $line_color, $scale_data) , $output); + } + + public function providerForPrepareRowAsSvg() { + + return array( + array( + 'GEOMETRYCOLLECTION(POLYGON((35 10,10 20,15 40,45 45,35 10),(20 30,35 32,30 20,20 30)))', + 'svg', + '#B02EE0', + array( + 'x' => 12, + 'y' => 69, + 'scale' => 2, + 'height' => 150 + ), + '/^()$/' + ) + ); + } + + /** + * + * @param type $spatial + * @param type $srid + * @param type $label + * @param type $line_color + * @param type $scale_data + * @param type $output + * + * @dataProvider providerForPrepareRowAsOl + */ + public function testPrepareRowAsOl($spatial, $srid, $label, $line_color, $scale_data, $output) { + + $this->assertEquals($this->object->prepareRowAsOl($spatial, $srid, $label, $line_color, $scale_data), $output); + } + + public function providerForPrepareRowAsOl() { + + return array( + array( + 'GEOMETRYCOLLECTION(POLYGON((35 10,10 20,15 40,45 45,35 10),(20 30,35 32,30 20,20 30)))', + 4326, + 'Ol', + '#B02EE0', + array( + 'minX' => '0', + 'minY' => '0', + 'maxX' => '1', + 'maxY' => '1', + ), + 'bound = new OpenLayers.Bounds(); bound.extend(new OpenLayers.LonLat(0, 0).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject())); bound.extend(new OpenLayers.LonLat(1, 1).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject()));vectorLayer.addFeatures(new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Polygon(new Array(new OpenLayers.Geometry.LinearRing(new Array((new OpenLayers.Geometry.Point(35,10)).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject()), (new OpenLayers.Geometry.Point(10,20)).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject()), (new OpenLayers.Geometry.Point(15,40)).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject()), (new OpenLayers.Geometry.Point(45,45)).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject()), (new OpenLayers.Geometry.Point(35,10)).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject()))), new OpenLayers.Geometry.LinearRing(new Array((new OpenLayers.Geometry.Point(20,30)).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject()), (new OpenLayers.Geometry.Point(35,32)).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject()), (new OpenLayers.Geometry.Point(30,20)).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject()), (new OpenLayers.Geometry.Point(20,30)).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject()))))), null, {"strokeColor":"#000000","strokeWidth":0.5,"fillColor":"#B02EE0","fillOpacity":0.8,"label":"Ol","fontSize":10}));' + ) + ); + } + +} + +?> diff --git a/test/classes/gis/PMA_GIS_Linestring_test.php b/test/classes/gis/PMA_GIS_Linestring_test.php index f8760b9133..b37ac1a8eb 100644 --- a/test/classes/gis/PMA_GIS_Linestring_test.php +++ b/test/classes/gis/PMA_GIS_Linestring_test.php @@ -9,6 +9,7 @@ require_once 'PMA_GIS_Geom_test.php'; require_once 'libraries/gis/pma_gis_geometry.php'; require_once 'libraries/gis/pma_gis_linestring.php'; +require_once 'libraries/tcpdf/tcpdf.php'; /** * Tests for PMA_GIS_Linestring class @@ -159,5 +160,146 @@ class PMA_GIS_LinestringTest extends PMA_GIS_GeomTest ) ); } + + /** + * + * @param type $spatial + * @param type $label + * @param type $line_color + * @param type $scale_data + * @param type $image + * @param type $output + * + *@dataProvider providerForPrepareRowAsPng + */ + public function testPrepareRowAsPng($spatial, $label, $line_color, $scale_data, $image, $output) { + + $return = $this->object->prepareRowAsPng($spatial, $label, $line_color, $scale_data, $image); + $this->assertTrue(true); + } + + public function providerForPrepareRowAsPng(){ + + return array( + array( + 'LINESTRING(12 35,48 75,69 23,25 45,14 53,35 78)', + 'image', + '#B02EE0', + array( + 'x' => 12, + 'y' => 69, + 'scale' => 2, + 'height' => 150 + ), + imagecreatetruecolor('120','150'), + '' + ) + + ); + } + + /** + * + * @param type $spatial + * @param type $label + * @param type $line_color + * @param type $scale_data + * @param type $pdf + * + *@dataProvider providerForPrepareRowAsPdf + */ + public function testPrepareRowAsPdf($spatial, $label, $line_color, $scale_data, $pdf) { + + $return = $this->object->prepareRowAsPdf($spatial, $label, $line_color, $scale_data, $pdf); + $this->assertTrue($return instanceof TCPDF); + } + + public function providerForPrepareRowAsPdf(){ + + return array( + array( + 'LINESTRING(12 35,48 75,69 23,25 45,14 53,35 78)', + 'pdf', + '#B02EE0', + array( + 'x' => 12, + 'y' => 69, + 'scale' => 2, + 'height' => 150 + ), + new TCPDF(), + ) + ); + } + + /** + * + * @param type $spatial + * @param type $label + * @param type $line_color + * @param type $scale_data + * @param type $output + * + *@dataProvider providerForPrepareRowAsSvg + */ + public function testPrepareRowAsSvg($spatial, $label, $line_color, $scale_data, $output) { + + $string = $this->object->prepareRowAsSvg($spatial, $label, $line_color, $scale_data); + $this->assertEquals(1, preg_match($output, $string)); + //$this->assertEquals($this->object->prepareRowAsSvg($spatial, $label, $line_color, $scale_data) , $output); + } + + public function providerForPrepareRowAsSvg(){ + + return array( + array( + 'LINESTRING(12 35,48 75,69 23,25 45,14 53,35 78)', + 'svg', + '#B02EE0', + array( + 'x' => 12, + 'y' => 69, + 'scale' => 2, + 'height' => 150 + ), + '/^()$/' + ) + ); + } + + /** + * + * @param type $spatial + * @param type $srid + * @param type $label + * @param type $line_color + * @param type $scale_data + * @param type $output + * + *@dataProvider providerForPrepareRowAsOl + */ + public function testPrepareRowAsOl($spatial, $srid, $label, $line_color, $scale_data, $output) { + + $this->assertEquals($this->object->prepareRowAsOl($spatial, $srid, $label, $line_color, $scale_data) , $output); + } + + public function providerForPrepareRowAsOl(){ + + return array( + array( + 'LINESTRING(12 35,48 75,69 23,25 45,14 53,35 78)', + 4326, + 'Ol', + '#B02EE0', + array( + 'minX' => '0', + 'minY' => '0', + 'maxX' => '1', + 'maxY' => '1', + ), + 'bound = new OpenLayers.Bounds(); bound.extend(new OpenLayers.LonLat(0, 0).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject())); bound.extend(new OpenLayers.LonLat(1, 1).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject()));vectorLayer.addFeatures(new OpenLayers.Feature.Vector(new OpenLayers.Geometry.LineString(new Array((new OpenLayers.Geometry.Point(12,35)).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject()), (new OpenLayers.Geometry.Point(48,75)).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject()), (new OpenLayers.Geometry.Point(69,23)).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject()), (new OpenLayers.Geometry.Point(25,45)).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject()), (new OpenLayers.Geometry.Point(14,53)).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject()), (new OpenLayers.Geometry.Point(35,78)).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject()))), null, {"strokeColor":"#B02EE0","strokeWidth":2,"label":"Ol","fontSize":10}));' + ) + ); + } } ?> diff --git a/test/classes/gis/PMA_GIS_Multilinestring_test.php b/test/classes/gis/PMA_GIS_Multilinestring_test.php index aed8f721bf..241a234212 100644 --- a/test/classes/gis/PMA_GIS_Multilinestring_test.php +++ b/test/classes/gis/PMA_GIS_Multilinestring_test.php @@ -9,6 +9,7 @@ require_once 'PMA_GIS_Geom_test.php'; require_once 'libraries/gis/pma_gis_geometry.php'; require_once 'libraries/gis/pma_gis_multilinestring.php'; +require_once 'libraries/tcpdf/tcpdf.php'; /** * Tests for PMA_GIS_Multilinestring class @@ -219,5 +220,147 @@ class PMA_GIS_MultilinestringTest extends PMA_GIS_GeomTest ) ); } + + + /** + * + * @param type $spatial + * @param type $label + * @param type $line_color + * @param type $scale_data + * @param type $image + * @param type $output + * + *@dataProvider providerForPrepareRowAsPng + */ + public function testPrepareRowAsPng($spatial, $label, $line_color, $scale_data, $image, $output) { + + $return = $this->object->prepareRowAsPng($spatial, $label, $line_color, $scale_data, $image); + $this->assertTrue(true); + } + + public function providerForPrepareRowAsPng(){ + + return array( + array( + 'MULTILINESTRING((36 14,47 23,62 75),(36 10,17 23,178 53))', + 'image', + '#B02EE0', + array( + 'x' => 12, + 'y' => 69, + 'scale' => 2, + 'height' => 150 + ), + imagecreatetruecolor('120','150'), + '' + ) + + ); + } + + /** + * + * @param type $spatial + * @param type $label + * @param type $line_color + * @param type $scale_data + * @param type $pdf + * + *@dataProvider providerForPrepareRowAsPdf + */ + public function testPrepareRowAsPdf($spatial, $label, $line_color, $scale_data, $pdf) { + + $return = $this->object->prepareRowAsPdf($spatial, $label, $line_color, $scale_data, $pdf); + $this->assertTrue($return instanceof TCPDF); + } + + public function providerForPrepareRowAsPdf(){ + + return array( + array( + 'MULTILINESTRING((36 14,47 23,62 75),(36 10,17 23,178 53))', + 'pdf', + '#B02EE0', + array( + 'x' => 12, + 'y' => 69, + 'scale' => 2, + 'height' => 150 + ), + new TCPDF(), + ) + ); + } + + /** + * + * @param type $spatial + * @param type $label + * @param type $line_color + * @param type $scale_data + * @param type $output + * + *@dataProvider providerForPrepareRowAsSvg + */ + public function testPrepareRowAsSvg($spatial, $label, $line_color, $scale_data, $output) { + + $string = $this->object->prepareRowAsSvg($spatial, $label, $line_color, $scale_data); + $this->assertEquals(1, preg_match($output, $string)); + //$this->assertEquals($this->object->prepareRowAsSvg($spatial, $label, $line_color, $scale_data) , $output); + } + + public function providerForPrepareRowAsSvg(){ + + return array( + array( + 'MULTILINESTRING((36 14,47 23,62 75),(36 10,17 23,178 53))', + 'svg', + '#B02EE0', + array( + 'x' => 12, + 'y' => 69, + 'scale' => 2, + 'height' => 150 + ), + '/^()$/' + ) + ); + } + + /** + * + * @param type $spatial + * @param type $srid + * @param type $label + * @param type $line_color + * @param type $scale_data + * @param type $output + * + *@dataProvider providerForPrepareRowAsOl + */ + public function testPrepareRowAsOl($spatial, $srid, $label, $line_color, $scale_data, $output) { + + $this->assertEquals($this->object->prepareRowAsOl($spatial, $srid, $label, $line_color, $scale_data) , $output); + } + + public function providerForPrepareRowAsOl(){ + + return array( + array( + 'MULTILINESTRING((36 14,47 23,62 75),(36 10,17 23,178 53))', + 4326, + 'Ol', + '#B02EE0', + array( + 'minX' => '0', + 'minY' => '0', + 'maxX' => '1', + 'maxY' => '1', + ), + 'bound = new OpenLayers.Bounds(); bound.extend(new OpenLayers.LonLat(0, 0).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject())); bound.extend(new OpenLayers.LonLat(1, 1).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject()));vectorLayer.addFeatures(new OpenLayers.Feature.Vector(new OpenLayers.Geometry.MultiLineString(new Array(new OpenLayers.Geometry.LineString(new Array((new OpenLayers.Geometry.Point(36,14)).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject()), (new OpenLayers.Geometry.Point(47,23)).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject()), (new OpenLayers.Geometry.Point(62,75)).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject()))), new OpenLayers.Geometry.LineString(new Array((new OpenLayers.Geometry.Point(36,10)).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject()), (new OpenLayers.Geometry.Point(17,23)).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject()), (new OpenLayers.Geometry.Point(178,53)).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject()))))), null, {"strokeColor":"#B02EE0","strokeWidth":2,"label":"Ol","fontSize":10}));' + ) + ); + } } ?> diff --git a/test/classes/gis/PMA_GIS_Multipoint_test.php b/test/classes/gis/PMA_GIS_Multipoint_test.php index 8bc2119725..caefe21c25 100644 --- a/test/classes/gis/PMA_GIS_Multipoint_test.php +++ b/test/classes/gis/PMA_GIS_Multipoint_test.php @@ -9,6 +9,7 @@ require_once 'PMA_GIS_Geom_test.php'; require_once 'libraries/gis/pma_gis_geometry.php'; require_once 'libraries/gis/pma_gis_multipoint.php'; +require_once 'libraries/tcpdf/tcpdf.php'; /** * Tests for PMA_GIS_Multipoint class @@ -163,5 +164,147 @@ class PMA_GIS_MultipointTest extends PMA_GIS_GeomTest ) ); } + + + /** + * + * @param type $spatial + * @param type $label + * @param type $line_color + * @param type $scale_data + * @param type $image + * @param type $output + * + *@dataProvider providerForPrepareRowAsPng + */ + public function testPrepareRowAsPng($spatial, $label, $line_color, $scale_data, $image, $output) { + + $return = $this->object->prepareRowAsPng($spatial, $label, $line_color, $scale_data, $image); + $this->assertTrue(true); + } + + public function providerForPrepareRowAsPng(){ + + return array( + array( + 'MULTIPOINT(12 35,48 75,69 23,25 45,14 53,35 78)', + 'image', + '#B02EE0', + array( + 'x' => 12, + 'y' => 69, + 'scale' => 2, + 'height' => 150 + ), + imagecreatetruecolor('120','150'), + '' + ) + + ); + } + + /** + * + * @param type $spatial + * @param type $label + * @param type $line_color + * @param type $scale_data + * @param type $pdf + * + *@dataProvider providerForPrepareRowAsPdf + */ + public function testPrepareRowAsPdf($spatial, $label, $line_color, $scale_data, $pdf) { + + $return = $this->object->prepareRowAsPdf($spatial, $label, $line_color, $scale_data, $pdf); + $this->assertTrue($return instanceof TCPDF); + } + + public function providerForPrepareRowAsPdf(){ + + return array( + array( + 'MULTIPOINT(12 35,48 75,69 23,25 45,14 53,35 78)', + 'pdf', + '#B02EE0', + array( + 'x' => 12, + 'y' => 69, + 'scale' => 2, + 'height' => 150 + ), + new TCPDF(), + ) + ); + } + + /** + * + * @param type $spatial + * @param type $label + * @param type $line_color + * @param type $scale_data + * @param type $output + * + *@dataProvider providerForPrepareRowAsSvg + */ + public function testPrepareRowAsSvg($spatial, $label, $line_color, $scale_data, $output) { + + $string = $this->object->prepareRowAsSvg($spatial, $label, $line_color, $scale_data); + $this->assertEquals(1, preg_match($output, $string)); +// $this->assertEquals($this->object->prepareRowAsSvg($spatial, $label, $line_color, $scale_data) , $output); + } + + public function providerForPrepareRowAsSvg(){ + + return array( + array( + 'MULTIPOINT(12 35,48 75,69 23,25 45,14 53,35 78)', + 'svg', + '#B02EE0', + array( + 'x' => 12, + 'y' => 69, + 'scale' => 2, + 'height' => 150 + ), + '/^()$/' + ) + ); + } + + /** + * + * @param type $spatial + * @param type $srid + * @param type $label + * @param type $line_color + * @param type $scale_data + * @param type $output + * + *@dataProvider providerForPrepareRowAsOl + */ + public function testPrepareRowAsOl($spatial, $srid, $label, $line_color, $scale_data, $output) { + + $this->assertEquals($this->object->prepareRowAsOl($spatial, $srid, $label, $line_color, $scale_data) , $output); + } + + public function providerForPrepareRowAsOl(){ + + return array( + array( + 'MULTIPOINT(12 35,48 75,69 23,25 45,14 53,35 78)', + 4326, + 'Ol', + '#B02EE0', + array( + 'minX' => '0', + 'minY' => '0', + 'maxX' => '1', + 'maxY' => '1', + ), + 'bound = new OpenLayers.Bounds(); bound.extend(new OpenLayers.LonLat(0, 0).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject())); bound.extend(new OpenLayers.LonLat(1, 1).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject()));vectorLayer.addFeatures(new OpenLayers.Feature.Vector(new OpenLayers.Geometry.MultiPoint(new Array((new OpenLayers.Geometry.Point(12,35)).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject()), (new OpenLayers.Geometry.Point(48,75)).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject()), (new OpenLayers.Geometry.Point(69,23)).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject()), (new OpenLayers.Geometry.Point(25,45)).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject()), (new OpenLayers.Geometry.Point(14,53)).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject()), (new OpenLayers.Geometry.Point(35,78)).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject()))), null, {"pointRadius":3,"fillColor":"#ffffff","strokeColor":"#B02EE0","strokeWidth":2,"label":"Ol","labelYOffset":-8,"fontSize":10}));' + ) + ); + } } ?> diff --git a/test/classes/gis/PMA_GIS_Multipolygon_test.php b/test/classes/gis/PMA_GIS_Multipolygon_test.php index eb1591690c..50d5eb3dec 100644 --- a/test/classes/gis/PMA_GIS_Multipolygon_test.php +++ b/test/classes/gis/PMA_GIS_Multipolygon_test.php @@ -9,6 +9,7 @@ require_once 'PMA_GIS_Geom_test.php'; require_once 'libraries/gis/pma_gis_geometry.php'; require_once 'libraries/gis/pma_gis_multipolygon.php'; +require_once 'libraries/tcpdf/tcpdf.php'; /** * Tests for PMA_GIS_Multipolygon class @@ -257,5 +258,147 @@ class PMA_GIS_MultipolygonTest extends PMA_GIS_GeomTest ) ); } + + + /** + * + * @param type $spatial + * @param type $label + * @param type $line_color + * @param type $scale_data + * @param type $image + * @param type $output + * + *@dataProvider providerForPrepareRowAsPng + */ + public function testPrepareRowAsPng($spatial, $label, $line_color, $scale_data, $image, $output) { + + $return = $this->object->prepareRowAsPng($spatial, $label, $line_color, $scale_data, $image); + $this->assertTrue(true); + } + + public function providerForPrepareRowAsPng(){ + + return array( + array( + 'MULTIPOLYGON(((136 40,147 83,16 75,136 40)),((105 0,56 20,78 73,105 0)))', + 'image', + '#B02EE0', + array( + 'x' => 12, + 'y' => 69, + 'scale' => 2, + 'height' => 150 + ), + imagecreatetruecolor('120','150'), + '' + ) + + ); + } + + /** + * + * @param type $spatial + * @param type $label + * @param type $line_color + * @param type $scale_data + * @param type $pdf + * + *@dataProvider providerForPrepareRowAsPdf + */ + public function testPrepareRowAsPdf($spatial, $label, $line_color, $scale_data, $pdf) { + + $return = $this->object->prepareRowAsPdf($spatial, $label, $line_color, $scale_data, $pdf); + $this->assertTrue($return instanceof TCPDF); + } + + public function providerForPrepareRowAsPdf(){ + + return array( + array( + 'MULTIPOLYGON(((136 40,147 83,16 75,136 40)),((105 0,56 20,78 73,105 0)))', + 'pdf', + '#B02EE0', + array( + 'x' => 12, + 'y' => 69, + 'scale' => 2, + 'height' => 150 + ), + new TCPDF(), + ) + ); + } + + /** + * + * @param type $spatial + * @param type $label + * @param type $line_color + * @param type $scale_data + * @param type $output + * + *@dataProvider providerForPrepareRowAsSvg + */ + public function testPrepareRowAsSvg($spatial, $label, $line_color, $scale_data, $output) { + + $string = $this->object->prepareRowAsSvg($spatial, $label, $line_color, $scale_data); + $this->assertEquals(1, preg_match($output, $string)); +// $this->assertEquals($this->object->prepareRowAsSvg($spatial, $label, $line_color, $scale_data) , $output); + } + + public function providerForPrepareRowAsSvg(){ + + return array( + array( + 'MULTIPOLYGON(((136 40,147 83,16 75,136 40)),((105 0,56 20,78 73,105 0)))', + 'svg', + '#B02EE0', + array( + 'x' => 12, + 'y' => 69, + 'scale' => 2, + 'height' => 150 + ), + '/^()$/' + ) + ); + } + + /** + * + * @param type $spatial + * @param type $srid + * @param type $label + * @param type $line_color + * @param type $scale_data + * @param type $output + * + *@dataProvider providerForPrepareRowAsOl + */ + public function testPrepareRowAsOl($spatial, $srid, $label, $line_color, $scale_data, $output) { + + $this->assertEquals($this->object->prepareRowAsOl($spatial, $srid, $label, $line_color, $scale_data) , $output); + } + + public function providerForPrepareRowAsOl(){ + + return array( + array( + 'MULTIPOLYGON(((136 40,147 83,16 75,136 40)),((105 0,56 20,78 73,105 0)))', + 4326, + 'Ol', + '#B02EE0', + array( + 'minX' => '0', + 'minY' => '0', + 'maxX' => '1', + 'maxY' => '1', + ), + 'bound = new OpenLayers.Bounds(); bound.extend(new OpenLayers.LonLat(0, 0).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject())); bound.extend(new OpenLayers.LonLat(1, 1).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject()));vectorLayer.addFeatures(new OpenLayers.Feature.Vector(new OpenLayers.Geometry.MultiPolygon(new Array(new OpenLayers.Geometry.Polygon(new Array(new OpenLayers.Geometry.LinearRing(new Array((new OpenLayers.Geometry.Point(136,40)).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject()), (new OpenLayers.Geometry.Point(147,83)).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject()), (new OpenLayers.Geometry.Point(16,75)).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject()), (new OpenLayers.Geometry.Point(136,40)).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject()))))), new OpenLayers.Geometry.Polygon(new Array(new OpenLayers.Geometry.LinearRing(new Array((new OpenLayers.Geometry.Point(105,0)).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject()), (new OpenLayers.Geometry.Point(56,20)).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject()), (new OpenLayers.Geometry.Point(78,73)).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject()), (new OpenLayers.Geometry.Point(105,0)).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject()))))))), null, {"strokeColor":"#000000","strokeWidth":0.5,"fillColor":"#B02EE0","fillOpacity":0.8,"label":"Ol","fontSize":10}));' + ) + ); + } } ?> diff --git a/test/classes/gis/PMA_GIS_Point_test.php b/test/classes/gis/PMA_GIS_Point_test.php index 165c58f848..cb327e957c 100644 --- a/test/classes/gis/PMA_GIS_Point_test.php +++ b/test/classes/gis/PMA_GIS_Point_test.php @@ -9,6 +9,7 @@ require_once 'PMA_GIS_Geom_test.php'; require_once 'libraries/gis/pma_gis_geometry.php'; require_once 'libraries/gis/pma_gis_point.php'; +require_once 'libraries/tcpdf/tcpdf.php'; /** * Tests for PMA_GIS_Point class. @@ -165,5 +166,146 @@ class PMA_GIS_PointTest extends PMA_GIS_GeomTest ) ); } + + + /** + * + * @param type $spatial + * @param type $label + * @param type $line_color + * @param type $scale_data + * @param type $image + * @param type $output + * + *@dataProvider providerForPrepareRowAsPng + */ + public function testPrepareRowAsPng($spatial, $label, $line_color, $scale_data, $image, $output) { + + $return = $this->object->prepareRowAsPng($spatial, $label, $line_color, $scale_data, $image); + $this->assertTrue(true); + } + + public function providerForPrepareRowAsPng(){ + + return array( + array( + 'POINT(12 35)', + 'image', + '#B02EE0', + array( + 'x' => 12, + 'y' => 69, + 'scale' => 2, + 'height' => 150 + ), + imagecreatetruecolor('120','150'), + '' + ) + + ); + } + + /** + * + * @param type $spatial + * @param type $label + * @param type $line_color + * @param type $scale_data + * @param type $pdf + * + *@dataProvider providerForPrepareRowAsPdf + */ + public function testPrepareRowAsPdf($spatial, $label, $line_color, $scale_data, $pdf) { + + $return = $this->object->prepareRowAsPdf($spatial, $label, $line_color, $scale_data, $pdf); + $this->assertTrue($return instanceof TCPDF); + } + + public function providerForPrepareRowAsPdf(){ + + return array( + array( + 'POINT(12 35)', + 'pdf', + '#B02EE0', + array( + 'x' => 12, + 'y' => 69, + 'scale' => 2, + 'height' => 150 + ), + new TCPDF(), + ) + ); + } + + /** + * + * @param type $spatial + * @param type $label + * @param type $line_color + * @param type $scale_data + * @param type $output + * + *@dataProvider providerForPrepareRowAsSvg + */ + public function testPrepareRowAsSvg($spatial, $label, $line_color, $scale_data, $output) { + + $this->assertEquals($output, $this->object->prepareRowAsSvg($spatial, $label, $line_color, $scale_data)); +// $this->assertEquals($this->object->prepareRowAsSvg($spatial, $label, $line_color, $scale_data) , $output); + } + + public function providerForPrepareRowAsSvg(){ + + return array( + array( + 'POINT(12 35)', + 'svg', + '#B02EE0', + array( + 'x' => 12, + 'y' => 69, + 'scale' => 2, + 'height' => 150 + ), + '' + ) + ); + } + + /** + * + * @param type $spatial + * @param type $srid + * @param type $label + * @param type $line_color + * @param type $scale_data + * @param type $output + * + *@dataProvider providerForPrepareRowAsOl + */ + public function testPrepareRowAsOl($spatial, $srid, $label, $line_color, $scale_data, $output) { + + $this->assertEquals($this->object->prepareRowAsOl($spatial, $srid, $label, $line_color, $scale_data) , $output); + } + + public function providerForPrepareRowAsOl(){ + + return array( + array( + 'POINT(12 35)', + 4326, + 'Ol', + '#B02EE0', + array( + 'minX' => '0', + 'minY' => '0', + 'maxX' => '1', + 'maxY' => '1', + ), + 'bound = new OpenLayers.Bounds(); bound.extend(new OpenLayers.LonLat(0, 0).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject())); bound.extend(new OpenLayers.LonLat(1, 1).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject()));vectorLayer.addFeatures(new OpenLayers.Feature.Vector((new OpenLayers.Geometry.Point(12,35)).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject()), null, {"pointRadius":3,"fillColor":"#ffffff","strokeColor":"#B02EE0","strokeWidth":2,"label":"Ol","labelYOffset":-8,"fontSize":10}));' + ) + ); + } } ?> diff --git a/test/classes/gis/PMA_GIS_Polygon_test.php b/test/classes/gis/PMA_GIS_Polygon_test.php index 9d0e951980..ffb6bc7dcc 100644 --- a/test/classes/gis/PMA_GIS_Polygon_test.php +++ b/test/classes/gis/PMA_GIS_Polygon_test.php @@ -9,6 +9,7 @@ require_once 'PMA_GIS_Geom_test.php'; require_once 'libraries/gis/pma_gis_geometry.php'; require_once 'libraries/gis/pma_gis_polygon.php'; +require_once 'libraries/tcpdf/tcpdf.php'; /** * Tests for PMA_GIS_Polygon class @@ -345,5 +346,173 @@ class PMA_GIS_PolygonTest extends PMA_GIS_GeomTest ), ); } + + + /** + * + * @param type $spatial + * @param type $label + * @param type $line_color + * @param type $scale_data + * @param type $image + * @param type $output + * + *@dataProvider providerForPrepareRowAsPng + */ + public function testPrepareRowAsPng($spatial, $label, $line_color, $scale_data, $image, $output) { + + $return = $this->object->prepareRowAsPng($spatial, $label, $line_color, $scale_data, $image); + $this->assertTrue(true); + } + + public function providerForPrepareRowAsPng(){ + + return array( + array( + 'POLYGON((123 0,23 30,17 63,123 0))', + 'image', + '#B02EE0', + array( + 'x' => 12, + 'y' => 69, + 'scale' => 2, + 'height' => 150 + ), + imagecreatetruecolor('120','150'), + '' + ) + + ); + } + + /** + * + * @param type $spatial + * @param type $label + * @param type $line_color + * @param type $scale_data + * @param type $pdf + * + *@dataProvider providerForPrepareRowAsPdf + */ + public function testPrepareRowAsPdf($spatial, $label, $line_color, $scale_data, $pdf) { + + $return = $this->object->prepareRowAsPdf($spatial, $label, $line_color, $scale_data, $pdf); + $this->assertTrue($return instanceof TCPDF); + } + + public function providerForPrepareRowAsPdf(){ + + return array( + array( + 'POLYGON((123 0,23 30,17 63,123 0))', + 'pdf', + '#B02EE0', + array( + 'x' => 12, + 'y' => 69, + 'scale' => 2, + 'height' => 150 + ), + new TCPDF(), + ) + ); + } + + /** + * + * @param type $spatial + * @param type $label + * @param type $line_color + * @param type $scale_data + * @param type $output + * + *@dataProvider providerForPrepareRowAsSvg + */ + public function testPrepareRowAsSvg($spatial, $label, $line_color, $scale_data, $output) { + + $string = $this->object->prepareRowAsSvg($spatial, $label, $line_color, $scale_data); + $this->assertEquals(1, preg_match($output, $string)); +// $this->assertEquals($this->object->prepareRowAsSvg($spatial, $label, $line_color, $scale_data) , $output); + } + + public function providerForPrepareRowAsSvg(){ + + return array( + array( + 'POLYGON((123 0,23 30,17 63,123 0))', + 'svg', + '#B02EE0', + array( + 'x' => 12, + 'y' => 69, + 'scale' => 2, + 'height' => 150 + ), + '/^()$/' + ) + ); + } + + /** + * + * @param type $spatial + * @param type $srid + * @param type $label + * @param type $line_color + * @param type $scale_data + * @param type $output + * + *@dataProvider providerForPrepareRowAsOl + */ + public function testPrepareRowAsOl($spatial, $srid, $label, $line_color, $scale_data, $output) { + + $this->assertEquals($this->object->prepareRowAsOl($spatial, $srid, $label, $line_color, $scale_data) , $output); + } + + public function providerForPrepareRowAsOl(){ + + return array( + array( + 'POLYGON((123 0,23 30,17 63,123 0))', + 4326, + 'Ol', + '#B02EE0', + array( + 'minX' => '0', + 'minY' => '0', + 'maxX' => '1', + 'maxY' => '1', + ), + 'bound = new OpenLayers.Bounds(); bound.extend(new OpenLayers.LonLat(0, 0).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject())); bound.extend(new OpenLayers.LonLat(1, 1).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject()));vectorLayer.addFeatures(new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Polygon(new Array(new OpenLayers.Geometry.LinearRing(new Array((new OpenLayers.Geometry.Point(123,0)).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject()), (new OpenLayers.Geometry.Point(23,30)).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject()), (new OpenLayers.Geometry.Point(17,63)).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject()), (new OpenLayers.Geometry.Point(123,0)).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject()))))), null, {"strokeColor":"#000000","strokeWidth":0.5,"fillColor":"#B02EE0","fillOpacity":0.8,"label":"Ol","fontSize":10}));' + ) + ); + } + + /** + * + * @param type $ring + * @param type $output + * + *@dataProvider providerForIsOuterRing + */ + public function testIsOuterRing($ring) { + + $this->assertTrue($this->object->isOuterRing($ring)); + } + + public function providerForIsOuterRing(){ + + return array( + array( + array( + array('x' => 0, 'y' => 0), + array('x' => 0, 'y' => 1), + array('x' => 1, 'y' => 1), + array('x' => 1, 'y' => 0) + ), + ) + ); + } } ?>