From 028575cc3a551f80b0a454079a878611da634d79 Mon Sep 17 00:00:00 2001 From: adamgsoc2013 Date: Fri, 19 Jul 2013 20:43:00 +0800 Subject: [PATCH 1/8] add sub class to test different env setting --- test/classes/PMA_Table_test.php | 38 +++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/test/classes/PMA_Table_test.php b/test/classes/PMA_Table_test.php index 9ffd636543..fb042ff260 100644 --- a/test/classes/PMA_Table_test.php +++ b/test/classes/PMA_Table_test.php @@ -202,11 +202,14 @@ class PMA_Table_Test extends PHPUnit_Framework_TestCase ->will($this->returnValue($getUniqueColumns_sql)); $GLOBALS['dbi'] = $dbi; + + //RunKit, we test: + //1. without Runkit, PMA_DRIZZLE = true; + //2. with Runkit, PMA_DRIZZLE = false; + if (!defined("PMA_DRIZZLE")) { define("PMA_DRIZZLE", true); } - - //RunKit if (PMA_HAS_RUNKIT) { runkit_constant_redefine("PMA_DRIZZLE", false); } @@ -689,6 +692,37 @@ class PMA_Table_Test extends PHPUnit_Framework_TestCase } } +/** + * + * Tests behaviour of PMA_Table class with Runkit and PMA_Drizzle = false + * + * @package PhpMyAdmin-test + */ +class PMA_Table_Runkit_Test extends PMA_Table_Test +{ + /** + * Configures environment + * + * @return void + */ + protected function setUp() + { + //we test: + //1. without Runkit, PMA_DRIZZLE = false; + //2. with Runkit, PMA_DRIZZLE = true; + if (!defined("PMA_DRIZZLE")) { + define("PMA_DRIZZLE", false); + } + + parent::setUp(); + + //RunKit + if (PMA_HAS_RUNKIT) { + runkit_constant_redefine("PMA_DRIZZLE", true); + } + } +} + //mock PMA Class DataBasePMAMock { From 7779e5acc87c1292bdb569991505036fe6619abf Mon Sep 17 00:00:00 2001 From: adamgsoc2013 Date: Fri, 19 Jul 2013 21:15:15 +0800 Subject: [PATCH 2/8] add test case for PMA_TableSearch --- test/classes/PMA_TableSearch_test.php | 108 ++++++++++++++++++++++++-- 1 file changed, 102 insertions(+), 6 deletions(-) diff --git a/test/classes/PMA_TableSearch_test.php b/test/classes/PMA_TableSearch_test.php index 8c27cf4e87..cb1f1bcfaa 100644 --- a/test/classes/PMA_TableSearch_test.php +++ b/test/classes/PMA_TableSearch_test.php @@ -136,7 +136,7 @@ class PMA_TableSearch_Test extends PHPUnit_Framework_TestCase */ public function testGetSelectionForm() { - //$this->_searchType == 'zoom' + //$this->_searchType == 'zoom' $tableSearch = new PMA_TableSearch("PMA", "PMA_BookMark", "zoom"); $url_goto = "http://phpmyadmin.net"; $form = $tableSearch->getSelectionForm($url_goto); @@ -149,7 +149,7 @@ class PMA_TableSearch_Test extends PHPUnit_Framework_TestCase $form ); - //$this->_searchType == 'normal' + //$this->_searchType == 'normal' $tableSearch = new PMA_TableSearch("PMA", "PMA_BookMark", "normal"); $url_goto = "http://phpmyadmin.net"; $form = $tableSearch->getSelectionForm($url_goto); @@ -162,7 +162,7 @@ class PMA_TableSearch_Test extends PHPUnit_Framework_TestCase $form ); - //$this->_searchType == 'replace' + //$this->_searchType == 'replace' $tableSearch = new PMA_TableSearch("PMA", "PMA_BookMark", "replace"); $url_goto = "http://phpmyadmin.net"; $form = $tableSearch->getSelectionForm($url_goto); @@ -197,7 +197,7 @@ class PMA_TableSearch_Test extends PHPUnit_Framework_TestCase $this->assertContains( __('Zoom Search'), $html - ); + ); $this->assertContains( __('Find and Replace'), $html @@ -223,7 +223,31 @@ class PMA_TableSearch_Test extends PHPUnit_Framework_TestCase json_encode($data), $html ); - + + } + + /** + * Test for replace + * + * @return void + */ + public function testReplace() + { + $tableSearch = new PMA_TableSearch("PMA", "PMA_BookMark", "zoom"); + $columnIndex = 0; + $find = "Field"; + $replaceWith = "Column"; + $charSet = "UTF-8"; + $tableSearch->replace($columnIndex, $find, $replaceWith, $charSet); + + $sql_query = $GLOBALS['sql_query']; + $result = "UPDATE `PMA`.`PMA_BookMark` SET `Field1` = " + . "REPLACE(`Field1`, 'Field', 'Column') " + . "WHERE `Field1` LIKE '%Field%' COLLATE UTF-8_bin"; + $this->assertEquals( + $result, + $sql_query + ); } /** @@ -243,7 +267,79 @@ class PMA_TableSearch_Test extends PHPUnit_Framework_TestCase __('Replace with:'), $html ); - + + } + + /** + * Test for getReplacePreview + * + * @return void + */ + public function testGetReplacePreview() + { + + $value = array( + 'value', + 'replace_value', + 'count' + ); + + $dbi = $GLOBALS['dbi']; + + $dbi->expects($this->at(3))->method('fetchRow') + ->will($this->returnValue($value)); + + $dbi->expects($this->at(4))->method('fetchRow') + ->will($this->returnValue(false)); + + $GLOBALS['dbi'] = $dbi; + + $tableSearch = new PMA_TableSearch("PMA", "PMA_BookMark", "zoom"); + $columnIndex = 0; + $find = "Field"; + $replaceWith = "Column"; + $charSet = "UTF-8"; + + $html = $tableSearch->getReplacePreview( + $columnIndex, + $find, + $replaceWith, + $charSet + ); + + $this->assertContains( + '
assertContains( + '', + $html + ); + $this->assertContains( + __('Find and replace - preview'), + $html + ); + $this->assertContains( + __('Original string'), + $html + ); + $this->assertContains( + __('Replaced string'), + $html + ); + + $this->assertContains( + 'value', + $html + ); + $this->assertContains( + 'replace_value', + $html + ); + $this->assertContains( + 'count', + $html + ); } } ?> From cc375f8c4af3db9066a37b315ad3e2c976ccdecd Mon Sep 17 00:00:00 2001 From: adamgsoc2013 Date: Fri, 19 Jul 2013 22:12:24 +0800 Subject: [PATCH 3/8] fix the DBI setting --- .../schema/Dia_Relation_Schema_test.php | 43 +++++++++++++++++-- .../schema/Eps_Relation_Schema_test.php | 41 ++++++++++++++++-- .../schema/Pdf_Relation_Schema_test.php | 41 ++++++++++++++++-- .../schema/Svg_Relation_Schema_test.php | 41 ++++++++++++++++-- 4 files changed, 153 insertions(+), 13 deletions(-) diff --git a/test/classes/schema/Dia_Relation_Schema_test.php b/test/classes/schema/Dia_Relation_Schema_test.php index e475fe8f3c..91da7d6d8f 100644 --- a/test/classes/schema/Dia_Relation_Schema_test.php +++ b/test/classes/schema/Dia_Relation_Schema_test.php @@ -11,7 +11,9 @@ require_once 'libraries/Util.class.php'; require_once 'libraries/relation.lib.php'; require_once 'libraries/url_generating.lib.php'; +require_once 'libraries/sqlparser.lib.php'; require_once 'libraries/php-gettext/gettext.inc'; +require_once 'libraries/Index.class.php'; require_once 'libraries/database_interface.inc.php'; require_once 'libraries/Response.class.php'; require_once 'libraries/schema/Dia_Relation_Schema.class.php'; @@ -46,11 +48,13 @@ class PMA_Dia_Relation_Schema_Test extends PHPUnit_Framework_TestCase $_POST['export_type'] = 'PMA_ExportType'; $GLOBALS['server'] = 1; $GLOBALS['cfg']['ServerDefault'] = 1; + $GLOBALS['cfg']['Server']['table_coords'] = "table_name"; + $GLOBALS['cfgRelation']['db'] = "PMA"; + $GLOBALS['cfgRelation']['table_coords'] = "table_name"; $dbi = $this->getMockBuilder('PMA_DatabaseInterface') ->disableOriginalConstructor() ->getMock(); - $GLOBALS['dbi'] = $dbi; $dbi->expects($this->any()) ->method('numRows') @@ -65,12 +69,43 @@ class PMA_Dia_Relation_Schema_Test extends PHPUnit_Framework_TestCase ->will($this->returnValue("executed_1")); $fetchArrayReturn = array( - 'table_name' => 'table_name' + 'table_name' => 'pma_table_name' ); - $dbi->expects($this->at(1)) + + $dbi->expects($this->at(2)) ->method('fetchAssoc') ->will($this->returnValue($fetchArrayReturn)); + $dbi->expects($this->at(3)) + ->method('fetchAssoc') + ->will($this->returnValue(false)); + $getIndexesResult = array( + array( + 'Table' => 'pma_tbl', + 'Field' => 'field1', + 'Key' => 'PRIMARY', + 'Key_name' => "Key_name", + 'Column_name' => "Column_name" + ) + ); + $dbi->expects($this->once())->method('getTableIndexes') + ->will($this->returnValue($getIndexesResult)); + + $fetchValue = "CREATE TABLE `pma_bookmark` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `dbase` varchar(255) COLLATE utf8_bin NOT NULL DEFAULT '', + `user` varchar(255) COLLATE utf8_bin NOT NULL DEFAULT '', + `label` varchar(255) CHARACTER SET utf8 NOT NULL DEFAULT '', + `query` text COLLATE utf8_bin NOT NULL, + PRIMARY KEY (`id`) + ) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Bookmarks'"; + + $dbi->expects($this->once()) + ->method('fetchValue') + ->will($this->returnValue($fetchValue)); + + $GLOBALS['dbi'] = $dbi; + $this->object = new PMA_Dia_Relation_Schema(); } @@ -94,7 +129,7 @@ class PMA_Dia_Relation_Schema_Test extends PHPUnit_Framework_TestCase * @group medium */ public function testSetProperty() - { + { $this->assertEquals( 33, $this->object->pageNumber diff --git a/test/classes/schema/Eps_Relation_Schema_test.php b/test/classes/schema/Eps_Relation_Schema_test.php index c33d46aee2..61f685a417 100644 --- a/test/classes/schema/Eps_Relation_Schema_test.php +++ b/test/classes/schema/Eps_Relation_Schema_test.php @@ -11,7 +11,9 @@ require_once 'libraries/Util.class.php'; require_once 'libraries/relation.lib.php'; require_once 'libraries/url_generating.lib.php'; +require_once 'libraries/sqlparser.lib.php'; require_once 'libraries/php-gettext/gettext.inc'; +require_once 'libraries/Index.class.php'; require_once 'libraries/database_interface.inc.php'; require_once 'libraries/schema/Eps_Relation_Schema.class.php'; @@ -47,11 +49,13 @@ class PMA_Eps_Relation_Schema_Test extends PHPUnit_Framework_TestCase $_POST['export_type'] = 'PMA_ExportType'; $GLOBALS['server'] = 1; $GLOBALS['cfg']['ServerDefault'] = 1; + $GLOBALS['cfg']['Server']['table_coords'] = "table_name"; + $GLOBALS['cfgRelation']['db'] = "PMA"; + $GLOBALS['cfgRelation']['table_coords'] = "table_name"; $dbi = $this->getMockBuilder('PMA_DatabaseInterface') ->disableOriginalConstructor() ->getMock(); - $GLOBALS['dbi'] = $dbi; $dbi->expects($this->any()) ->method('numRows') @@ -66,11 +70,42 @@ class PMA_Eps_Relation_Schema_Test extends PHPUnit_Framework_TestCase ->will($this->returnValue("executed_1")); $fetchArrayReturn = array( - 'table_name' => 'table_name' + 'table_name' => 'pma_table_name' ); - $dbi->expects($this->at(1)) + + $dbi->expects($this->at(2)) ->method('fetchAssoc') ->will($this->returnValue($fetchArrayReturn)); + $dbi->expects($this->at(3)) + ->method('fetchAssoc') + ->will($this->returnValue(false)); + + $getIndexesResult = array( + array( + 'Table' => 'pma_tbl', + 'Field' => 'field1', + 'Key' => 'PRIMARY', + 'Key_name' => "Key_name", + 'Column_name' => "Column_name" + ) + ); + $dbi->expects($this->once())->method('getTableIndexes') + ->will($this->returnValue($getIndexesResult)); + + $fetchValue = "CREATE TABLE `pma_bookmark` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `dbase` varchar(255) COLLATE utf8_bin NOT NULL DEFAULT '', + `user` varchar(255) COLLATE utf8_bin NOT NULL DEFAULT '', + `label` varchar(255) CHARACTER SET utf8 NOT NULL DEFAULT '', + `query` text COLLATE utf8_bin NOT NULL, + PRIMARY KEY (`id`) + ) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Bookmarks'"; + + $dbi->expects($this->once()) + ->method('fetchValue') + ->will($this->returnValue($fetchValue)); + + $GLOBALS['dbi'] = $dbi; $this->object = new PMA_Eps_Relation_Schema(); } diff --git a/test/classes/schema/Pdf_Relation_Schema_test.php b/test/classes/schema/Pdf_Relation_Schema_test.php index ff8d926726..9426114078 100644 --- a/test/classes/schema/Pdf_Relation_Schema_test.php +++ b/test/classes/schema/Pdf_Relation_Schema_test.php @@ -11,7 +11,9 @@ require_once 'libraries/Util.class.php'; require_once 'libraries/relation.lib.php'; require_once 'libraries/url_generating.lib.php'; +require_once 'libraries/sqlparser.lib.php'; require_once 'libraries/php-gettext/gettext.inc'; +require_once 'libraries/Index.class.php'; require_once 'libraries/database_interface.inc.php'; require_once 'libraries/schema/Pdf_Relation_Schema.class.php'; @@ -48,11 +50,13 @@ class PMA_Pdf_Relation_Schema_Test extends PHPUnit_Framework_TestCase $_POST['with_doc'] = 'on'; $GLOBALS['server'] = 1; $GLOBALS['cfg']['ServerDefault'] = 1; + $GLOBALS['cfg']['Server']['table_coords'] = "table_name"; + $GLOBALS['cfgRelation']['db'] = "PMA"; + $GLOBALS['cfgRelation']['table_coords'] = "table_name"; $dbi = $this->getMockBuilder('PMA_DatabaseInterface') ->disableOriginalConstructor() ->getMock(); - $GLOBALS['dbi'] = $dbi; $dbi->expects($this->any()) ->method('numRows') @@ -67,11 +71,42 @@ class PMA_Pdf_Relation_Schema_Test extends PHPUnit_Framework_TestCase ->will($this->returnValue("executed_1")); $fetchArrayReturn = array( - 'table_name' => 'table_name' + 'table_name' => 'pma_table_name' ); - $dbi->expects($this->at(1)) + + $dbi->expects($this->at(2)) ->method('fetchAssoc') ->will($this->returnValue($fetchArrayReturn)); + $dbi->expects($this->at(3)) + ->method('fetchAssoc') + ->will($this->returnValue(false)); + + $getIndexesResult = array( + array( + 'Table' => 'pma_tbl', + 'Field' => 'field1', + 'Key' => 'PRIMARY', + 'Key_name' => "Key_name", + 'Column_name' => "Column_name" + ) + ); + $dbi->expects($this->once())->method('getTableIndexes') + ->will($this->returnValue($getIndexesResult)); + + $fetchValue = "CREATE TABLE `pma_bookmark` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `dbase` varchar(255) COLLATE utf8_bin NOT NULL DEFAULT '', + `user` varchar(255) COLLATE utf8_bin NOT NULL DEFAULT '', + `label` varchar(255) CHARACTER SET utf8 NOT NULL DEFAULT '', + `query` text COLLATE utf8_bin NOT NULL, + PRIMARY KEY (`id`) + ) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Bookmarks'"; + + $dbi->expects($this->once()) + ->method('fetchValue') + ->will($this->returnValue($fetchValue)); + + $GLOBALS['dbi'] = $dbi; $this->object = new PMA_Pdf_Relation_Schema(); } diff --git a/test/classes/schema/Svg_Relation_Schema_test.php b/test/classes/schema/Svg_Relation_Schema_test.php index 7c658840f6..56e6c4d152 100644 --- a/test/classes/schema/Svg_Relation_Schema_test.php +++ b/test/classes/schema/Svg_Relation_Schema_test.php @@ -11,7 +11,9 @@ require_once 'libraries/Util.class.php'; require_once 'libraries/relation.lib.php'; require_once 'libraries/url_generating.lib.php'; +require_once 'libraries/sqlparser.lib.php'; require_once 'libraries/php-gettext/gettext.inc'; +require_once 'libraries/Index.class.php'; require_once 'libraries/database_interface.inc.php'; require_once 'libraries/schema/Svg_Relation_Schema.class.php'; @@ -48,11 +50,13 @@ class PMA_Svg_Relation_Schema_Test extends PHPUnit_Framework_TestCase $_POST['with_doc'] = 'on'; $GLOBALS['server'] = 1; $GLOBALS['cfg']['ServerDefault'] = 1; + $GLOBALS['cfg']['Server']['table_coords'] = "table_name"; + $GLOBALS['cfgRelation']['db'] = "PMA"; + $GLOBALS['cfgRelation']['table_coords'] = "table_name"; $dbi = $this->getMockBuilder('PMA_DatabaseInterface') ->disableOriginalConstructor() ->getMock(); - $GLOBALS['dbi'] = $dbi; $dbi->expects($this->any()) ->method('numRows') @@ -67,11 +71,42 @@ class PMA_Svg_Relation_Schema_Test extends PHPUnit_Framework_TestCase ->will($this->returnValue("executed_1")); $fetchArrayReturn = array( - 'table_name' => 'table_name' + 'table_name' => 'pma_table_name' ); - $dbi->expects($this->at(1)) + + $dbi->expects($this->at(2)) ->method('fetchAssoc') ->will($this->returnValue($fetchArrayReturn)); + $dbi->expects($this->at(3)) + ->method('fetchAssoc') + ->will($this->returnValue(false)); + + $getIndexesResult = array( + array( + 'Table' => 'pma_tbl', + 'Field' => 'field1', + 'Key' => 'PRIMARY', + 'Key_name' => "Key_name", + 'Column_name' => "Column_name" + ) + ); + $dbi->expects($this->once())->method('getTableIndexes') + ->will($this->returnValue($getIndexesResult)); + + $fetchValue = "CREATE TABLE `pma_bookmark` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `dbase` varchar(255) COLLATE utf8_bin NOT NULL DEFAULT '', + `user` varchar(255) COLLATE utf8_bin NOT NULL DEFAULT '', + `label` varchar(255) CHARACTER SET utf8 NOT NULL DEFAULT '', + `query` text COLLATE utf8_bin NOT NULL, + PRIMARY KEY (`id`) + ) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Bookmarks'"; + + $dbi->expects($this->once()) + ->method('fetchValue') + ->will($this->returnValue($fetchValue)); + + $GLOBALS['dbi'] = $dbi; $this->object = new PMA_Svg_Relation_Schema(); } From 232f0bfaa0ba8bb9ee02daebd1feea377c7a71c8 Mon Sep 17 00:00:00 2001 From: adamgsoc2013 Date: Fri, 19 Jul 2013 23:39:06 +0800 Subject: [PATCH 4/8] mock fetchrow for DBI --- .../schema/Dia_Relation_Schema_test.php | 2 +- .../schema/Eps_Relation_Schema_test.php | 2 +- .../schema/Pdf_Relation_Schema_test.php | 41 ++++++++++++++++++- .../schema/Svg_Relation_Schema_test.php | 2 +- 4 files changed, 43 insertions(+), 4 deletions(-) diff --git a/test/classes/schema/Dia_Relation_Schema_test.php b/test/classes/schema/Dia_Relation_Schema_test.php index 91da7d6d8f..340e2ac52c 100644 --- a/test/classes/schema/Dia_Relation_Schema_test.php +++ b/test/classes/schema/Dia_Relation_Schema_test.php @@ -88,7 +88,7 @@ class PMA_Dia_Relation_Schema_Test extends PHPUnit_Framework_TestCase 'Column_name' => "Column_name" ) ); - $dbi->expects($this->once())->method('getTableIndexes') + $dbi->expects($this->any())->method('getTableIndexes') ->will($this->returnValue($getIndexesResult)); $fetchValue = "CREATE TABLE `pma_bookmark` ( diff --git a/test/classes/schema/Eps_Relation_Schema_test.php b/test/classes/schema/Eps_Relation_Schema_test.php index 61f685a417..71ffbb7d7a 100644 --- a/test/classes/schema/Eps_Relation_Schema_test.php +++ b/test/classes/schema/Eps_Relation_Schema_test.php @@ -89,7 +89,7 @@ class PMA_Eps_Relation_Schema_Test extends PHPUnit_Framework_TestCase 'Column_name' => "Column_name" ) ); - $dbi->expects($this->once())->method('getTableIndexes') + $dbi->expects($this->any())->method('getTableIndexes') ->will($this->returnValue($getIndexesResult)); $fetchValue = "CREATE TABLE `pma_bookmark` ( diff --git a/test/classes/schema/Pdf_Relation_Schema_test.php b/test/classes/schema/Pdf_Relation_Schema_test.php index 9426114078..6f60534d0a 100644 --- a/test/classes/schema/Pdf_Relation_Schema_test.php +++ b/test/classes/schema/Pdf_Relation_Schema_test.php @@ -14,6 +14,7 @@ require_once 'libraries/url_generating.lib.php'; require_once 'libraries/sqlparser.lib.php'; require_once 'libraries/php-gettext/gettext.inc'; require_once 'libraries/Index.class.php'; +require_once 'libraries/Table.class.php'; require_once 'libraries/database_interface.inc.php'; require_once 'libraries/schema/Pdf_Relation_Schema.class.php'; @@ -48,9 +49,18 @@ class PMA_Pdf_Relation_Schema_Test extends PHPUnit_Framework_TestCase $_POST['paper'] = 'paper'; $_POST['export_type'] = 'PMA_ExportType'; $_POST['with_doc'] = 'on'; + $GLOBALS['server'] = 1; + $GLOBALS['cfg']['Server']['pmadb'] = "pmadb"; + $GLOBALS['cfg']['LimitChars'] = 100; $GLOBALS['cfg']['ServerDefault'] = 1; + $GLOBALS['cfg']['Server']['user'] = "user"; $GLOBALS['cfg']['Server']['table_coords'] = "table_name"; + $GLOBALS['cfg']['Server']['bookmarktable'] = "bookmarktable"; + $GLOBALS['cfg']['Server']['relation'] = "relation"; + $GLOBALS['cfg']['Server']['relation'] = "relation"; + $GLOBALS['cfg']['Server']['table_info'] = "table_info"; + $GLOBALS['cfgRelation']['db'] = "PMA"; $GLOBALS['cfgRelation']['table_coords'] = "table_name"; @@ -81,6 +91,35 @@ class PMA_Pdf_Relation_Schema_Test extends PHPUnit_Framework_TestCase ->method('fetchAssoc') ->will($this->returnValue(false)); + $fetchRowReturn = array( + 'table_name' + ); + + //let fetchRow have more results + for ($index=0; $index<10; ++$index) { + $dbi->expects($this->at($index)) + ->method('fetchRow') + ->will($this->returnValue($fetchRowReturn)); + } + + $dbi->expects($this->at(10)) + ->method('fetchRow') + ->will($this->returnValue($fetchRowReturn)); + + $fields_info = array( + "Host" => array( + "Field" => "host", + "Type" => "char(60)", + "Null" => "NO", + 'Extra' => "Extra", + ) + ); + $dbi->expects($this->any())->method('getColumns') + ->will($this->returnValue($fields_info)); + + $dbi->expects($this->any())->method('selectDb') + ->will($this->returnValue(true)); + $getIndexesResult = array( array( 'Table' => 'pma_tbl', @@ -90,7 +129,7 @@ class PMA_Pdf_Relation_Schema_Test extends PHPUnit_Framework_TestCase 'Column_name' => "Column_name" ) ); - $dbi->expects($this->once())->method('getTableIndexes') + $dbi->expects($this->any())->method('getTableIndexes') ->will($this->returnValue($getIndexesResult)); $fetchValue = "CREATE TABLE `pma_bookmark` ( diff --git a/test/classes/schema/Svg_Relation_Schema_test.php b/test/classes/schema/Svg_Relation_Schema_test.php index 56e6c4d152..30a4008cbd 100644 --- a/test/classes/schema/Svg_Relation_Schema_test.php +++ b/test/classes/schema/Svg_Relation_Schema_test.php @@ -90,7 +90,7 @@ class PMA_Svg_Relation_Schema_Test extends PHPUnit_Framework_TestCase 'Column_name' => "Column_name" ) ); - $dbi->expects($this->once())->method('getTableIndexes') + $dbi->expects($this->any())->method('getTableIndexes') ->will($this->returnValue($getIndexesResult)); $fetchValue = "CREATE TABLE `pma_bookmark` ( From da4119a3810b6e9b1d059c033d4830e13d6d1891 Mon Sep 17 00:00:00 2001 From: adamgsoc2013 Date: Fri, 19 Jul 2013 23:59:25 +0800 Subject: [PATCH 5/8] add PMA_Table::$cache --- test/classes/PMA_Table_test.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/classes/PMA_Table_test.php b/test/classes/PMA_Table_test.php index fb042ff260..727431a73b 100644 --- a/test/classes/PMA_Table_test.php +++ b/test/classes/PMA_Table_test.php @@ -46,6 +46,12 @@ class PMA_Table_Test extends PHPUnit_Framework_TestCase $GLOBALS['pmaThemeImage'] = 'themes/dot.gif'; $GLOBALS['is_ajax_request'] = false; $GLOBALS['cfgRelation'] = PMA_getRelationsParam(); + PMA_Table::$cache["PMA"]["PMA_BookMark"] = array( + 'ENGINE' => true, + 'Create_time' => true, + 'TABLE_TYPE' => true, + 'Comment' => true, + ); $dbi = $this->getMockBuilder('PMA_DatabaseInterface') ->disableOriginalConstructor() From ea81960b6c9fba0c6e8d2641812dfeb2abd6c359 Mon Sep 17 00:00:00 2001 From: Spun Nakandala Date: Sun, 21 Jul 2013 04:32:17 +0530 Subject: [PATCH 6/8] removed include sql.php from tbl_select.php --- tbl_select.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tbl_select.php b/tbl_select.php index 995eaef85f..82189d7ad3 100644 --- a/tbl_select.php +++ b/tbl_select.php @@ -15,6 +15,7 @@ require_once 'libraries/common.inc.php'; require_once 'libraries/mysql_charsets.inc.php'; require_once 'libraries/TableSearch.class.php'; +require_once 'libraries/sql.lib.php'; $response = PMA_Response::getInstance(); $header = $response->getHeader(); @@ -65,6 +66,16 @@ if (! isset($_POST['columnsToDisplay']) && ! isset($_POST['displayAllColumns'])) * Selection criteria have been submitted -> do the work */ $sql_query = $table_search->buildSqlQuery(); - include 'sql.php'; + + /** + * Parse and analyze the query + */ + require_once 'libraries/parse_analyze.inc.php'; + + PMA_executeQueryAndSendQueryResponse( + $analyzed_sql_results, false, $db, $table, null, null, null, false, null, + null, null, null, $goto, $pmaThemeImage, null, null, null, $sql_query, + null, null + ); } ?> From 3c83f1f6d296f174efcb1e3cfbb85c6616d057ad Mon Sep 17 00:00:00 2001 From: Marc Delisle Date: Sun, 21 Jul 2013 07:51:36 -0400 Subject: [PATCH 7/8] Fix comment due to refactoring --- tbl_select.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tbl_select.php b/tbl_select.php index 82189d7ad3..e0fd01f113 100644 --- a/tbl_select.php +++ b/tbl_select.php @@ -4,7 +4,7 @@ * Handles table search tab * * display table search form, create SQL query from form data - * and include sql.php to execute it + * and call PMA_executeQueryAndSendQueryResponse() to execute it * * @package PhpMyAdmin */ From 1b34f8fd28c157f695384f7c52dc3961a1ab83f1 Mon Sep 17 00:00:00 2001 From: Marc Delisle Date: Sun, 21 Jul 2013 08:58:05 -0400 Subject: [PATCH 8/8] Fix typos and clarify comment --- libraries/display_export.lib.php | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/libraries/display_export.lib.php b/libraries/display_export.lib.php index 9fd9aa4678..9630e427e9 100644 --- a/libraries/display_export.lib.php +++ b/libraries/display_export.lib.php @@ -2,7 +2,7 @@ /* vim: set expandtab sw=4 ts=4 sts=4: */ /** - * functions for displaying server export + * functions for displaying server, database and table export * * @usedby server_export.php and display_export.inc.php * @@ -29,7 +29,7 @@ function PMA_exportCheckboxCheck($str) /** * Prints Html For Export Selection Options * - * @param String $tmp_select Tmp seleted method of export + * @param String $tmp_select Tmp selected method of export * * @return string */ @@ -398,7 +398,7 @@ function PMA_getHtmlForExportOptionsQuickExport() * * @return string */ -function PMA_getHtmlForExportOptionsOuputSaveDir() +function PMA_getHtmlForExportOptionsOutputSaveDir() { global $cfg; $html = '
  • '; @@ -434,7 +434,7 @@ function PMA_getHtmlForExportOptionsOuputSaveDir() * * @return string */ -function PMA_getHtmlForExportOptionsOuputFormat($export_type) +function PMA_getHtmlForExportOptionsOutputFormat($export_type) { $html = '
  • '; $html .= '
  • '; $html .= ''; $html .= '
      '; if (isset($cfg['SaveDir']) && !empty($cfg['SaveDir'])) { - $html .= PMA_getHtmlForExportOptionsOuputSaveDir(); + $html .= PMA_getHtmlForExportOptionsOutputSaveDir(); } - $html .= PMA_getHtmlForExportOptionsOuputFormat($export_type); + $html .= PMA_getHtmlForExportOptionsOutputFormat($export_type); // charset of file if ($GLOBALS['PMA_recoding_engine'] != PMA_CHARSET_NONE) { - $html .= PMA_getHtmlForExportOptionsOuputCharset(); + $html .= PMA_getHtmlForExportOptionsOutputCharset(); } // end if - $html .= PMA_getHtmlForExportOptionsOuputCompression(); + $html .= PMA_getHtmlForExportOptionsOutputCompression(); $html .= '
    '; $html .= '
  • '; - $html .= PMA_getHtmlForExportOptionsOuputRadio(); + $html .= PMA_getHtmlForExportOptionsOutputRadio(); $html .= ''; $html .= ''; @@ -697,12 +697,9 @@ function PMA_getHtmlForExportOptions( $html .= PMA_getHtmlForExportOptionsQuickExport(); } - $html .= PMA_getHtmlForExportOptionsOuput($export_type); + $html .= PMA_getHtmlForExportOptionsOutput($export_type); $html .= PMA_getHtmlForExportOptionsFormat($export_list); return $html; } ?> - - - \ No newline at end of file