Skip to content

Commit

Permalink
add more case for PMA_Table
Browse files Browse the repository at this point in the history
  • Loading branch information
adamgsoc2013 committed Jul 17, 2013
1 parent e8621b5 commit 0648e5d
Showing 1 changed file with 116 additions and 2 deletions.
118 changes: 116 additions & 2 deletions test/classes/PMA_Table_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ protected function setUp()
FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = 'PMA'
AND TABLE_NAME = 'PMA_BookMark'";


$getUniqueColumns_sql = "select unique column";

$fetchResult = array(
array(
$sql_isView_true,
Expand Down Expand Up @@ -121,6 +123,42 @@ protected function setUp()
array('COLUMN_NAME'=>'COLUMN_NAME', 'DATA_TYPE'=>'DATA_TYPE')
)
),
array(
$getUniqueColumns_sql,
array('Key_name', null),
'Column_name',
null,
0,
array(
array('index1'),
array('index3'),
array('index5'),
)
),
array(
$getUniqueColumns_sql,
'Column_name',
'Column_name',
null,
0,
array(
'column1',
'column3',
'column5',
)
),
array(
'SHOW COLUMNS FROM `PMA`.`PMA_BookMark`',
'Field',
'Field',
null,
0,
array(
'column1',
'column3',
'column5',
)
),
);

$dbi = $this->getMockBuilder('PMA_DatabaseInterface')
Expand Down Expand Up @@ -158,7 +196,10 @@ protected function setUp()
->will($this->returnValue($triggers));

$dbi->expects($this->any())->method('query')
->will($this->returnValue("executed"));
->will($this->returnValue("executed"));

$dbi->expects($this->any())->method('getTableIndexesSql')
->will($this->returnValue($getUniqueColumns_sql));

$GLOBALS['dbi'] = $dbi;
}
Expand Down Expand Up @@ -552,7 +593,80 @@ public function testRename()
$table->getLastMessage()
);
}


/**
* Test for getUniqueColumns
*
* @return void
*/
public function testGetUniqueColumns()
{
$table = 'PMA_BookMark';
$db = 'PMA';

$table = new PMA_Table($table, $db);
$return = $table->getUniqueColumns();
$expect = array(
'`PMA`.`PMA_BookMark`.`index1`',
'`PMA`.`PMA_BookMark`.`index3`',
'`PMA`.`PMA_BookMark`.`index5`'
);
$this->assertEquals(
$expect,
$return
);
}


/**
* Test for getIndexedColumns
*
* @return void
*/
public function testGetIndexedColumns()
{
$table = 'PMA_BookMark';
$db = 'PMA';

$table = new PMA_Table($table, $db);
$return = $table->getIndexedColumns();
$expect = array(
'`PMA`.`PMA_BookMark`.`column1`',
'`PMA`.`PMA_BookMark`.`column3`',
'`PMA`.`PMA_BookMark`.`column5`'
);
$this->assertEquals(
$expect,
$return
);
}


/**
* Test for getColumns
*
* @return void
*/
public function testGetColumns()
{
$table = 'PMA_BookMark';
$db = 'PMA';

$table = new PMA_Table($table, $db);
$return = $table->getColumns();
$expect = array(
'`PMA`.`PMA_BookMark`.`column1`',
'`PMA`.`PMA_BookMark`.`column3`',
'`PMA`.`PMA_BookMark`.`column5`'
);
$this->assertEquals(
$expect,
$return
);
}
}

//mock PMA
Class DataBasePMAMock{
var $databases;
Expand Down

0 comments on commit 0648e5d

Please sign in to comment.