diff --git a/test/classes/PMA_TableReplaceSearch_test.php b/test/classes/PMA_TableReplaceSearch_test.php index 38b4611634..422a5b6886 100644 --- a/test/classes/PMA_TableReplaceSearch_test.php +++ b/test/classes/PMA_TableReplaceSearch_test.php @@ -35,29 +35,29 @@ class PMA_TableReplaceSearchTest extends PHPUnit_Framework_TestCase protected function setup() { // @todo: Replace this test with TableSearchController test -// $this->_object = $this->getMock( -// 'PMA_TableSearch', -// array('_loadTableInfo'), -// array(), -// '', -// false -// ); -// -// $reflection = new \ReflectionClass('PMA_TableSearch'); -// -// // set database, table names -// $attrDb = $reflection->getProperty('_db'); -// $attrDb->setAccessible(true); -// $attrDb->setValue($this->_object, 'dbName'); -// $attrTable = $reflection->getProperty('_table'); -// $attrTable->setAccessible(true); -// $attrTable->setValue($this->_object, 'tableName'); -// -// // set column names list -// $attrColNames = $reflection->getProperty('_columnNames'); -// $attrColNames->setAccessible(true); -// $columnNames = array('column1'); -// $attrColNames->setValue($this->_object, $columnNames); + /*$this->_object = $this->getMock( + 'PMA_TableSearch', + array('_loadTableInfo'), + array(), + '', + false + ); + + $reflection = new \ReflectionClass('PMA_TableSearch'); + + // set database, table names + $attrDb = $reflection->getProperty('_db'); + $attrDb->setAccessible(true); + $attrDb->setValue($this->_object, 'dbName'); + $attrTable = $reflection->getProperty('_table'); + $attrTable->setAccessible(true); + $attrTable->setValue($this->_object, 'tableName'); + + // set column names list + $attrColNames = $reflection->getProperty('_columnNames'); + $attrColNames->setAccessible(true); + $columnNames = array('column1'); + $attrColNames->setValue($this->_object, $columnNames);*/ } /** @@ -69,51 +69,51 @@ class PMA_TableReplaceSearchTest extends PHPUnit_Framework_TestCase public function testGetReplacePreview() { // @todo: Replace this test with TableSearchController test -// //mock DBI -// $dbi = $this->getMockBuilder('PMA_DatabaseInterface') -// ->disableOriginalConstructor() -// ->getMock(); -// -// $find = 'findValue'; -// $replaceWith = 'replaceWithValue'; -// $useRegex = false; -// $charSet = 'charSetValue'; -// -// // set expectations -// $dbi->expects($this->once()) -// ->method('fetchResult') -// ->will( -// $this->returnValue( -// array( -// array('val1', 'replace1', 5), -// array('va<2', 'replac<2', 1) -// ) -// ) -// ); -// $GLOBALS['dbi'] = $dbi; -// -// $ret = $this->_object->getReplacePreview( -// 0, $find, $replaceWith, $useRegex, $charSet -// ); -// -// // assert whether hidden values are properly set -// $this->assertContains( -// '', -// $ret -// ); -// $this->assertContains( -// '', -// $ret -// ); -// $this->assertContains( -// '', -// $ret -// ); -// $this->assertContains( -// '', -// $ret -// ); + /*//mock DBI + $dbi = $this->getMockBuilder('PMA_DatabaseInterface') + ->disableOriginalConstructor() + ->getMock(); + + $find = 'findValue'; + $replaceWith = 'replaceWithValue'; + $useRegex = false; + $charSet = 'charSetValue'; + + // set expectations + $dbi->expects($this->once()) + ->method('fetchResult') + ->will( + $this->returnValue( + array( + array('val1', 'replace1', 5), + array('va<2', 'replac<2', 1) + ) + ) + ); + $GLOBALS['dbi'] = $dbi; + + $ret = $this->_object->getReplacePreview( + 0, $find, $replaceWith, $useRegex, $charSet + ); + + // assert whether hidden values are properly set + $this->assertContains( + '', + $ret + ); + $this->assertContains( + '', + $ret + ); + $this->assertContains( + '', + $ret + ); + $this->assertContains( + '', + $ret + );*/ // assert values displayed in the preview and escaping /** @@ -139,26 +139,26 @@ class PMA_TableReplaceSearchTest extends PHPUnit_Framework_TestCase public function testReplace() { // @todo: Replace this test with TableSearchController test -// //mock DBI -// $dbi = $this->getMockBuilder('PMA_DatabaseInterface') -// ->disableOriginalConstructor() -// ->getMock(); -// -// $find = 'findValue'; -// $replaceWith = 'replaceWithValue'; -// $useRegex = false; -// $charSet = 'charSetValue'; -// -// $expectedQuery = "UPDATE `dbName`.`tableName`" -// . " SET `column1` = REPLACE(`column1`, '" . $find . "', '" . $replaceWith -// . "') WHERE `column1` LIKE '%" . $find . "%' COLLATE " -// . $charSet . "_bin"; -// // set expectations -// $dbi->expects($this->once()) -// ->method('query') -// ->with($expectedQuery); -// $GLOBALS['dbi'] = $dbi; -// -// $this->_object->replace(0, $find, $replaceWith, $useRegex, $charSet); + /*//mock DBI + $dbi = $this->getMockBuilder('PMA_DatabaseInterface') + ->disableOriginalConstructor() + ->getMock(); + + $find = 'findValue'; + $replaceWith = 'replaceWithValue'; + $useRegex = false; + $charSet = 'charSetValue'; + + $expectedQuery = "UPDATE `dbName`.`tableName`" + . " SET `column1` = REPLACE(`column1`, '" . $find . "', '" . $replaceWith + . "') WHERE `column1` LIKE '%" . $find . "%' COLLATE " + . $charSet . "_bin"; + // set expectations + $dbi->expects($this->once()) + ->method('query') + ->with($expectedQuery); + $GLOBALS['dbi'] = $dbi; + + $this->_object->replace(0, $find, $replaceWith, $useRegex, $charSet);*/ } } diff --git a/test/classes/PMA_TableSearch_test.php b/test/classes/PMA_TableSearch_test.php index eb3f94d1ee..ffc20878a0 100644 --- a/test/classes/PMA_TableSearch_test.php +++ b/test/classes/PMA_TableSearch_test.php @@ -38,65 +38,65 @@ class PMA_TableSearch_Test extends PHPUnit_Framework_TestCase */ protected function setUp() { -// /** -// * SET these to avoid undefined index error -// */ -// $_SESSION['PMA_Theme'] = new PMA_Theme(); -// $_POST['zoom_submit'] = 'zoom'; -// -// $GLOBALS['server'] = 1; -// $GLOBALS['PMA_PHP_SELF'] = 'index.php'; -// $GLOBALS['pmaThemeImage'] = 'themes/dot.gif'; -// $GLOBALS['is_ajax_request'] = false; -// $GLOBALS['cfgRelation'] = PMA_getRelationsParam(); -// $GLOBALS['PMA_Types'] = new PMA_Types_MySQL(); -// -// $GLOBALS['cfg']['ServerDefault'] = 1; -// $GLOBALS['cfg']['maxRowPlotLimit'] = 500; -// $GLOBALS['cfg']['Server']['DisableIS'] = false; -// $GLOBALS['cfg']['ServerDefault'] = 1; -// $GLOBALS['cfg']['ActionLinksMode'] = 'both'; -// $GLOBALS['cfg']['ForeignKeyMaxLimit'] = 100; -// $GLOBALS['cfg']['InitialSlidersState'] = 'closed'; -// $GLOBALS['cfg']['MaxRows'] = 25; -// $GLOBALS['cfg']['TabsMode'] = 'text'; -// -// $dbi = $this->getMockBuilder('PMA_DatabaseInterface') -// ->disableOriginalConstructor() -// ->getMock(); -// -// $columns =array( -// array( -// 'Field' => 'Field1', -// 'Type' => 'Type1', -// 'Null' => 'Null1', -// 'Collation' => 'Collation1', -// ), -// array( -// 'Field' => 'Field2', -// 'Type' => 'Type2', -// 'Null' => 'Null2', -// 'Collation' => 'Collation2', -// ) -// ); -// $dbi->expects($this->any())->method('getColumns') -// ->will($this->returnValue($columns)); -// -// $show_create_table = "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`), -// KEY `foreign_field` (`foreign_db`,`foreign_table`) -// ) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COLLATE=utf8_bin " -// . "COMMENT='Bookmarks'"; -// -// $dbi->expects($this->any())->method('fetchValue') -// ->will($this->returnValue($show_create_table)); -// -// $GLOBALS['dbi'] = $dbi; + /** + * SET these to avoid undefined index error + */ + /*$_SESSION['PMA_Theme'] = new PMA_Theme(); + $_POST['zoom_submit'] = 'zoom'; + + $GLOBALS['server'] = 1; + $GLOBALS['PMA_PHP_SELF'] = 'index.php'; + $GLOBALS['pmaThemeImage'] = 'themes/dot.gif'; + $GLOBALS['is_ajax_request'] = false; + $GLOBALS['cfgRelation'] = PMA_getRelationsParam(); + $GLOBALS['PMA_Types'] = new PMA_Types_MySQL(); + + $GLOBALS['cfg']['ServerDefault'] = 1; + $GLOBALS['cfg']['maxRowPlotLimit'] = 500; + $GLOBALS['cfg']['Server']['DisableIS'] = false; + $GLOBALS['cfg']['ServerDefault'] = 1; + $GLOBALS['cfg']['ActionLinksMode'] = 'both'; + $GLOBALS['cfg']['ForeignKeyMaxLimit'] = 100; + $GLOBALS['cfg']['InitialSlidersState'] = 'closed'; + $GLOBALS['cfg']['MaxRows'] = 25; + $GLOBALS['cfg']['TabsMode'] = 'text'; + + $dbi = $this->getMockBuilder('PMA_DatabaseInterface') + ->disableOriginalConstructor() + ->getMock(); + + $columns =array( + array( + 'Field' => 'Field1', + 'Type' => 'Type1', + 'Null' => 'Null1', + 'Collation' => 'Collation1', + ), + array( + 'Field' => 'Field2', + 'Type' => 'Type2', + 'Null' => 'Null2', + 'Collation' => 'Collation2', + ) + ); + $dbi->expects($this->any())->method('getColumns') + ->will($this->returnValue($columns)); + + $show_create_table = "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`), + KEY `foreign_field` (`foreign_db`,`foreign_table`) + ) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COLLATE=utf8_bin " + . "COMMENT='Bookmarks'"; + + $dbi->expects($this->any())->method('fetchValue') + ->will($this->returnValue($show_create_table)); + + $GLOBALS['dbi'] = $dbi;*/ // @todo: Replace this test with TableSearchController test } @@ -119,16 +119,16 @@ class PMA_TableSearch_Test extends PHPUnit_Framework_TestCase */ public function testConstruct() { -// $tableSearch = new PMA_TableSearch("PMA", "PMA_BookMark", "normal"); -// $columNames = $tableSearch->getColumnNames(); -// $this->assertEquals( -// 'Field1', -// $columNames[0] -// ); -// $this->assertEquals( -// 'Field2', -// $columNames[1] -// ); + /*$tableSearch = new PMA_TableSearch("PMA", "PMA_BookMark", "normal"); + $columNames = $tableSearch->getColumnNames(); + $this->assertEquals( + 'Field1', + $columNames[0] + ); + $this->assertEquals( + 'Field2', + $columNames[1] + );*/ // @todo: Replace this test with TableSearchController test } @@ -140,44 +140,44 @@ class PMA_TableSearch_Test extends PHPUnit_Framework_TestCase */ public function testGetSelectionForm() { -// //$this->_searchType == 'zoom' -// $tableSearch = new PMA_TableSearch("PMA", "PMA_BookMark", "zoom"); -// $url_goto = "http://phpmyadmin.net"; -// $form = $tableSearch->getSelectionForm($url_goto); -// $this->assertContains( -// '