Merge branch 'master' of https://github.com/phpmyadmin/phpmyadmin into serverview_refactor
This commit is contained in:
commit
247ea08eaf
@ -377,6 +377,11 @@ function PMA_getSqlQueryAndCreateDbBeforeCopy()
|
||||
$GLOBALS['dbi']->query($local_query);
|
||||
$GLOBALS['db'] = $original_db;
|
||||
|
||||
// Set the SQL mode to NO_AUTO_VALUE_ON_ZERO to prevent MySQL from creating
|
||||
// export statements it cannot import
|
||||
$sql_set_mode = "SET SQL_MODE='NO_AUTO_VALUE_ON_ZERO'";
|
||||
PMA_DBI_query($sql_set_mode);
|
||||
|
||||
// rebuild the database list because PMA_Table::moveCopy
|
||||
// checks in this list if the target db exists
|
||||
$GLOBALS['pma']->databases->build();
|
||||
|
||||
@ -1667,7 +1667,7 @@ function PMA_SQP_analyze($arr)
|
||||
$in_limit = false;
|
||||
$after_limit = true;
|
||||
|
||||
// for the presnece of PROCEDURE ANALYSE
|
||||
// for the presence of PROCEDURE ANALYSE
|
||||
if (isset($subresult['queryflags']['select_from'])
|
||||
&& $subresult['queryflags']['select_from'] == 1
|
||||
&& ($i + 1) < $size
|
||||
@ -1678,7 +1678,7 @@ function PMA_SQP_analyze($arr)
|
||||
}
|
||||
}
|
||||
|
||||
// for the presnece of INTO OUTFILE
|
||||
// for the presence of INTO OUTFILE
|
||||
if ($upper_data == 'INTO'
|
||||
&& isset($subresult['queryflags']['select_from'])
|
||||
&& $subresult['queryflags']['select_from'] == 1
|
||||
|
||||
107
test/classes/PMA_TableSearch_test.php
Normal file
107
test/classes/PMA_TableSearch_test.php
Normal file
@ -0,0 +1,107 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* Tests for PMA_TableSearch
|
||||
*
|
||||
* @package PhpMyAdmin-test
|
||||
*/
|
||||
|
||||
/*
|
||||
* Include to test.
|
||||
*/
|
||||
require_once 'libraries/TableSearch.class.php';
|
||||
require_once 'libraries/Util.class.php';
|
||||
require_once 'libraries/php-gettext/gettext.inc';
|
||||
require_once 'libraries/database_interface.inc.php';
|
||||
require_once 'libraries/relation.lib.php';
|
||||
require_once 'libraries/sqlparser.lib.php';
|
||||
|
||||
/**
|
||||
* Tests for PMA_TableSearch
|
||||
*
|
||||
* @package PhpMyAdmin-test
|
||||
*/
|
||||
class PMA_TableSearch_Test extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* Setup function for test cases
|
||||
*
|
||||
* @access protected
|
||||
* @return void
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
/**
|
||||
* SET these to avoid undefined index error
|
||||
*/
|
||||
$GLOBALS['server'] = 1;
|
||||
|
||||
$dbi = $this->getMockBuilder('PMA_DatabaseInterface')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$columns =array(
|
||||
array(
|
||||
'Field' => 'Field1',
|
||||
'Type' => 'Type1',
|
||||
'Null' => 'Null1',
|
||||
'Collation' => 'Collation1',
|
||||
),
|
||||
array(
|
||||
'Field' => 'Field2',
|
||||
'Type' => 'Type2',
|
||||
'Null' => 'Null2',
|
||||
'Collation' => 'Collation2',
|
||||
)
|
||||
);
|
||||
$dbi->expects($this->any())->method('getColumns')
|
||||
->will($this->returnValue($columns));
|
||||
|
||||
$show_create_table = "CREATE TABLE `pma_bookmark` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`dbase` varchar(255) COLLATE utf8_bin NOT NULL DEFAULT '',
|
||||
`user` varchar(255) COLLATE utf8_bin NOT NULL DEFAULT '',
|
||||
`label` varchar(255) CHARACTER SET utf8 NOT NULL DEFAULT '',
|
||||
`query` text COLLATE utf8_bin NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `foreign_field` (`foreign_db`,`foreign_table`)
|
||||
) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Bookmarks'";
|
||||
|
||||
$dbi->expects($this->any())->method('fetchValue')
|
||||
->will($this->returnValue($show_create_table));
|
||||
|
||||
$GLOBALS['dbi'] = $dbi;
|
||||
}
|
||||
|
||||
/**
|
||||
* tearDown function for test cases
|
||||
*
|
||||
* @access protected
|
||||
* @return void
|
||||
*/
|
||||
protected function tearDown()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for __construct
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testConstruct()
|
||||
{
|
||||
$tableSearch = new PMA_TableSearch("PMA", "PMA_BookMark", "normal");
|
||||
$columNames = $tableSearch->getColumnNames();
|
||||
$this->assertEquals(
|
||||
'Field1',
|
||||
$columNames[0]
|
||||
);
|
||||
$this->assertEquals(
|
||||
'Field2',
|
||||
$columNames[1]
|
||||
);
|
||||
}
|
||||
}
|
||||
?>
|
||||
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* Tests for Table.class.php
|
||||
*
|
||||
@ -8,7 +9,6 @@
|
||||
/*
|
||||
* Include to test.
|
||||
*/
|
||||
|
||||
require_once 'libraries/Table.class.php';
|
||||
require_once 'libraries/Util.class.php';
|
||||
require_once 'libraries/database_interface.inc.php';
|
||||
@ -18,7 +18,6 @@ require_once 'libraries/Theme.class.php';
|
||||
require_once 'libraries/Tracker.class.php';
|
||||
require_once 'libraries/relation.lib.php';
|
||||
|
||||
|
||||
/**
|
||||
* Tests behaviour of PMA_Table class
|
||||
*
|
||||
@ -33,6 +32,9 @@ class PMA_Table_Test extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
/**
|
||||
* SET these to avoid undefined index error
|
||||
*/
|
||||
$GLOBALS['server'] = 0;
|
||||
$GLOBALS['cfg']['Server']['DisableIS'] = false;
|
||||
$GLOBALS['cfg']['ServerDefault'] = 1;
|
||||
@ -43,8 +45,93 @@ class PMA_Table_Test extends PHPUnit_Framework_TestCase
|
||||
$GLOBALS['pmaThemeImage'] = 'themes/dot.gif';
|
||||
$GLOBALS['is_ajax_request'] = false;
|
||||
$GLOBALS['cfgRelation'] = PMA_getRelationsParam();
|
||||
|
||||
$dbi = $this->getMockBuilder('PMA_DatabaseInterface')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$sql_isView_true = "SELECT TABLE_NAME
|
||||
FROM information_schema.VIEWS
|
||||
WHERE TABLE_SCHEMA = 'PMA'
|
||||
AND TABLE_NAME = 'PMA_BookMark'";
|
||||
|
||||
$sql_isView_false = "SELECT TABLE_NAME
|
||||
FROM information_schema.VIEWS
|
||||
WHERE TABLE_SCHEMA = 'PMA'
|
||||
AND TABLE_NAME = 'PMA_BookMark_2'";
|
||||
|
||||
$sql_isUpdatableView_true = "SELECT TABLE_NAME
|
||||
FROM information_schema.VIEWS
|
||||
WHERE TABLE_SCHEMA = 'PMA'
|
||||
AND TABLE_NAME = 'PMA_BookMark'
|
||||
AND IS_UPDATABLE = 'YES'";
|
||||
|
||||
$sql_isUpdatableView_false = "SELECT TABLE_NAME
|
||||
FROM information_schema.VIEWS
|
||||
WHERE TABLE_SCHEMA = 'PMA'
|
||||
AND TABLE_NAME = 'PMA_BookMark_2'
|
||||
AND IS_UPDATABLE = 'YES'";
|
||||
|
||||
$sql_analyzeStructure_true = "SELECT COLUMN_NAME, DATA_TYPE
|
||||
FROM information_schema.COLUMNS
|
||||
WHERE TABLE_SCHEMA = 'PMA'
|
||||
AND TABLE_NAME = 'PMA_BookMark'";
|
||||
|
||||
$fetchResult = array(
|
||||
array(
|
||||
$sql_isView_true,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
0,
|
||||
true
|
||||
),
|
||||
array(
|
||||
$sql_isView_false,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
0,
|
||||
false
|
||||
),
|
||||
array(
|
||||
$sql_isUpdatableView_true,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
0,
|
||||
true
|
||||
),
|
||||
array(
|
||||
$sql_isUpdatableView_false,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
0,
|
||||
false
|
||||
),
|
||||
array(
|
||||
$sql_analyzeStructure_true,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
0,
|
||||
array(
|
||||
array('COLUMN_NAME'=>'COLUMN_NAME', 'DATA_TYPE'=>'DATA_TYPE')
|
||||
)
|
||||
),
|
||||
);
|
||||
|
||||
$dbi = $this->getMockBuilder('PMA_DatabaseInterface')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$dbi->expects($this->any())->method('fetchResult')
|
||||
->will($this->returnValueMap($fetchResult));
|
||||
|
||||
$GLOBALS['dbi'] = $dbi;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test object creating
|
||||
*
|
||||
@ -57,17 +144,37 @@ class PMA_Table_Test extends PHPUnit_Framework_TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* Test renaming
|
||||
* Test for constructor
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testRename()
|
||||
public function testConstruct()
|
||||
{
|
||||
$table = new PMA_Table('table1', 'pma_test');
|
||||
$table->rename('table3');
|
||||
$this->assertEquals('table3', $table->getName());
|
||||
$table = new PMA_Table("PMA_BookMark", "PMA");
|
||||
$this->assertEquals(
|
||||
'PMA_BookMark',
|
||||
$table->__toString()
|
||||
);
|
||||
$this->assertEquals(
|
||||
'PMA_BookMark',
|
||||
$table->getName()
|
||||
);
|
||||
$this->assertEquals(
|
||||
'PMA',
|
||||
$table->getDbName()
|
||||
);
|
||||
$this->assertEquals(
|
||||
'PMA.PMA_BookMark',
|
||||
$table->getFullName()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test object creating
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
/**
|
||||
* Test Set & Get
|
||||
*
|
||||
@ -88,34 +195,6 @@ class PMA_Table_Test extends PHPUnit_Framework_TestCase
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test getting columns
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testColumns()
|
||||
{
|
||||
$table = new PMA_Table('table1', 'pma_test');
|
||||
$this->assertEquals(
|
||||
array('`pma_test`.`table1`.`i`', '`pma_test`.`table1`.`o`'),
|
||||
$table->getColumns()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test getting unique columns
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testUniqueColumns()
|
||||
{
|
||||
$table = new PMA_Table('table1', 'pma_test');
|
||||
$this->assertEquals(
|
||||
array(),
|
||||
$table->getUniqueColumns()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test name validation
|
||||
*
|
||||
@ -148,5 +227,72 @@ class PMA_Table_Test extends PHPUnit_Framework_TestCase
|
||||
array('te\\st', false),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for isView
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testIsView()
|
||||
{
|
||||
$this->assertEquals(
|
||||
false,
|
||||
PMA_Table::isView()
|
||||
);
|
||||
|
||||
//validate that it is the same as DBI fetchResult
|
||||
$this->assertEquals(
|
||||
true,
|
||||
PMA_Table::isView('PMA', 'PMA_BookMark')
|
||||
);
|
||||
$this->assertEquals(
|
||||
false,
|
||||
PMA_Table::isView('PMA', 'PMA_BookMark_2')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for isUpdatableView
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testIsUpdatableView()
|
||||
{
|
||||
$this->assertEquals(
|
||||
false,
|
||||
PMA_Table::isUpdatableView()
|
||||
);
|
||||
|
||||
//validate that it is the same as DBI fetchResult
|
||||
$this->assertEquals(
|
||||
true,
|
||||
PMA_Table::isUpdatableView('PMA', 'PMA_BookMark')
|
||||
);
|
||||
$this->assertEquals(
|
||||
false,
|
||||
PMA_Table::isUpdatableView('PMA', 'PMA_BookMark_2')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for analyzeStructure
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testAnalyzeStructure()
|
||||
{
|
||||
$this->assertEquals(
|
||||
false,
|
||||
PMA_Table::analyzeStructure()
|
||||
);
|
||||
|
||||
//validate that it is the same as DBI fetchResult
|
||||
$show_create_table = PMA_Table::analyzeStructure('PMA', 'PMA_BookMark');
|
||||
$this->assertEquals(
|
||||
array('type'=>'DATA_TYPE'),
|
||||
$show_create_table[0]['create_table_fields']['COLUMN_NAME']
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
|
||||
@ -29,6 +29,11 @@ class PMA_From_Processing_Test extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testProcessFormSet()
|
||||
{
|
||||
if (!defined('PMA_TEST_HEADERS')) {
|
||||
$this->markTestSkipped(
|
||||
'Cannot redefine constant/function - missing runkit extension'
|
||||
);
|
||||
}
|
||||
|
||||
// case 1
|
||||
$formDisplay = $this->getMockBuilder('FormDisplay')
|
||||
@ -106,7 +111,7 @@ class PMA_From_Processing_Test extends PHPUnit_Framework_TestCase
|
||||
process_formset($formDisplay);
|
||||
|
||||
$this->assertEquals(
|
||||
'HTTP/1.1 303 See OtherLocation: index.php',
|
||||
array('HTTP/1.1 303 See Other', 'Location: index.php'),
|
||||
$GLOBALS['header']
|
||||
);
|
||||
|
||||
|
||||
@ -354,8 +354,10 @@ class PMA_User_Preferences_Test extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testUserprefsRedirect()
|
||||
{
|
||||
if (! PMA_HAS_RUNKIT) {
|
||||
$this->markTestSkipped('Cannot redefine constant');
|
||||
if (!defined('PMA_TEST_HEADERS')) {
|
||||
$this->markTestSkipped(
|
||||
'Cannot redefine constant/function - missing runkit extension'
|
||||
);
|
||||
}
|
||||
|
||||
$GLOBALS['cfg']['PmaAbsoluteUri'] = 'http://www.phpmyadmin.net';
|
||||
@ -379,7 +381,7 @@ class PMA_User_Preferences_Test extends PHPUnit_Framework_TestCase
|
||||
$this->assertContains(
|
||||
'Location: http://www.phpmyadmin.netfile.html?a=b&saved=1&server=0&' .
|
||||
'token=token#h+ash',
|
||||
$GLOBALS['header']
|
||||
$GLOBALS['header'][0]
|
||||
);
|
||||
|
||||
if ($redefine !== null) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user