Fix Navigation tests and Export tests
Signed-off-by: Deven Bansod <devenbansod.bits@gmail.com>
This commit is contained in:
parent
bd449f7405
commit
956f3179cb
@ -489,10 +489,9 @@ class DatabaseInterface
|
||||
$needAnd = false;
|
||||
if ($table || (true === $tbl_is_group)) {
|
||||
$sql .= " `Name` LIKE '"
|
||||
.
|
||||
// Util::escapeMysqlWildcards(
|
||||
. Util::escapeMysqlWildcards(
|
||||
$this->escapeString($table, $link)
|
||||
// )
|
||||
)
|
||||
. "%'";
|
||||
$needAnd = true;
|
||||
}
|
||||
|
||||
@ -204,8 +204,7 @@ class DbSearch
|
||||
// Usage example: If user is searching for a literal $ in a regexp search,
|
||||
// he should enter \$ as the value.
|
||||
$criteriaSearchStringEscaped = $GLOBALS['dbi']->escapeString(
|
||||
$this->_criteriaSearchString,
|
||||
($this->_criteriaSearchType == 4 ? false : true)
|
||||
$this->_criteriaSearchString
|
||||
);
|
||||
// Extract search words or pattern
|
||||
$search_words = (($this->_criteriaSearchType > 2)
|
||||
|
||||
@ -62,7 +62,7 @@ if (empty($is_table)
|
||||
if (! $is_table) {
|
||||
$_result = $GLOBALS['dbi']->tryQuery(
|
||||
'SHOW TABLES LIKE \''
|
||||
. $GLOBALS['dbi']->escapeString($table, true) . '\';',
|
||||
. $GLOBALS['dbi']->escapeString($table) . '\';',
|
||||
null, PMA\libraries\DatabaseInterface::QUERY_STORE
|
||||
);
|
||||
$is_table = @$GLOBALS['dbi']->numRows($_result);
|
||||
|
||||
@ -27,7 +27,7 @@
|
||||
<directory suffix="_test.php">test/libraries/rte</directory>
|
||||
<directory suffix="_test.php">test/libraries</directory>
|
||||
</testsuite>
|
||||
<!-- <testsuite name="Selenium">
|
||||
<testsuite name="Selenium">
|
||||
<directory suffix="Test.php">test/selenium</directory>
|
||||
</testsuite> -->
|
||||
</testsuites>
|
||||
|
||||
@ -10,6 +10,7 @@
|
||||
*/
|
||||
|
||||
require_once 'libraries/url_generating.lib.php';
|
||||
require_once 'libraries/js_escape.lib.php';
|
||||
require_once 'libraries/database_interface.inc.php';
|
||||
require_once 'test/PMATestCase.php';
|
||||
|
||||
@ -40,6 +41,22 @@ class DbSearchTest extends PMATestCase
|
||||
$this->object = new DbSearch('pma_test');
|
||||
$GLOBALS['server'] = 0;
|
||||
$GLOBALS['db'] = 'pma';
|
||||
|
||||
//mock DBI
|
||||
$dbi = $this->getMockBuilder('PMA\libraries\DatabaseInterface')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$dbi->expects($this->any())
|
||||
->method('getColumns')
|
||||
->with('pma', 'table1')
|
||||
->will($this->returnValue(array()));
|
||||
|
||||
$dbi->expects($this->any())
|
||||
->method('escapeString')
|
||||
->will($this->returnArgument(0));
|
||||
|
||||
$GLOBALS['dbi'] = $dbi;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -77,18 +94,6 @@ class DbSearchTest extends PMATestCase
|
||||
*/
|
||||
public function testGetSearchSqls()
|
||||
{
|
||||
//mock DBI
|
||||
$dbi = $this->getMockBuilder('PMA\libraries\DatabaseInterface')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$dbi->expects($this->any())
|
||||
->method('getColumns')
|
||||
->with('pma', 'table1')
|
||||
->will($this->returnValue(array()));
|
||||
|
||||
$GLOBALS['dbi'] = $dbi;
|
||||
|
||||
$this->assertEquals(
|
||||
array (
|
||||
'select_columns' => 'SELECT * FROM `pma`.`table1` WHERE FALSE',
|
||||
|
||||
@ -117,13 +117,11 @@ class NavigationTest extends PMATestCase
|
||||
$dbi = $this->getMockBuilder('PMA\libraries\DatabaseInterface')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$dbi->expects($this->any())->method('escapeString')
|
||||
->will($this->returnArgument(0));
|
||||
$dbi->expects($this->once())
|
||||
->method('tryQuery')
|
||||
->with($expectedQuery)
|
||||
->will($this->returnValue(true));
|
||||
$dbi->expects($this->at(1))
|
||||
$dbi->expects($this->at(3))
|
||||
->method('fetchArray')
|
||||
->will(
|
||||
$this->returnValue(
|
||||
@ -133,7 +131,7 @@ class NavigationTest extends PMATestCase
|
||||
)
|
||||
)
|
||||
);
|
||||
$dbi->expects($this->at(2))
|
||||
$dbi->expects($this->at(4))
|
||||
->method('fetchArray')
|
||||
->will(
|
||||
$this->returnValue(
|
||||
@ -143,11 +141,13 @@ class NavigationTest extends PMATestCase
|
||||
)
|
||||
)
|
||||
);
|
||||
$dbi->expects($this->at(3))
|
||||
$dbi->expects($this->at(5))
|
||||
->method('fetchArray')
|
||||
->will($this->returnValue(false));
|
||||
$dbi->expects($this->once())
|
||||
->method('freeResult');
|
||||
$dbi->expects($this->any())->method('escapeString')
|
||||
->will($this->returnArgument(0));
|
||||
|
||||
$GLOBALS['dbi'] = $dbi;
|
||||
|
||||
|
||||
@ -479,20 +479,15 @@ class ExportHtmlwordTest extends PMATestCase
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$dbi->expects($this->at(1))
|
||||
$dbi->expects($this->exactly(2))
|
||||
->method('fetchResult')
|
||||
->will($this->returnValue(array()));
|
||||
|
||||
$dbi->expects($this->at(6))
|
||||
->method('fetchResult')
|
||||
->will(
|
||||
$this->returnValue(
|
||||
array(
|
||||
'fieldname' => array(
|
||||
'values' => 'test-',
|
||||
'transformation' => 'testfoo',
|
||||
'mimetype' => 'test<'
|
||||
)
|
||||
->willReturnOnConsecutiveCalls(
|
||||
array(),
|
||||
array(
|
||||
'fieldname' => array(
|
||||
'values' => 'test-',
|
||||
'transformation' => 'testfoo',
|
||||
'mimetype' => 'test<'
|
||||
)
|
||||
)
|
||||
);
|
||||
@ -527,6 +522,8 @@ class ExportHtmlwordTest extends PMATestCase
|
||||
)
|
||||
)
|
||||
);
|
||||
$dbi->expects($this->any())->method('escapeString')
|
||||
->will($this->returnArgument(0));
|
||||
|
||||
$GLOBALS['dbi'] = $dbi;
|
||||
|
||||
@ -573,29 +570,20 @@ class ExportHtmlwordTest extends PMATestCase
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$dbi->expects($this->at(1))
|
||||
$dbi->expects($this->exactly(2))
|
||||
->method('fetchResult')
|
||||
->will(
|
||||
$this->returnValue(
|
||||
array(
|
||||
'fieldname' => array(
|
||||
'foreign_table' => 'ftable',
|
||||
'foreign_field' => 'ffield'
|
||||
)
|
||||
->willReturnOnConsecutiveCalls(
|
||||
array(
|
||||
'fieldname' => array(
|
||||
'foreign_table' => 'ftable',
|
||||
'foreign_field' => 'ffield'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$dbi->expects($this->at(6))
|
||||
->method('fetchResult')
|
||||
->will(
|
||||
$this->returnValue(
|
||||
array(
|
||||
'field' => array(
|
||||
'values' => 'test-',
|
||||
'transformation' => 'testfoo',
|
||||
'mimetype' => 'test<'
|
||||
)
|
||||
),
|
||||
array(
|
||||
'field' => array(
|
||||
'values' => 'test-',
|
||||
'transformation' => 'testfoo',
|
||||
'mimetype' => 'test<'
|
||||
)
|
||||
)
|
||||
);
|
||||
@ -631,6 +619,8 @@ class ExportHtmlwordTest extends PMATestCase
|
||||
)
|
||||
)
|
||||
);
|
||||
$dbi->expects($this->any())->method('escapeString')
|
||||
->will($this->returnArgument(0));
|
||||
|
||||
$GLOBALS['dbi'] = $dbi;
|
||||
|
||||
@ -700,6 +690,8 @@ class ExportHtmlwordTest extends PMATestCase
|
||||
)
|
||||
)
|
||||
);
|
||||
$dbi->expects($this->any())->method('escapeString')
|
||||
->will($this->returnArgument(0));
|
||||
|
||||
$GLOBALS['dbi'] = $dbi;
|
||||
|
||||
|
||||
@ -688,20 +688,15 @@ class ExportOdtTest extends PMATestCase
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$dbi->expects($this->at(1))
|
||||
$dbi->expects($this->exactly(2))
|
||||
->method('fetchResult')
|
||||
->will($this->returnValue(array()));
|
||||
|
||||
$dbi->expects($this->at(6))
|
||||
->method('fetchResult')
|
||||
->will(
|
||||
$this->returnValue(
|
||||
array(
|
||||
'fieldname' => array(
|
||||
'values' => 'test-',
|
||||
'transformation' => 'testfoo',
|
||||
'mimetype' => 'test<'
|
||||
)
|
||||
->willReturnOnConsecutiveCalls(
|
||||
array(),
|
||||
array(
|
||||
'fieldname' => array(
|
||||
'values' => 'test-',
|
||||
'transformation' => 'testfoo',
|
||||
'mimetype' => 'test<'
|
||||
)
|
||||
)
|
||||
);
|
||||
@ -794,29 +789,20 @@ class ExportOdtTest extends PMATestCase
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$dbi->expects($this->at(1))
|
||||
$dbi->expects($this->exactly(2))
|
||||
->method('fetchResult')
|
||||
->will(
|
||||
$this->returnValue(
|
||||
array(
|
||||
'fieldname' => array(
|
||||
'foreign_table' => 'ftable',
|
||||
'foreign_field' => 'ffield'
|
||||
)
|
||||
->willReturnOnConsecutiveCalls(
|
||||
array(
|
||||
'fieldname' => array(
|
||||
'foreign_table' => 'ftable',
|
||||
'foreign_field' => 'ffield'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$dbi->expects($this->at(6))
|
||||
->method('fetchResult')
|
||||
->will(
|
||||
$this->returnValue(
|
||||
array(
|
||||
'field' => array(
|
||||
'values' => 'test-',
|
||||
'transformation' => 'testfoo',
|
||||
'mimetype' => 'test<'
|
||||
)
|
||||
),
|
||||
array(
|
||||
'field' => array(
|
||||
'values' => 'test-',
|
||||
'transformation' => 'testfoo',
|
||||
'mimetype' => 'test<'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
@ -92,6 +92,9 @@ class ExportSqlTest extends PMATestCase
|
||||
->method('getCompatibilities')
|
||||
->will($this->returnValue(array('v1', 'v2')));
|
||||
|
||||
$dbi->expects($this->any())->method('escapeString')
|
||||
->will($this->returnArgument(0));
|
||||
|
||||
$GLOBALS['dbi'] = $dbi;
|
||||
$GLOBALS['plugin_param']['export_type'] = 'server';
|
||||
$GLOBALS['plugin_param']['single_table'] = false;
|
||||
@ -857,8 +860,10 @@ class ExportSqlTest extends PMATestCase
|
||||
$dbi = $this->getMockBuilder('PMA\libraries\DatabaseInterface')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$dbi->expects($this->any())->method('escapeString')
|
||||
->will($this->returnArgument(0));
|
||||
|
||||
$dbi->expects($this->at(0))
|
||||
$dbi->expects($this->any(0))
|
||||
->method('getColumns')
|
||||
->with('db', 'view')
|
||||
->will(
|
||||
@ -876,22 +881,6 @@ class ExportSqlTest extends PMATestCase
|
||||
)
|
||||
);
|
||||
|
||||
$dbi->expects($this->at(1))
|
||||
->method('getColumns')
|
||||
->with('db', 'view')
|
||||
->will(
|
||||
$this->returnValue(
|
||||
array(
|
||||
'cname' => array(
|
||||
'Type' => 'char',
|
||||
'Collation' => 'utf-8',
|
||||
'Null' => 'YES',
|
||||
'Comment' => 'cmt',
|
||||
'Field' => 'fname'
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
$GLOBALS['dbi'] = $dbi;
|
||||
$GLOBALS['sql_compatibility'] = 'MSSQL';
|
||||
|
||||
@ -910,6 +899,31 @@ class ExportSqlTest extends PMATestCase
|
||||
|
||||
// case 2
|
||||
unset($GLOBALS['sql_compatibility']);
|
||||
|
||||
$dbi = $this->getMockBuilder('PMA\libraries\DatabaseInterface')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$dbi->expects($this->any())->method('escapeString')
|
||||
->will($this->returnArgument(0));
|
||||
|
||||
$dbi->expects($this->any())
|
||||
->method('getColumns')
|
||||
->with('db', 'view')
|
||||
->will(
|
||||
$this->returnValue(
|
||||
array(
|
||||
'cname' => array(
|
||||
'Type' => 'char',
|
||||
'Collation' => 'utf-8',
|
||||
'Null' => 'YES',
|
||||
'Comment' => 'cmt',
|
||||
'Field' => 'fname'
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
$GLOBALS['dbi'] = $dbi;
|
||||
|
||||
$result = $method->invoke(
|
||||
$this->object, 'db', 'view', "\n", false
|
||||
);
|
||||
@ -950,12 +964,8 @@ class ExportSqlTest extends PMATestCase
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$dbi->expects($this->at(0))
|
||||
$dbi->expects($this->any())
|
||||
->method('query')
|
||||
->with(
|
||||
'SHOW TABLE STATUS FROM `db` WHERE Name = \'table\'', null,
|
||||
PMA\libraries\DatabaseInterface::QUERY_STORE
|
||||
)
|
||||
->will($this->returnValue('res'));
|
||||
|
||||
$dbi->expects($this->never())
|
||||
@ -982,11 +992,6 @@ class ExportSqlTest extends PMATestCase
|
||||
->with('res')
|
||||
->will($this->returnValue($tmpres));
|
||||
|
||||
$dbi->expects($this->at(5))
|
||||
->method('query')
|
||||
->with('SET SQL_QUOTE_SHOW_CREATE = 1')
|
||||
->will($this->returnValue('res'));
|
||||
|
||||
$dbi->expects($this->once())
|
||||
->method('tryQuery')
|
||||
->with('SHOW CREATE TABLE `db`.`table`')
|
||||
@ -1019,7 +1024,7 @@ class ExportSqlTest extends PMATestCase
|
||||
|
||||
$dbi->expects($this->once())
|
||||
->method('getTable')
|
||||
->will($this->returnValue(new Table('table', 'db')));
|
||||
->will($this->returnValue(new Table('table', 'db', $dbi)));
|
||||
|
||||
$GLOBALS['dbi'] = $dbi;
|
||||
$GLOBALS['cfg']['Server']['DisableIS'] = false;
|
||||
@ -1121,12 +1126,8 @@ class ExportSqlTest extends PMATestCase
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$dbi->expects($this->at(0))
|
||||
$dbi->expects($this->any())
|
||||
->method('query')
|
||||
->with(
|
||||
'SHOW TABLE STATUS FROM `db` WHERE Name = \'table\'', null,
|
||||
PMA\libraries\DatabaseInterface::QUERY_STORE
|
||||
)
|
||||
->will($this->returnValue('res'));
|
||||
|
||||
$dbi->expects($this->never())
|
||||
@ -1153,11 +1154,6 @@ class ExportSqlTest extends PMATestCase
|
||||
->with('res')
|
||||
->will($this->returnValue($tmpres));
|
||||
|
||||
$dbi->expects($this->at(5))
|
||||
->method('query')
|
||||
->with('SET SQL_QUOTE_SHOW_CREATE = 0')
|
||||
->will($this->returnValue('res'));
|
||||
|
||||
$dbi->expects($this->once())
|
||||
->method('tryQuery')
|
||||
->with('SHOW CREATE TABLE `db`.`table`')
|
||||
@ -1169,7 +1165,10 @@ class ExportSqlTest extends PMATestCase
|
||||
|
||||
$dbi->expects($this->once())
|
||||
->method('getTable')
|
||||
->will($this->returnValue(new Table('table', 'db')));
|
||||
->will($this->returnValue(new Table('table', 'db', $dbi)));
|
||||
$dbi->expects($this->any())
|
||||
->method('escapeString')
|
||||
->will($this->returnArgument(0));
|
||||
|
||||
$GLOBALS['dbi'] = $dbi;
|
||||
$GLOBALS['cfg']['Server']['DisableIS'] = false;
|
||||
@ -1207,32 +1206,24 @@ class ExportSqlTest extends PMATestCase
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$dbi->expects($this->at(0))
|
||||
$dbi->expects($this->exactly(2))
|
||||
->method('fetchResult')
|
||||
->will(
|
||||
$this->returnValue(
|
||||
array(
|
||||
'foo' => array(
|
||||
'foreign_table' => 'ftable',
|
||||
'foreign_field' => 'ffield'
|
||||
)
|
||||
->willReturnOnConsecutiveCalls(
|
||||
array(
|
||||
'foo' => array(
|
||||
'foreign_table' => 'ftable',
|
||||
'foreign_field' => 'ffield'
|
||||
)
|
||||
),
|
||||
array(
|
||||
'fieldname' => array(
|
||||
'values' => 'test-',
|
||||
'transformation' => 'testfoo',
|
||||
'mimetype' => 'test<'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$dbi->expects($this->at(1))
|
||||
->method('fetchResult')
|
||||
->will(
|
||||
$this->returnValue(
|
||||
array(
|
||||
'fieldname' => array(
|
||||
'values' => 'test-',
|
||||
'transformation' => 'testfoo',
|
||||
'mimetype' => 'test<'
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
$GLOBALS['dbi'] = $dbi;
|
||||
|
||||
$method = new ReflectionMethod('PMA\libraries\plugins\export\ExportSql', '_getTableComments');
|
||||
|
||||
@ -364,6 +364,7 @@ class ExportTexytextTest extends PMATestCase
|
||||
$this->object = $this->getMockBuilder('PMA\libraries\plugins\export\ExportTexytext')
|
||||
->setMethods(array('formatOneColumnDefinition'))
|
||||
->getMock();
|
||||
$GLOBALS['controllink'] = null;
|
||||
|
||||
// case 1
|
||||
|
||||
@ -387,20 +388,25 @@ class ExportTexytextTest extends PMATestCase
|
||||
->with('db', 'table')
|
||||
->will($this->returnValue($keys));
|
||||
|
||||
$dbi->expects($this->at(2))
|
||||
$dbi->expects($this->exactly(2))
|
||||
->method('fetchResult')
|
||||
->will(
|
||||
$this->returnValue(
|
||||
array(
|
||||
'fname' => array(
|
||||
'foreign_table' => '<ftable',
|
||||
'foreign_field' => 'ffield>'
|
||||
)
|
||||
->willReturnOnConsecutiveCalls(
|
||||
array(
|
||||
'fname' => array(
|
||||
'foreign_table' => '<ftable',
|
||||
'foreign_field' => 'ffield>'
|
||||
)
|
||||
),
|
||||
array(
|
||||
'fname' => array(
|
||||
'values' => 'test-',
|
||||
'transformation' => 'testfoo',
|
||||
'mimetype' => 'test<'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$dbi->expects($this->at(3))
|
||||
$dbi->expects($this->once())
|
||||
->method('fetchValue')
|
||||
->will(
|
||||
$this->returnValue(
|
||||
@ -408,20 +414,6 @@ class ExportTexytextTest extends PMATestCase
|
||||
)
|
||||
);
|
||||
|
||||
$dbi->expects($this->at(5))
|
||||
->method('fetchResult')
|
||||
->will(
|
||||
$this->returnValue(
|
||||
array(
|
||||
'fname' => array(
|
||||
'values' => 'test-',
|
||||
'transformation' => 'testfoo',
|
||||
'mimetype' => 'test<'
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$columns = array(
|
||||
'Field' => 'fname',
|
||||
'Comment' => 'comm'
|
||||
|
||||
Loading…
Reference in New Issue
Block a user