3 * Tests for PMA_GIS_modifyQuery method
5 * @package phpMyAdmin-test
8 require_once 'libraries/sqlparser.lib.php';
9 require_once 'libraries/common.lib.php';
13 require_once 'libraries/gis_visualization.lib.php';
15 class PMA_GIS_modifyQueryTest
extends PHPUnit_Framework_TestCase
18 * Test PMA_GIS_modifyQuery method
20 * @param string $sql_query query to modify
21 * @param array $settings visualization settings
22 * @param string $modified_query modified query
24 * @dataProvider provider
27 public function testModifyQuery($sql_query, $settings, $modified_query)
30 PMA_GIS_modifyQuery($sql_query, $settings),
36 * data provider for testModifyQuery
38 * @return data for testModifyQuery
40 public function provider()
45 'SELECT * FROM `foo` WHERE `bar` = `zoo`',
46 array('spatialColumn' => 'moo', 'labelColumn' => 'noo'),
47 'SELECT `noo`, ASTEXT(`moo`) AS `moo`, SRID(`moo`) AS `srid` FROM `foo` WHERE `bar` = `zoo`'
49 // select * with no label column
51 'SELECT * FROM `foo` WHERE `bar` = `zoo`',
52 array('spatialColumn' => 'moo'),
53 'SELECT ASTEXT(`moo`) AS `moo`, SRID(`moo`) AS `srid` FROM `foo` WHERE `bar` = `zoo`'
57 'SELECT `aaa`, `moo`, `bbb`, `noo` FROM `foo` WHERE `bar` = `zoo`',
58 array('spatialColumn' => 'moo', 'labelColumn' => 'noo'),
59 'SELECT `noo`, ASTEXT(`moo`) AS `moo`, SRID(`moo`) AS `srid` FROM `foo` WHERE `bar` = `zoo`'
61 // no labelColumn defined
63 'SELECT `moo`, `noo` FROM `foo` WHERE `bar` = `zoo`',
64 array('spatialColumn' => 'moo'),
65 'SELECT ASTEXT(`moo`) AS `moo`, SRID(`moo`) AS `srid` FROM `foo` WHERE `bar` = `zoo`'
67 // alias for spatialColumn
69 'SELECT `aaa` AS `moo`, `noo` FROM `foo` WHERE `bar` = `zoo`',
70 array('spatialColumn' => 'moo', 'labelColumn' => 'noo'),
71 'SELECT `noo`, ASTEXT(`aaa`) AS `moo`, SRID(`aaa`) AS `srid` FROM `foo` WHERE `bar` = `zoo`'
73 // alias for labelColumn
75 'SELECT `moo`, `bbb` AS `noo` FROM `foo` WHERE `bar` = `zoo`',
76 array('spatialColumn' => 'moo', 'labelColumn' => 'noo'),
77 'SELECT `bbb` AS `noo`, ASTEXT(`moo`) AS `moo`, SRID(`moo`) AS `srid` FROM `foo` WHERE `bar` = `zoo`'
79 // with database names
81 'SELECT `db`.`moo`, `db`.`noo` FROM `foo` WHERE `bar` = `zoo`',
82 array('spatialColumn' => 'moo', 'labelColumn' => 'noo'),
83 'SELECT `db`.`noo`, ASTEXT(`db`.`moo`) AS `moo`, SRID(`db`.`moo`) AS `srid` FROM `foo` WHERE `bar` = `zoo`'
85 // database names plus alias
87 'SELECT `db`.`aaa` AS `moo`, `noo` FROM `foo` WHERE `bar` = `zoo`',
88 array('spatialColumn' => 'moo', 'labelColumn' => 'noo'),
89 'SELECT `noo`, ASTEXT(`db`.`aaa`) AS `moo`, SRID(`db`.`aaa`) AS `srid` FROM `foo` WHERE `bar` = `zoo`'