From d912798fd006020fd3ea57b28854e6397fa262fb Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Mon, 9 Mar 2015 17:33:12 +0530 Subject: [PATCH 01/11] These are not generic expectations Signed-off-by: Madhura Jayaratne --- test/libraries/PMA_central_columns_test.php | 8 -------- 1 file changed, 8 deletions(-) diff --git a/test/libraries/PMA_central_columns_test.php b/test/libraries/PMA_central_columns_test.php index 2db153bd7f..ee8547e91c 100644 --- a/test/libraries/PMA_central_columns_test.php +++ b/test/libraries/PMA_central_columns_test.php @@ -84,17 +84,9 @@ class PMA_Central_Columns_Test extends PHPUnit_Framework_TestCase $dbi->expects($this->any()) ->method('getColumnNames') ->will($this->returnValue(array("id", "col1", "col2"))); - $dbi->expects($this->any()) - ->method('fetchResult') - ->will($this->returnValue(array("id", "col1"))); $dbi->expects($this->any()) ->method('tryQuery') ->will($this->returnValue(true)); - $dbi->expects($this->any()) - ->method('fetchValue') - ->will( - $this->returnValue('PMA_table=CREATE table `PMA_table` (id integer)') - ); $dbi->expects($this->any()) ->method('getTables') ->will( From 547606bd263c56446dce67649c2e7a80d380188c Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Mon, 9 Mar 2015 18:03:05 +0530 Subject: [PATCH 02/11] Fix testPMAGetColumnsList() Signed-off-by: Madhura Jayaratne --- libraries/central_columns.lib.php | 2 +- test/libraries/PMA_central_columns_test.php | 74 ++++++++++++++++++++- 2 files changed, 72 insertions(+), 4 deletions(-) diff --git a/libraries/central_columns.lib.php b/libraries/central_columns.lib.php index 93314e2db4..a137a26641 100644 --- a/libraries/central_columns.lib.php +++ b/libraries/central_columns.lib.php @@ -66,7 +66,7 @@ function PMA_getColumnsList($db, $from=0, $num=25) . 'WHERE db_name = \'' . $db . '\';'; } else { $query = 'SELECT * FROM ' . PMA_Util::backquote($central_list_table) . ' ' - . 'WHERE db_name = \'' . $db . '\'' + . 'WHERE db_name = \'' . $db . '\' ' . 'LIMIT ' . $from . ', ' . $num . ';'; } $has_list = (array) $GLOBALS['dbi']->fetchResult( diff --git a/test/libraries/PMA_central_columns_test.php b/test/libraries/PMA_central_columns_test.php index ee8547e91c..469eddcfff 100644 --- a/test/libraries/PMA_central_columns_test.php +++ b/test/libraries/PMA_central_columns_test.php @@ -119,13 +119,81 @@ class PMA_Central_Columns_Test extends PHPUnit_Framework_TestCase */ public function testPMAGetColumnsList() { + $GLOBALS['dbi']->expects($this->at(1)) + ->method('fetchResult') + ->with("SELECT * FROM `pma_central_columns` WHERE db_name = 'phpmyadmin' LIMIT 0, 25;", null, null, $GLOBALS['controllink']) + ->will( + $this->returnValue( + array( + array( + 'col_name' => "id", "col_type" => 'integer', + 'col_length' => 0, 'col_isNull' => 0, 'col_extra' => '', + 'col_default' => 1 + ), + array('col_name' => "col1", 'col_type' => 'varchar', + 'col_length' => 100, 'col_isNull' => 1, 'col_extra' => '', + 'col_default' => 1 + ), + array( + 'col_name' => "col2", 'col_type' => 'DATETIME', + 'col_length' => 0, 'col_isNull' => 1, 'col_extra' => '', + 'col_default' => 'CURRENT_TIMESTAMP' + ) + ) + ) + ); + + $GLOBALS['dbi']->expects($this->at(3)) + ->method('fetchResult') + ->with("SELECT * FROM `pma_central_columns` WHERE db_name = 'phpmyadmin' LIMIT 1, 2;", null, null, $GLOBALS['controllink']) + ->will( + $this->returnValue( + array( + array('col_name' => "col1", 'col_type' => 'varchar', + 'col_length' => 100, 'col_isNull' => 1, 'col_extra' => '', + 'col_default' => 1 + ), + array( + 'col_name' => "col2", 'col_type' => 'DATETIME', + 'col_length' => 0, 'col_isNull' => 1, 'col_extra' => '', + 'col_default' => 'CURRENT_TIMESTAMP' + ) + ) + ) + ); + $this->assertEquals( - array("id", "col1"), + array( + array( + 'col_name' => "id", "col_type" => 'integer', + 'col_length' => 0, 'col_isNull' => 0, 'col_extra' => '', + 'col_default' => 1, 'col_attribute' => '' + ), + array('col_name' => "col1", 'col_type' => 'varchar', + 'col_length' => 100, 'col_isNull' => 1, 'col_extra' => '', + 'col_default' => 1, 'col_attribute' => '' + ), + array( + 'col_name' => "col2", 'col_type' => 'DATETIME', + 'col_length' => 0, 'col_isNull' => 1, 'col_extra' => '', + 'col_default' => 'CURRENT_TIMESTAMP', 'col_attribute' => '' + ) + ), PMA_getColumnsList('phpmyadmin') ); $this->assertEquals( - array("id", "col1"), - PMA_getColumnsList('phpmyadmin', 0, 0) + array( + array('col_name' => "col1", 'col_type' => 'varchar', + 'col_length' => 100, 'col_isNull' => 1, 'col_extra' => '', + 'col_default' => 1, 'col_attribute' => '' + ), + array( + 'col_name' => "col2", 'col_type' => 'DATETIME', + 'col_length' => 0, 'col_isNull' => 1, 'col_extra' => '', + 'col_default' => 'CURRENT_TIMESTAMP', 'col_attribute' => '' + ) + ), + PMA_getColumnsList('phpmyadmin', 1, 2) ); } From a90b8bc8e23736ed15f8ebe4cbf57fc829934f64 Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Mon, 9 Mar 2015 18:15:25 +0530 Subject: [PATCH 03/11] Move test data to instance variable with reuse in mind Signed-off-by: Madhura Jayaratne --- test/libraries/PMA_central_columns_test.php | 98 +++++++++------------ 1 file changed, 41 insertions(+), 57 deletions(-) diff --git a/test/libraries/PMA_central_columns_test.php b/test/libraries/PMA_central_columns_test.php index 469eddcfff..43943fe565 100644 --- a/test/libraries/PMA_central_columns_test.php +++ b/test/libraries/PMA_central_columns_test.php @@ -31,6 +31,40 @@ require_once 'libraries/sqlparser.lib.php'; */ class PMA_Central_Columns_Test extends PHPUnit_Framework_TestCase { + private $_columnData = array( + array( + 'col_name' => "id", "col_type" => 'integer', + 'col_length' => 0, 'col_isNull' => 0, 'col_extra' => 'UNSIGNED,auto_increment', + 'col_default' => 1 + ), + array('col_name' => "col1", 'col_type' => 'varchar', + 'col_length' => 100, 'col_isNull' => 1, 'col_extra' => 'BINARY', + 'col_default' => 1 + ), + array( + 'col_name' => "col2", 'col_type' => 'DATETIME', + 'col_length' => 0, 'col_isNull' => 1, 'col_extra' => 'on update CURRENT_TIMESTAMP', + 'col_default' => 'CURRENT_TIMESTAMP' + ) + ); + + private $_modifiedColumnData = array( + array( + 'col_name' => "id", "col_type" => 'integer', + 'col_length' => 0, 'col_isNull' => 0, 'col_extra' => 'auto_increment', + 'col_default' => 1, 'col_attribute' => 'UNSIGNED' + ), + array('col_name' => "col1", 'col_type' => 'varchar', + 'col_length' => 100, 'col_isNull' => 1, 'col_extra' => '', + 'col_default' => 1, 'col_attribute' => 'BINARY' + ), + array( + 'col_name' => "col2", 'col_type' => 'DATETIME', + 'col_length' => 0, 'col_isNull' => 1, 'col_extra' => '', + 'col_default' => 'CURRENT_TIMESTAMP', 'col_attribute' => 'on update CURRENT_TIMESTAMP' + ) + ); + /** * prepares environment for tests * @@ -61,11 +95,13 @@ class PMA_Central_Columns_Test extends PHPUnit_Framework_TestCase 'relation' => 'relation', 'central_columns' => 'pma_central_columns' ); - //mock DBI + + //mock DBI $dbi = $this->getMockBuilder('PMA_DatabaseInterface') ->disableOriginalConstructor() ->getMock(); $GLOBALS['dbi'] = $dbi; + // set expectations $dbi->expects($this->any()) ->method('selectDb') @@ -123,24 +159,7 @@ class PMA_Central_Columns_Test extends PHPUnit_Framework_TestCase ->method('fetchResult') ->with("SELECT * FROM `pma_central_columns` WHERE db_name = 'phpmyadmin' LIMIT 0, 25;", null, null, $GLOBALS['controllink']) ->will( - $this->returnValue( - array( - array( - 'col_name' => "id", "col_type" => 'integer', - 'col_length' => 0, 'col_isNull' => 0, 'col_extra' => '', - 'col_default' => 1 - ), - array('col_name' => "col1", 'col_type' => 'varchar', - 'col_length' => 100, 'col_isNull' => 1, 'col_extra' => '', - 'col_default' => 1 - ), - array( - 'col_name' => "col2", 'col_type' => 'DATETIME', - 'col_length' => 0, 'col_isNull' => 1, 'col_extra' => '', - 'col_default' => 'CURRENT_TIMESTAMP' - ) - ) - ) + $this->returnValue($this->_columnData) ); $GLOBALS['dbi']->expects($this->at(3)) @@ -148,51 +167,16 @@ class PMA_Central_Columns_Test extends PHPUnit_Framework_TestCase ->with("SELECT * FROM `pma_central_columns` WHERE db_name = 'phpmyadmin' LIMIT 1, 2;", null, null, $GLOBALS['controllink']) ->will( $this->returnValue( - array( - array('col_name' => "col1", 'col_type' => 'varchar', - 'col_length' => 100, 'col_isNull' => 1, 'col_extra' => '', - 'col_default' => 1 - ), - array( - 'col_name' => "col2", 'col_type' => 'DATETIME', - 'col_length' => 0, 'col_isNull' => 1, 'col_extra' => '', - 'col_default' => 'CURRENT_TIMESTAMP' - ) - ) + array_slice($this->_columnData, 1, 2) ) ); $this->assertEquals( - array( - array( - 'col_name' => "id", "col_type" => 'integer', - 'col_length' => 0, 'col_isNull' => 0, 'col_extra' => '', - 'col_default' => 1, 'col_attribute' => '' - ), - array('col_name' => "col1", 'col_type' => 'varchar', - 'col_length' => 100, 'col_isNull' => 1, 'col_extra' => '', - 'col_default' => 1, 'col_attribute' => '' - ), - array( - 'col_name' => "col2", 'col_type' => 'DATETIME', - 'col_length' => 0, 'col_isNull' => 1, 'col_extra' => '', - 'col_default' => 'CURRENT_TIMESTAMP', 'col_attribute' => '' - ) - ), + $this->_modifiedColumnData, PMA_getColumnsList('phpmyadmin') ); $this->assertEquals( - array( - array('col_name' => "col1", 'col_type' => 'varchar', - 'col_length' => 100, 'col_isNull' => 1, 'col_extra' => '', - 'col_default' => 1, 'col_attribute' => '' - ), - array( - 'col_name' => "col2", 'col_type' => 'DATETIME', - 'col_length' => 0, 'col_isNull' => 1, 'col_extra' => '', - 'col_default' => 'CURRENT_TIMESTAMP', 'col_attribute' => '' - ) - ), + array_slice($this->_modifiedColumnData, 1, 2), PMA_getColumnsList('phpmyadmin', 1, 2) ); } From 19a1f376f5f9a6040bfbed923ebdab2952769e4b Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Mon, 9 Mar 2015 18:22:36 +0530 Subject: [PATCH 04/11] Fix testPMAGetCentralColumnsCount() Signed-off-by: Madhura Jayaratne --- libraries/central_columns.lib.php | 4 +++- test/libraries/PMA_central_columns_test.php | 9 ++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/libraries/central_columns.lib.php b/libraries/central_columns.lib.php index a137a26641..f400e95182 100644 --- a/libraries/central_columns.lib.php +++ b/libraries/central_columns.lib.php @@ -95,7 +95,9 @@ function PMA_getCentralColumnsCount($db) $query = 'SELECT count(db_name) FROM ' . PMA_Util::backquote($central_list_table) . ' ' . 'WHERE db_name = \'' . $db . '\';'; - $res = $GLOBALS['dbi']->fetchResult($query); + $res = $GLOBALS['dbi']->fetchResult( + $query, null, null, $GLOBALS['controllink'] + ); if (isset($res[0])) { return $res[0]; } else { diff --git a/test/libraries/PMA_central_columns_test.php b/test/libraries/PMA_central_columns_test.php index 43943fe565..2752d40b55 100644 --- a/test/libraries/PMA_central_columns_test.php +++ b/test/libraries/PMA_central_columns_test.php @@ -188,8 +188,15 @@ class PMA_Central_Columns_Test extends PHPUnit_Framework_TestCase */ function testPMAGetCentralColumnsCount() { + $GLOBALS['dbi']->expects($this->at(1)) + ->method('fetchResult') + ->with("SELECT count(db_name) FROM `pma_central_columns` WHERE db_name = 'phpmyadmin';", null, null, $GLOBALS['controllink']) + ->will( + $this->returnValue(array(3)) + ); + $this->assertEquals( - 'id', + 3, PMA_getCentralColumnsCount('phpmyadmin') ); } From 5e8d08186983aafb46d809fb7c0b99abde965678 Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Mon, 9 Mar 2015 19:01:43 +0530 Subject: [PATCH 05/11] Fix testPMADeleteColumnsFromList() Signed-off-by: Madhura Jayaratne --- test/libraries/PMA_central_columns_test.php | 22 +++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/test/libraries/PMA_central_columns_test.php b/test/libraries/PMA_central_columns_test.php index 2752d40b55..035359ecba 100644 --- a/test/libraries/PMA_central_columns_test.php +++ b/test/libraries/PMA_central_columns_test.php @@ -227,15 +227,33 @@ class PMA_Central_Columns_Test extends PHPUnit_Framework_TestCase */ public function testPMADeleteColumnsFromList() { - $field_select = array("col1"); $_REQUEST['db'] = 'PMA_db'; $_REQUEST['table'] = 'PMA_table'; + + // when column exists in the central column list + $GLOBALS['dbi']->expects($this->at(2)) + ->method('fetchResult') + ->with("SELECT col_name FROM `pma_central_columns` WHERE db_name = 'PMA_db' AND col_name IN ('col1');", null, null, $GLOBALS['controllink']) + ->will( + $this->returnValue(array('col1')) + ); + + $GLOBALS['dbi']->expects($this->at(4)) + ->method('tryQuery') + ->with("DELETE FROM `pma_central_columns` WHERE db_name = 'PMA_db' AND col_name IN ('col1');", $GLOBALS['controllink']) + ->will( + $this->returnValue(array('col1')) + ); + $this->assertTrue( - PMA_deleteColumnsFromList($field_select, false) + PMA_deleteColumnsFromList(array("col1"), false) ); + + // when column does not exist in the central column list $this->assertInstanceOf( 'PMA_Message', PMA_deleteColumnsFromList(array('column1'), false) ); + $this->assertInstanceOf( 'PMA_Message', PMA_deleteColumnsFromList(array('PMA_table')) ); From b6724c5cf6b2fee1945c58d2c833f78c416e5a7a Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Mon, 9 Mar 2015 19:11:03 +0530 Subject: [PATCH 06/11] Cleanup duplicate code Signed-off-by: Madhura Jayaratne --- test/libraries/PMA_central_columns_test.php | 42 +++------------------ 1 file changed, 5 insertions(+), 37 deletions(-) diff --git a/test/libraries/PMA_central_columns_test.php b/test/libraries/PMA_central_columns_test.php index 035359ecba..57c1d82536 100644 --- a/test/libraries/PMA_central_columns_test.php +++ b/test/libraries/PMA_central_columns_test.php @@ -96,13 +96,13 @@ class PMA_Central_Columns_Test extends PHPUnit_Framework_TestCase 'central_columns' => 'pma_central_columns' ); - //mock DBI + // mock DBI $dbi = $this->getMockBuilder('PMA_DatabaseInterface') ->disableOriginalConstructor() ->getMock(); $GLOBALS['dbi'] = $dbi; - // set expectations + // set some common expectations $dbi->expects($this->any()) ->method('selectDb') ->will($this->returnValue(true)); @@ -266,43 +266,12 @@ class PMA_Central_Columns_Test extends PHPUnit_Framework_TestCase */ public function testPMAMakeConsistentWithList() { - $dbi = $GLOBALS['dbi']; - $dbitmp = $this->getMockBuilder('PMA_DatabaseInterface') - ->disableOriginalConstructor() - ->getMock(); - $GLOBALS['dbi'] = $dbitmp; - $dbitmp->expects($this->any()) - ->method('selectDb') - ->will($this->returnValue(true)); - $dbitmp->expects($this->any()) - ->method('getColumnNames') - ->will($this->returnValue(array("id", "col1", "col2"))); - $dbitmp->expects($this->any()) - ->method('tryQuery') - ->will($this->returnValue(true)); - $dbitmp->expects($this->any()) + $GLOBALS['dbi']->expects($this->any()) ->method('fetchResult') ->will( - $this->returnValue( - array( - array( - 'col_name'=>"id", "col_type"=>'integer', - 'col_length'=>0, 'col_isNull'=>0, 'col_extra'=>'', - 'col_default'=>1 - ), - array('col_name'=>"col1", 'col_type'=>'varchar', - 'col_length'=>100, 'col_isNull'=>1, 'col_extra'=>'', - 'col_default'=>1 - ), - array( - 'col_name'=>"col2", 'col_type'=>'DATETIME', - 'col_length'=>0, 'col_isNull'=>1, 'col_extra'=>'', - 'col_default'=>'CURRENT_TIMESTAMP' - ) - ) - ) + $this->returnValue($this->_columnData) ); - $dbitmp->expects($this->any()) + $GLOBALS['dbi']->expects($this->any()) ->method('fetchValue') ->will( $this->returnValue('PMA_table=CREATE table `PMA_table` (id integer)') @@ -310,7 +279,6 @@ class PMA_Central_Columns_Test extends PHPUnit_Framework_TestCase $this->assertTrue( PMA_makeConsistentWithList("phpmyadmin", array('PMA_table')) ); - $GLOBALS['dbi'] = $dbi; } /** From fd16be985968b880d6834f40ebe73b946e8176b9 Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Mon, 9 Mar 2015 19:27:13 +0530 Subject: [PATCH 07/11] Fix testPMAGetCentralColumnsFromTable() Signed-off-by: Madhura Jayaratne --- test/libraries/PMA_central_columns_test.php | 28 ++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/test/libraries/PMA_central_columns_test.php b/test/libraries/PMA_central_columns_test.php index 57c1d82536..debd2796c8 100644 --- a/test/libraries/PMA_central_columns_test.php +++ b/test/libraries/PMA_central_columns_test.php @@ -290,15 +290,41 @@ class PMA_Central_Columns_Test extends PHPUnit_Framework_TestCase { $db = 'PMA_db'; $table = 'PMA_table'; + + $GLOBALS['dbi']->expects($this->at(3)) + ->method('fetchResult') + ->with("SELECT col_name FROM `pma_central_columns` WHERE db_name = 'PMA_db' AND col_name IN ('id','col1','col2');", null, null, $GLOBALS['controllink']) + ->will( + $this->returnValue(array('id','col1')) + ); $this->assertEquals( array("id", "col1"), PMA_getCentralColumnsFromTable($db, $table) ); + } + + /** + * Test for PMA_getCentralColumnsFromTable with $allFields = true + * + * @return void + */ + public function testPMAGetCentralColumnsFromTableWithAllFields() + { + $db = 'PMA_db'; + $table = 'PMA_table'; + + $GLOBALS['dbi']->expects($this->at(3)) + ->method('fetchResult') + ->with("SELECT * FROM `pma_central_columns` WHERE db_name = 'PMA_db' AND col_name IN ('id','col1','col2');", null, null, $GLOBALS['controllink']) + ->will( + $this->returnValue(array_slice($this->_columnData, 0, 2)) + ); $this->assertEquals( - array("id", "col1"), + array_slice($this->_modifiedColumnData, 0, 2), PMA_getCentralColumnsFromTable($db, $table, true) ); } + /** * Test for PMA_updateOneColumn * From 4c2365e48c582200f4f6e734d5b9dbbbfc829fc3 Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Mon, 9 Mar 2015 19:35:32 +0530 Subject: [PATCH 08/11] Fix testPMAGetCentralColumnsListRaw() Signed-off-by: Madhura Jayaratne --- test/libraries/PMA_central_columns_test.php | 32 +++++++++++++++++---- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/test/libraries/PMA_central_columns_test.php b/test/libraries/PMA_central_columns_test.php index debd2796c8..a1032f1af5 100644 --- a/test/libraries/PMA_central_columns_test.php +++ b/test/libraries/PMA_central_columns_test.php @@ -471,16 +471,38 @@ class PMA_Central_Columns_Test extends PHPUnit_Framework_TestCase */ public function testPMAGetCentralColumnsListRaw() { + $GLOBALS['dbi']->expects($this->at(1)) + ->method('fetchResult') + ->with("SELECT * FROM `pma_central_columns` WHERE db_name = 'phpmyadmin';", null, null, $GLOBALS['controllink']) + ->will( + $this->returnValue($this->_columnData) + ); $this->assertEquals( - json_encode(array("id", "col1")), - PMA_getCentralColumnsListRaw('phpmyadmin', 'pma_central_columns') - ); - $this->assertEquals( - json_encode(array("id", "col1")), + json_encode($this->_modifiedColumnData), PMA_getCentralColumnsListRaw('phpmyadmin', '') ); } + /** + * Test for PMA_getCentralColumnsListRaw with a table name + * + * @return void + */ + public function testPMAGetCentralColumnsListRawWithTable() + { + $GLOBALS['dbi']->expects($this->at(3)) + ->method('fetchResult') + ->with("SELECT * FROM `pma_central_columns` WHERE db_name = 'phpmyadmin' AND col_name NOT IN ('id','col1','col2');", null, null, $GLOBALS['controllink']) + ->will( + $this->returnValue($this->_columnData) + ); + $this->assertEquals( + json_encode($this->_modifiedColumnData), + PMA_getCentralColumnsListRaw('phpmyadmin', 'table1') + ); + + } + /** * Test for PMA_getHTMLforAddNewColumn * From 7ece631025aa79ec122c60d04eabc0d573b0bc65 Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Mon, 9 Mar 2015 19:41:12 +0530 Subject: [PATCH 09/11] Fix testPMAFindExistingColNames() Signed-off-by: Madhura Jayaratne --- test/libraries/PMA_central_columns_test.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/test/libraries/PMA_central_columns_test.php b/test/libraries/PMA_central_columns_test.php index a1032f1af5..42740e2540 100644 --- a/test/libraries/PMA_central_columns_test.php +++ b/test/libraries/PMA_central_columns_test.php @@ -544,9 +544,15 @@ class PMA_Central_Columns_Test extends PHPUnit_Framework_TestCase */ public function testPMAFindExistingColNames() { + $GLOBALS['dbi']->expects($this->at(1)) + ->method('fetchResult') + ->with("SELECT * FROM `pma_central_columns` WHERE db_name = 'phpmyadmin' AND col_name IN ('col1');", null, null, $GLOBALS['controllink']) + ->will( + $this->returnValue(array_slice($this->_columnData, 1, 1)) + ); $this->assertEquals( - array('id', 'col1'), - PMA_findExistingColNames('phpmyadmin', 'col1', true) + array_slice($this->_modifiedColumnData, 1, 1), + PMA_findExistingColNames('phpmyadmin', "'col1'", true) ); } From d6a36ef770ab47b544fead84863fbc797f5e0f27 Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Mon, 9 Mar 2015 19:43:40 +0530 Subject: [PATCH 10/11] Fix testPMAGetHTMLforColumnDropdown() Signed-off-by: Madhura Jayaratne --- test/libraries/PMA_central_columns_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/libraries/PMA_central_columns_test.php b/test/libraries/PMA_central_columns_test.php index 42740e2540..f20647e345 100644 --- a/test/libraries/PMA_central_columns_test.php +++ b/test/libraries/PMA_central_columns_test.php @@ -585,7 +585,7 @@ class PMA_Central_Columns_Test extends PHPUnit_Framework_TestCase $selected_tbl = 'PMA_table'; $result = PMA_getHTMLforColumnDropdown($db, $selected_tbl); $this->assertEquals( - '', + '', $result ); } From 6952bd36c26552162e50d0297132f2b985a0fab6 Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Mon, 9 Mar 2015 19:57:54 +0530 Subject: [PATCH 11/11] Fix testPMASyncUniqueColumns() Signed-off-by: Madhura Jayaratne --- test/libraries/PMA_central_columns_test.php | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/test/libraries/PMA_central_columns_test.php b/test/libraries/PMA_central_columns_test.php index f20647e345..6c6a4abc46 100644 --- a/test/libraries/PMA_central_columns_test.php +++ b/test/libraries/PMA_central_columns_test.php @@ -208,15 +208,11 @@ class PMA_Central_Columns_Test extends PHPUnit_Framework_TestCase */ public function testPMASyncUniqueColumns() { - $field_select = array("col1"); $_REQUEST['db'] = 'PMA_db'; $_REQUEST['table'] = 'PMA_table'; - $this->assertInstanceOf( - 'PMA_Message', PMA_syncUniqueColumns($field_select, false) - ); - $field_select = array("PMA_table"); - $this->assertInstanceOf( - 'PMA_Message', PMA_syncUniqueColumns($field_select) + + $this->assertTrue( + PMA_syncUniqueColumns(array('PMA_table')) ); }