From fe71fbda566eb5e22c82032214061f129c8b66bf Mon Sep 17 00:00:00 2001 From: Deven Bansod Date: Fri, 4 Nov 2016 15:12:28 +0530 Subject: [PATCH] Fixed tests in Central Columns Signed-off-by: Deven Bansod --- test/libraries/PMA_central_columns_test.php | 43 +++++++-------------- 1 file changed, 14 insertions(+), 29 deletions(-) diff --git a/test/libraries/PMA_central_columns_test.php b/test/libraries/PMA_central_columns_test.php index b983e7e763..a0e4b94d86 100644 --- a/test/libraries/PMA_central_columns_test.php +++ b/test/libraries/PMA_central_columns_test.php @@ -132,6 +132,8 @@ class PMA_Central_Columns_Test extends PHPUnit_Framework_TestCase ->will( $this->returnValue(array("PMA_table", "PMA_table1", "PMA_table2")) ); + $dbi->expects($this->any())->method('escapeString') + ->will($this->returnArgument(0)); } @@ -159,28 +161,11 @@ class PMA_Central_Columns_Test extends PHPUnit_Framework_TestCase */ public function testPMAGetColumnsList() { - $GLOBALS['dbi']->expects($this->at(1)) + $GLOBALS['dbi']->expects($this->exactly(2)) ->method('fetchResult') - ->with( - "SELECT * FROM `pma_central_columns` " - . "WHERE db_name = 'phpmyadmin' LIMIT 0, 25;", - null, null, $GLOBALS['controllink'] - ) - ->will( - $this->returnValue($this->_columnData) - ); - - $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_slice($this->_columnData, 1, 2) - ) + ->willReturnOnConsecutiveCalls( + $this->_columnData, + array_slice($this->_columnData, 1, 2) ); $this->assertEquals( @@ -200,7 +185,7 @@ class PMA_Central_Columns_Test extends PHPUnit_Framework_TestCase */ function testPMAGetCentralColumnsCount() { - $GLOBALS['dbi']->expects($this->at(1)) + $GLOBALS['dbi']->expects($this->once()) ->method('fetchResult') ->with( "SELECT count(db_name) FROM `pma_central_columns` " @@ -243,7 +228,7 @@ class PMA_Central_Columns_Test extends PHPUnit_Framework_TestCase $_REQUEST['table'] = 'PMA_table'; // when column exists in the central column list - $GLOBALS['dbi']->expects($this->at(2)) + $GLOBALS['dbi']->expects($this->at(4)) ->method('fetchResult') ->with( "SELECT col_name FROM `pma_central_columns` " @@ -254,7 +239,7 @@ class PMA_Central_Columns_Test extends PHPUnit_Framework_TestCase $this->returnValue(array('col1')) ); - $GLOBALS['dbi']->expects($this->at(4)) + $GLOBALS['dbi']->expects($this->at(7)) ->method('tryQuery') ->with( "DELETE FROM `pma_central_columns` " @@ -311,7 +296,7 @@ class PMA_Central_Columns_Test extends PHPUnit_Framework_TestCase $db = 'PMA_db'; $table = 'PMA_table'; - $GLOBALS['dbi']->expects($this->at(3)) + $GLOBALS['dbi']->expects($this->once()) ->method('fetchResult') ->with( "SELECT col_name FROM `pma_central_columns` " @@ -337,7 +322,7 @@ class PMA_Central_Columns_Test extends PHPUnit_Framework_TestCase $db = 'PMA_db'; $table = 'PMA_table'; - $GLOBALS['dbi']->expects($this->at(3)) + $GLOBALS['dbi']->expects($this->once()) ->method('fetchResult') ->with( "SELECT * FROM `pma_central_columns` " @@ -505,7 +490,7 @@ class PMA_Central_Columns_Test extends PHPUnit_Framework_TestCase */ public function testPMAGetCentralColumnsListRaw() { - $GLOBALS['dbi']->expects($this->at(1)) + $GLOBALS['dbi']->expects($this->once()) ->method('fetchResult') ->with( "SELECT * FROM `pma_central_columns` " @@ -528,7 +513,7 @@ class PMA_Central_Columns_Test extends PHPUnit_Framework_TestCase */ public function testPMAGetCentralColumnsListRawWithTable() { - $GLOBALS['dbi']->expects($this->at(3)) + $GLOBALS['dbi']->expects($this->once()) ->method('fetchResult') ->with( "SELECT * FROM `pma_central_columns` " @@ -592,7 +577,7 @@ class PMA_Central_Columns_Test extends PHPUnit_Framework_TestCase */ public function testPMAFindExistingColNames() { - $GLOBALS['dbi']->expects($this->at(1)) + $GLOBALS['dbi']->expects($this->once()) ->method('fetchResult') ->with( "SELECT * FROM `pma_central_columns` WHERE db_name = 'phpmyadmin'"