true, 'relwork'=>1, 'db'=>'phpmyadmin', 'relation'=>'pma_central_columns' ); //mock DBI $dbi = $this->getMockBuilder('PMA_DatabaseInterface') ->disableOriginalConstructor() ->getMock(); $GLOBALS['dbi'] = $dbi; // set expectations $dbi->expects($this->any()) ->method('selectDb') ->will($this->returnValue(true)); $dbi->expects($this->any()) ->method('getColumns') ->will( $this->returnValue( array( "id"=>array("Type"=>"integer", "Null"=>"NO"), "col1"=>array("Type"=>'varchar(100)', "Null"=>"YES"), "col2"=>array("Type"=>'DATETIME', "Null"=>"NO") ) ) ); $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( $this->returnValue(array("PMA_table", "PMA_table1", "PMA_table2")) ); } /** * Test for PMA_centralColumnsGetParams * * @return void */ public function testPMACentralColumnsGetParams() { $this->assertSame( array( 'user' => 'pma_user', 'db' => 'phpmyadmin', 'table' => 'pma_central_columns' ), PMA_centralColumnsGetParams() ); } /** * Test for PMA_getColumnsList * * @return void */ public function testPMAGetColumnsList() { $this->assertEquals( array("id", "col1"), PMA_getColumnsList('phpmyadmin') ); $this->assertEquals( array("id", "col1"), PMA_getColumnsList('phpmyadmin', 0, 0) ); } /** * Test for PMA_getCentralColumnsCount * * @return void */ function testPMAGetCentralColumnsCount() { $this->assertEquals( 'id', PMA_getCentralColumnsCount('phpmyadmin') ); } /** * Test for PMA_syncUniqueColumns * * @return void */ public function testPMASyncUniqueColumns() { $field_select = array("col1"); $_POST['db'] = 'PMA_db'; $_POST['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) ); } /** * Test for PMA_deleteColumnsFromList * * @return void */ public function testPMADeleteColumnsFromList() { $field_select = array("col1"); $_POST['db'] = 'PMA_db'; $_POST['table'] = 'PMA_table'; $this->assertTrue( PMA_deleteColumnsFromList($field_select, false) ); $this->assertInstanceOf( 'PMA_Message', PMA_deleteColumnsFromList(array('column1'), false) ); $this->assertInstanceOf( 'PMA_Message', PMA_deleteColumnsFromList(array('PMA_table')) ); } /** * Test for PMA_makeConsistentWithList * * @return void */ 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()) ->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' ) ) ) ); $dbitmp->expects($this->any()) ->method('fetchValue') ->will( $this->returnValue('PMA_table=CREATE table `PMA_table` (id integer)') ); $this->assertTrue( PMA_makeConsistentWithList("phpmyadmin", array('PMA_table')) ); $GLOBALS['dbi'] = $dbi; } /** * Test for PMA_getCentralColumnsFromTable * * @return void */ public function testPMAGetCentralColumnsFromTable() { $db = 'PMA_db'; $table = 'PMA_table'; $this->assertEquals( array("id", "col1"), PMA_getCentralColumnsFromTable($db, $table) ); $this->assertEquals( array("id", "col1"), PMA_getCentralColumnsFromTable($db, $table, true) ); } /** * Test for PMA_updateOneColumn * * @return void */ public function testPMAUpdateOneColumn() { $this->assertTrue( PMA_updateOneColumn( "phpmyadmin", "", "", "", "", "", "", "", "" ) ); $this->assertTrue( PMA_updateOneColumn( "phpmyadmin", "col1", "", "", "", "", "", "", "" ) ); } /** * Test for PMA_getHTMLforTableNavigation * * @return void */ public function testPMAGetHTMLforTableNavigation() { $result = PMA_getHTMLforTableNavigation(0, 0, 'phpmyadmin'); $this->assertTag( array('tag' => 'table'), $result ); $this->assertContains( __('Search this table'), $result ); $result_1 = PMA_getHTMLforTableNavigation(25, 10, 'phpmyadmin'); $this->assertContains( '