[Phpmyadmin-git] [SCM] phpMyAdmin branch, master, updated. RELEASE_3_4_3_2-16991-gcae0366

Madhura Jayaratne madhuracj at users.sourceforge.net
Tue Aug 23 20:44:58 CEST 2011


The branch, master has been updated
       via  cae0366d212bef81d3cef345b02c3e00f681602d (commit)
       via  d837b705a5cd34eb4119a7a556b71b7bd419a918 (commit)
       via  486638281a9b17144915dbc743256429ad34bf45 (commit)
       via  8b3f1b0247c50de4af178f7fa0f014eedbbc9de1 (commit)
      from  c2e7d4be68ac792720eefa9fa5298f0d0014ba5a (commit)


- Log -----------------------------------------------------------------
commit cae0366d212bef81d3cef345b02c3e00f681602d
Merge: d837b70 c2e7d4b
Author: Madhura Jayaratne <madhura.cj at gmail.com>
Date:   Wed Aug 24 00:13:18 2011 +0530

    Merge branch 'master' of ssh://phpmyadmin.git.sourceforge.net/gitroot/phpmyadmin/phpmyadmin

commit d837b705a5cd34eb4119a7a556b71b7bd419a918
Author: Madhura Jayaratne <madhura.cj at gmail.com>
Date:   Wed Aug 24 00:11:39 2011 +0530

    Test cases for PMA_GIS_Geometry class

commit 486638281a9b17144915dbc743256429ad34bf45
Author: Madhura Jayaratne <madhura.cj at gmail.com>
Date:   Tue Aug 23 22:47:34 2011 +0530

    Abstract class PMA_GIS_GeometryTest renamed to PMA_GIS_GeomTest to make room for tests for functions in PMA_GIS_Geometry class

commit 8b3f1b0247c50de4af178f7fa0f014eedbbc9de1
Author: Madhura Jayaratne <madhura.cj at gmail.com>
Date:   Tue Aug 23 22:40:22 2011 +0530

    tests for PMA_GIS_Linestring::scaleRow() method

-----------------------------------------------------------------------

Summary of changes:
 ...GIS_Geometry_test.php => PMA_GIS_Geom_test.php} |    2 +-
 test/classes/gis/PMA_GIS_Geometry_test.php         |  249 +++++++++++++++++---
 test/classes/gis/PMA_GIS_Linestring_test.php       |   38 +++-
 test/classes/gis/PMA_GIS_Multilinestring_test.php  |    4 +-
 test/classes/gis/PMA_GIS_Multipoint_test.php       |    4 +-
 test/classes/gis/PMA_GIS_Multipolygon_test.php     |    4 +-
 test/classes/gis/PMA_GIS_Point_test.php            |    4 +-
 test/classes/gis/PMA_GIS_Polygon_test.php          |    4 +-
 8 files changed, 265 insertions(+), 44 deletions(-)
 copy test/classes/gis/{PMA_GIS_Geometry_test.php => PMA_GIS_Geom_test.php} (95%)

diff --git a/test/classes/gis/PMA_GIS_Geometry_test.php b/test/classes/gis/PMA_GIS_Geom_test.php
similarity index 95%
copy from test/classes/gis/PMA_GIS_Geometry_test.php
copy to test/classes/gis/PMA_GIS_Geom_test.php
index 37d4c42..d7637eb 100644
--- a/test/classes/gis/PMA_GIS_Geometry_test.php
+++ b/test/classes/gis/PMA_GIS_Geom_test.php
@@ -10,7 +10,7 @@ require_once 'libraries/gis/pma_gis_geometry.php';
 /**
  * Abstract parent class for all PMA_GIS_<Geom_type> test classes
  */
