Simplify dbsearch test using new dummy dbi

Also make it reuse dummy queries from qbe test
This commit is contained in:
Michal Čihař 2012-09-17 16:12:04 +02:00
parent 405b4717cc
commit adde53d899
3 changed files with 20 additions and 32 deletions

View File

@ -63,14 +63,14 @@ $GLOBALS['dummy_queries'] = array(
)
),
array(
'query' => 'SHOW TABLES FROM `qbe_test`;',
'query' => 'SHOW TABLES FROM `pma_test`;',
'result' => array(
array('table1'),
array('table2'),
)
),
array(
'query' => 'SHOW COLUMNS FROM `qbe_test`.`table1`',
'query' => 'SHOW COLUMNS FROM `pma_test`.`table1`',
'columns' => array(
'Field', 'Type', 'Null', 'Key', 'Default', 'Extra'
),
@ -80,7 +80,7 @@ $GLOBALS['dummy_queries'] = array(
)
),
array(
'query' => 'SHOW COLUMNS FROM `qbe_test`.`table2`',
'query' => 'SHOW COLUMNS FROM `pma_test`.`table2`',
'columns' => array(
'Field', 'Type', 'Null', 'Key', 'Default', 'Extra'
),
@ -90,13 +90,23 @@ $GLOBALS['dummy_queries'] = array(
)
),
array(
'query' => 'SHOW INDEXES FROM `qbe_test`.`table1`',
'query' => 'SHOW INDEXES FROM `pma_test`.`table1`',
'result' => array(),
),
array(
'query' => 'SHOW INDEXES FROM `qbe_test`.`table2`',
'query' => 'SHOW INDEXES FROM `pma_test`.`table2`',
'result' => array(),
),
array(
'query' => 'SHOW COLUMNS FROM `pma`.`table1`',
'columns' => array(
'Field', 'Type', 'Null', 'Key', 'Default', 'Extra', 'Privileges', 'Comment'
),
'result' => array(
array('i', 'int(11)', 'NO', 'PRI', 'NULL', 'auto_increment', 'select,insert,update,references', ''),
array('o', 'int(11)', 'NO', 'MUL', 'NULL', '', 'select,insert,update,references', ''),
)
),
);

View File

@ -33,7 +33,7 @@ class PMA_DBQbe_test extends PHPUnit_Framework_TestCase
*/
protected function setUp()
{
$this->object = new PMA_DBQbe('qbe_test');
$this->object = new PMA_DBQbe('pma_test');
}
/**

View File

@ -15,6 +15,8 @@ require_once 'libraries/CommonFunctions.class.php';
require_once 'libraries/url_generating.lib.php';
require_once 'libraries/core.lib.php';
require_once 'libraries/Theme.class.php';
require_once 'libraries/database_interface.lib.php';
require_once 'libraries/Tracker.class.php';
/**
* Tests for database search.
@ -37,16 +39,7 @@ class PMA_DbSearch_test extends PHPUnit_Framework_TestCase
*/
protected function setUp()
{
if (! function_exists('PMA_DBI_get_tables')) {
function PMA_DBI_get_tables()
{
return array(
'table1',
'table2'
);
}
}
$this->object = new PMA_DbSearch('pma');
$this->object = new PMA_DbSearch('pma_test');
}
/**
@ -95,15 +88,6 @@ class PMA_DbSearch_test extends PHPUnit_Framework_TestCase
{
$GLOBALS['db'] = 'pma';
if (! function_exists('PMA_DBI_get_columns')) {
function PMA_DBI_get_columns()
{
return array(
'column1',
'column2'
);
}
}
$this->assertEquals(
array (
@ -143,18 +127,12 @@ class PMA_DbSearch_test extends PHPUnit_Framework_TestCase
$each_table, $newsearchsqls, $odd_row, $output
) {
if (! function_exists('PMA_DBI_fetch_value')) {
function PMA_DBI_fetch_value()
{
return 2;
}
}
$GLOBALS['cfg']['AjaxEnable'] = true;
$this->assertEquals(
$output,
$this->_callProtectedFunction(
'_getResultsRow',
array($each_table, $newsearchsqls, $odd_row)
array($each_table, $newsearchsqls, $odd_row, 2)
)
);
}