-abstract class PMA_GIS_GeometryTest extends PHPUnit_Framework_TestCase
+abstract class PMA_GIS_GeomTest extends PHPUnit_Framework_TestCase
 {
     /**
      * test generateWkt method
diff --git a/test/classes/gis/PMA_GIS_Geometry_test.php b/test/classes/gis/PMA_GIS_Geometry_test.php
index 37d4c42..b5d4732 100644
--- a/test/classes/gis/PMA_GIS_Geometry_test.php
+++ b/test/classes/gis/PMA_GIS_Geometry_test.php
@@ -1,6 +1,6 @@
 <?php
 /**
- * Abstract parent class for all PMA_GIS_<Geom_type> test classes
+ * Test for PMA_GIS_Geometry
  *
  * @package phpMyAdmin-test
  */
@@ -8,53 +8,240 @@
 require_once 'libraries/gis/pma_gis_geometry.php';
 
 /**
- * Abstract parent class for all PMA_GIS_<Geom_type> test classes
+ * Tests for PMA_GIS_Geometry class
  */
-abstract class PMA_GIS_GeometryTest extends PHPUnit_Framework_TestCase
+class PMA_GIS_GeometryTest extends PHPUnit_Framework_TestCase
 {
     /**
-     * test generateWkt method
+     * @access protected
+     */
+    protected $object;
+
+    /**
+     * Sets up the fixture, for example, opens a network connection.
+     * This method is called before a test is executed.
      *
-     * @param array  $gis_data array of GIS data
-     * @param int    $index    index
-     * @param string $empty    string to be insterted in place of missing values
-     * @param string $wkt      expected WKT
+     * @access protected
+     * @return nothing
+     */
+    protected function setUp()
+    {
+        $this->object = $this->getMockForAbstractClass('PMA_GIS_Geometry');
+    }
+
+    /**
+     * Tears down the fixture, for example, closes a network connection.
+     * This method is called after a test is executed.
      *
+     * @access protected
      * @return nothing
-     * @dataProvider providerForTestGenerateWkt
      */
-    public function testGenerateWkt($gis_data, $index, $empty, $wkt)
+    protected function tearDown()
+    {
+        unset($this->object);
+    }
+
+    /**
+     * Call protected functions by making the visibitlity to public.
+     *
+     * @param string $name   method name
+     * @param array  $params parameters for the invocation
+     *
+     * @return the output from the protected method.
+     */
+    private function _callProtectedFunction($name, $params)
+    {
+        $class = new ReflectionClass('PMA_GIS_Geometry');
+        $method = $class->getMethod($name);
+        $method->setAccessible(true);
+        return $method->invokeArgs($this->object, $params);
+    }
+
+    /**
+     * tests setMinMax method
+     *
+     * @param string $point_set Point set
+     * @param array  $min_max   Existing min, max values
+     * @param array  $output    Expected output array
+     *
+     * @dataProvider providerForTestSetMinMax
+     * @return nothing
+     */
+    public function testSetMinMax($point_set, $min_max, $output)
+    {
+        $this->assertEquals(
+            $this->_callProtectedFunction(
+                'setMinMax',
+                array($point_set, $min_max)
+            ),
+            $output
+        );
+    }
+
+    /**
+     * data provider for testSetMinMax
+     *
+     * @return data for testSetMinMax
+     */
+    public function providerForTestSetMinMax()
     {
-        if ($empty == null) {
-            $this->assertEquals($this->object->generateWkt($gis_data, $index), $wkt);
-        } else {
-            $this->assertEquals(
-                $this->object->generateWkt($gis_data, $index, $empty),
-                $wkt
-            );
-        }
+        return array(
+            array(
+                '12 35,48 75,69 23,25 45,14 53,35 78',
+                array(),
+                array(
+                    'minX' => 12,
+                    'maxX' => 69,
+                    'minY' => 23,
+                    'maxY' => 78
+                )
+            ),
+            array(
+                '12 35,48 75,69 23,25 45,14 53,35 78',
+                array(
+                    'minX' => 2,
+                    'maxX' => 29,
+                    'minY' => 23,
+                    'maxY' => 128
+                ),
+                array(
+                    'minX' => 2,
+                    'maxX' => 69,
+                    'minY' => 23,
+                    'maxY' => 128
+                )
+            )
+        );
     }
 
     /**
-     * test generateParams method
+     * tests generateParams method
      *
-     * @param string $wkt    point in WKT form
-     * @param index  $index  index
-     * @param array  $params expected output array
+     * @param string $value  Geometry data
+     * @param string $output Expected output
      *
      * @dataProvider providerForTestGenerateParams
      * @return nothing
      */
-    public function testGenerateParams($wkt, $index, $params)
+    public function testGenerateParams($value, $output)
+    {
+        $this->assertEquals(
+            $this->_callProtectedFunction(
+                'generateParams',
+                array($value)
+            ),
+            $output
+        );
+    }
+
+    /**
+     * data provider for testGenerateParams
+     *
+     * @return data for testGenerateParams
+     */
+    public function providerForTestGenerateParams()
+    {
+        return array(
+            array(
+                "'MULTIPOINT(125 50,156 25,178 43,175 80)',125",
+                array(
+                    'srid' => '125',
+                    'wkt'  => 'MULTIPOINT(125 50,156 25,178 43,175 80)',
+                ),
+            ),
+            array(
+                'MULTIPOINT(125 50,156 25,178 43,175 80)',
+                array(
+                    'srid' => '0',
+                    'wkt'  => 'MULTIPOINT(125 50,156 25,178 43,175 80)',
+                ),
+            ),
+            array(
+                "foo",
+                array(
+                    'srid' => '0',
+                    'wkt'  => '',
+                ),
+            ),
+        );
+    }
+
+    /**
+     * tests extractPoints method
+     *
+     * @param string  $point_set  String of comma sperated points
+     * @param array   $scale_data Data related to scaling
+     * @param boolean $linear     If true, as a 1D array, else as a 2D array
+     * @param array   $output     Expected output
+     *
+     * @dataProvider providerForTestExtractPoints
+     * @return nothing
+     */
+    public function testExtractPoints($point_set, $scale_data, $linear, $output)
+    {
+        $this->assertEquals(
+            $this->_callProtectedFunction(
+                'extractPoints',
+                array($point_set, $scale_data, $linear)
+            ),
+            $output
+        );
+    }
+
+    /**
+     * data provider for testExtractPoints
+     *
+     * @return data for testExtractPoints
+     */
+    public function providerForTestExtractPoints()
     {
-        if ($index == null) {
-            $this->assertEquals($this->object->generateParams($wkt), $params);
-        } else {
-            $this->assertEquals(
-                $this->object->generateParams($wkt, $index),
-                $params
-            );
-        }
+        return array(
+            // with no scale data
+            array(
+                '12 35,48 75,69 23',
+                null,
+                false,
+                array(
+                    0 => array(12, 35),
+                    1 => array(48, 75),
+                    2 => array(69, 23),
+                ),
+            ),
+            // with scale data
+            array(
+                '12 35,48 75,69 23',
+                array(
+                    'x'      => 5,
+                    'y'      => 5,
+                    'scale'  => 2,
+                    'height' => 200,
+                ),
+                false,
+                array(
+                    0 => array(14, 140),
+                    1 => array(86, 60),
+                    2 => array(128, 164),
+                ),
+            ),
+            // linear output
+            array(
+                '12 35,48 75,69 23',
+                null,
+                true,
+                array(12, 35, 48, 75, 69, 23),
+            ),
+            // if a single part of a coordinate is empty
+            array(
+                '12 35,48 75,69 ',
+                null,
+                false,
+                array(
+                    0 => array(12, 35),
+                    1 => array(48, 75),
+                    2 => array('', ''),
+                ),
+            ),
+        );
     }
 }
 ?>
\ No newline at end of file
diff --git a/test/classes/gis/PMA_GIS_Linestring_test.php b/test/classes/gis/PMA_GIS_Linestring_test.php
index 4bef75c..05413e1 100644
--- a/test/classes/gis/PMA_GIS_Linestring_test.php
+++ b/test/classes/gis/PMA_GIS_Linestring_test.php
@@ -5,14 +5,14 @@
  * @package phpMyAdmin-test
  */
 
-require_once 'PMA_GIS_Geometry_test.php';
+require_once 'PMA_GIS_Geom_test.php';
 require_once 'libraries/gis/pma_gis_geometry.php';
 require_once 'libraries/gis/pma_gis_linestring.php';
 
 /**
  * Tests for PMA_GIS_Linestring class
  */
-class PMA_GIS_LinestringTest extends PMA_GIS_GeometryTest
+class PMA_GIS_LinestringTest extends PMA_GIS_GeomTest
 {
     /**
      * @var    PMA_GIS_Linestring
@@ -138,5 +138,39 @@ class PMA_GIS_LinestringTest extends PMA_GIS_GeometryTest
             )
         );
     }
+
+    /**
+     * test scaleRow method
+     *
+     * @param string $spatial spatial data of a row
+     * @param array  $min_max expected results
+     *
+     * @dataProvider providerForTestScaleRow
+     * @return nothing
+     */
+    public function testScaleRow($spatial, $min_max)
+    {
+        $this->assertEquals($this->object->scaleRow($spatial), $min_max);
+    }
+
+    /**
+     * data provider for testScaleRow
+     *
+     * @return data for testScaleRow
+     */
+    public function providerForTestScaleRow()
+    {
+        return array(
+            array(
+                'LINESTRING(12 35,48 75,69 23,25 45,14 53,35 78)',
+                array(
+                    'minX' => 12,
+                    'maxX' => 69,
+                    'minY' => 23,
+                    'maxY' => 78
+                )
+            )
+        );
+    }
 }
 ?>
\ No newline at end of file
diff --git a/test/classes/gis/PMA_GIS_Multilinestring_test.php b/test/classes/gis/PMA_GIS_Multilinestring_test.php
index d7b8132..a0ab50f 100644
--- a/test/classes/gis/PMA_GIS_Multilinestring_test.php
+++ b/test/classes/gis/PMA_GIS_Multilinestring_test.php
@@ -5,14 +5,14 @@
  * @package phpMyAdmin-test
  */
 
-require_once 'PMA_GIS_Geometry_test.php';
+require_once 'PMA_GIS_Geom_test.php';
 require_once 'libraries/gis/pma_gis_geometry.php';
 require_once 'libraries/gis/pma_gis_multilinestring.php';
 
 /**
  * Tests for PMA_GIS_Multilinestring class
  */
-class PMA_GIS_MultilinestringTest extends PMA_GIS_GeometryTest
+class PMA_GIS_MultilinestringTest extends PMA_GIS_GeomTest
 {
     /**
      * @var    PMA_GIS_Multilinestring
diff --git a/test/classes/gis/PMA_GIS_Multipoint_test.php b/test/classes/gis/PMA_GIS_Multipoint_test.php
index 8ab0aef..1d5fcdf 100644
--- a/test/classes/gis/PMA_GIS_Multipoint_test.php
+++ b/test/classes/gis/PMA_GIS_Multipoint_test.php
@@ -5,14 +5,14 @@
  * @package phpMyAdmin-test
  */
 
-require_once 'PMA_GIS_Geometry_test.php';
+require_once 'PMA_GIS_Geom_test.php';
 require_once 'libraries/gis/pma_gis_geometry.php';
 require_once 'libraries/gis/pma_gis_multipoint.php';
 
 /**
  * Tests for PMA_GIS_Multipoint class
  */
-class PMA_GIS_MultipointTest extends PMA_GIS_GeometryTest
+class PMA_GIS_MultipointTest extends PMA_GIS_GeomTest
 {
     /**
      * @var    PMA_GIS_Multipoint
diff --git a/test/classes/gis/PMA_GIS_Multipolygon_test.php b/test/classes/gis/PMA_GIS_Multipolygon_test.php
index 500cbae..1589f9d 100644
--- a/test/classes/gis/PMA_GIS_Multipolygon_test.php
+++ b/test/classes/gis/PMA_GIS_Multipolygon_test.php
@@ -5,14 +5,14 @@
  * @package phpMyAdmin-test
  */
 
-require_once 'PMA_GIS_Geometry_test.php';
+require_once 'PMA_GIS_Geom_test.php';
 require_once 'libraries/gis/pma_gis_geometry.php';
 require_once 'libraries/gis/pma_gis_multipolygon.php';
 
 /**
  * Tests for PMA_GIS_Multipolygon class
  */
-class PMA_GIS_MultipolygonTest extends PMA_GIS_GeometryTest
+class PMA_GIS_MultipolygonTest extends PMA_GIS_GeomTest
 {
     /**
      * @var    PMA_GIS_Multipolygon
diff --git a/test/classes/gis/PMA_GIS_Point_test.php b/test/classes/gis/PMA_GIS_Point_test.php
index a25a66a..9f9ef21 100644
--- a/test/classes/gis/PMA_GIS_Point_test.php
+++ b/test/classes/gis/PMA_GIS_Point_test.php
@@ -5,14 +5,14 @@
  * @package phpMyAdmin-test
  */
 
-require_once 'PMA_GIS_Geometry_test.php';
+require_once 'PMA_GIS_Geom_test.php';
 require_once 'libraries/gis/pma_gis_geometry.php';
 require_once 'libraries/gis/pma_gis_point.php';
 
 /**
  * Tests for PMA_GIS_Point class.
  */
-class PMA_GIS_PointTest extends PMA_GIS_GeometryTest
+class PMA_GIS_PointTest extends PMA_GIS_GeomTest
 {
     /**
      * @var    PMA_GIS_Point
diff --git a/test/classes/gis/PMA_GIS_Polygon_test.php b/test/classes/gis/PMA_GIS_Polygon_test.php
index 9a27e34..e4941d3 100644
--- a/test/classes/gis/PMA_GIS_Polygon_test.php
+++ b/test/classes/gis/PMA_GIS_Polygon_test.php
@@ -5,14 +5,14 @@
  * @package phpMyAdmin-test
  */
 
-require_once 'PMA_GIS_Geometry_test.php';
+require_once 'PMA_GIS_Geom_test.php';
 require_once 'libraries/gis/pma_gis_geometry.php';
 require_once 'libraries/gis/pma_gis_polygon.php';
 
 /**
  * Tests for PMA_GIS_Polygon class
  */
-class PMA_GIS_PolygonTest extends PMA_GIS_GeometryTest
+class PMA_GIS_PolygonTest extends PMA_GIS_GeomTest
 {
     /**
      * @var    PMA_GIS_Polygon


hooks/post-receive
-- 
phpMyAdmin




More information about the Git mailing list