Merge branch 'master' of https://github.com/phpmyadmin/phpmyadmin into server_refactor2
This commit is contained in:
commit
e8fc1adf6b
@ -25,7 +25,7 @@ phpMyAdmin - ChangeLog
|
||||
- [core] Dropped support for PHP 5.2.
|
||||
+ rfe #487 and rfe #1405 Find and Replacing column wise
|
||||
+ rfe #1373 Use same create view dialog for editing a view
|
||||
+ rfe #316 Configurable menus; allow user groups with customized menus per group
|
||||
+ rfe #316 Configurable menus; allow user groups with customized menus per group- bug #4024 Editing field a record is selected by makes pma load forever
|
||||
|
||||
4.0.5.0 (not yet released)
|
||||
- bug #3977 Not detected configuration storage
|
||||
|
||||
14
db_qbe.php
14
db_qbe.php
@ -11,6 +11,9 @@
|
||||
*/
|
||||
require_once 'libraries/common.inc.php';
|
||||
require_once 'libraries/DBQbe.class.php';
|
||||
require_once 'libraries/bookmark.lib.php';
|
||||
require_once 'libraries/sql.lib.php';
|
||||
|
||||
$response = PMA_Response::getInstance();
|
||||
|
||||
// Gets the relation settings
|
||||
@ -25,8 +28,15 @@ if (isset($_REQUEST['submit_sql']) && ! empty($sql_query)) {
|
||||
$message_to_display = true;
|
||||
} else {
|
||||
$goto = 'db_sql.php';
|
||||
include 'sql.php';
|
||||
exit;
|
||||
|
||||
// Parse and analyze the query
|
||||
require_once 'libraries/parse_analyze.inc.php';
|
||||
|
||||
PMA_executeQueryAndSendQueryResponse(
|
||||
$analyzed_sql_results, false, $_REQUEST['db'], null, null, null, null,
|
||||
false, null, null, null, null, $goto, $pmaThemeImage, null, null, null,
|
||||
$sql_query, null, null
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -63,24 +63,11 @@ if (defined('SESSIONUPLOAD')) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets globals from $_GET
|
||||
*/
|
||||
$get_params = array(
|
||||
'message',
|
||||
'id'
|
||||
);
|
||||
foreach ($get_params as $one_get_param) {
|
||||
if (isset($_GET[$one_get_param])) {
|
||||
$GLOBALS[$one_get_param] = $_GET[$one_get_param];
|
||||
}
|
||||
}
|
||||
|
||||
// AJAX requests can't be cached!
|
||||
PMA_noCacheHeader();
|
||||
|
||||
// $GLOBALS["message"] is used for asking for an import message
|
||||
if (isset($GLOBALS["message"]) && $GLOBALS["message"]) {
|
||||
// $_GET["message"] is used for asking for an import message
|
||||
if (isset($_GET["message"]) && $_GET["message"]) {
|
||||
|
||||
header('Content-type: text/html');
|
||||
|
||||
@ -100,6 +87,6 @@ if (isset($GLOBALS["message"]) && $GLOBALS["message"]) {
|
||||
echo '</fieldset>'."\n";
|
||||
|
||||
} else {
|
||||
PMA_importAjaxStatus($GLOBALS["id"]);
|
||||
PMA_importAjaxStatus($_GET["id"]);
|
||||
}
|
||||
?>
|
||||
|
||||
@ -170,7 +170,7 @@ var ColumnType = {
|
||||
};
|
||||
|
||||
/*******************************************************************************
|
||||
* JQPlot specifc code
|
||||
* JQPlot specific code
|
||||
******************************************************************************/
|
||||
|
||||
/**
|
||||
|
||||
@ -1201,6 +1201,19 @@ AJAX.registerOnload('server_status_monitor.js', function () {
|
||||
settings.axes.yaxis.tickOptions = {
|
||||
formatter: $.jqplot.byteFormatter(1) // KiB
|
||||
};
|
||||
} else if (settings.title === PMA_messages.strQuestions
|
||||
|| settings.title === PMA_messages.strConnections
|
||||
) {
|
||||
settings.axes.yaxis.tickOptions = {
|
||||
formatter: function(format, val) {
|
||||
if (Math.abs(val) >= 1000000)
|
||||
return $.jqplot.sprintf("%.3g M", val/1000000);
|
||||
else if (Math.abs(val) >= 1000)
|
||||
return $.jqplot.sprintf("%.3g k", val/1000);
|
||||
else
|
||||
return $.jqplot.sprintf("%d", val);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
settings.series = chartObj.series;
|
||||
@ -1290,7 +1303,6 @@ AJAX.registerOnload('server_status_monitor.js', function () {
|
||||
);
|
||||
}
|
||||
$('#gridchart' + runtime.chartAI)
|
||||
.css('overflow', 'hidden')
|
||||
.parent()
|
||||
.append($legend);
|
||||
|
||||
|
||||
13
js/sql.js
13
js/sql.js
@ -364,7 +364,7 @@ AJAX.registerOnload('sql.js', function () {
|
||||
$("#resultsForm.ajax .mult_submit[value=edit]").live('click', function (event) {
|
||||
event.preventDefault();
|
||||
|
||||
/*Check whether atleast one row is selected for change*/
|
||||
/*Check whether at least one row is selected*/
|
||||
if ($("#table_results tbody tr, #table_results tbody tr td").hasClass("marked")) {
|
||||
var $div = $('<div id="change_row_dialog"></div>');
|
||||
|
||||
@ -426,6 +426,17 @@ AJAX.registerOnload('sql.js', function () {
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Checks whether at least one row is selected for deletion or export
|
||||
*/
|
||||
$("#resultsForm.ajax .mult_submit[value=delete]," +
|
||||
"#resultsForm.ajax .mult_submit[value=export]").live('click', function (event) {
|
||||
/*Check whether at least one row is selected*/
|
||||
if (!$("#table_results tbody tr, #table_results tbody tr td").hasClass("marked")) {
|
||||
event.preventDefault();
|
||||
PMA_ajaxShowMessage(PMA_messages.strNoRowSelected);
|
||||
}
|
||||
});
|
||||
/**
|
||||
* Click action for "Go" button in ajax dialog insertForm -> insertRowTable
|
||||
*/
|
||||
|
||||
@ -362,7 +362,7 @@ AJAX.registerOnload('tbl_zoom_plot_jqplot.js', function () {
|
||||
// other
|
||||
} else {
|
||||
// type explicitly identified
|
||||
if (sqlTypes[key] !== null) {
|
||||
if (sqlTypes[key] != null) {
|
||||
if (sqlTypes[key] == 'bit') {
|
||||
sql_query += "b'" + value + "', ";
|
||||
}
|
||||
@ -376,6 +376,7 @@ AJAX.registerOnload('tbl_zoom_plot_jqplot.js', function () {
|
||||
}
|
||||
}
|
||||
}
|
||||
// remove two extraneous characters ', '
|
||||
sql_query = sql_query.substring(0, sql_query.length - 2);
|
||||
sql_query += ' WHERE ' + PMA_urldecode(searchedData[searchedDataKey].where_clause);
|
||||
|
||||
|
||||
@ -304,11 +304,14 @@ class Advisor
|
||||
*/
|
||||
private function _ruleExprEvaluateVariable($matches)
|
||||
{
|
||||
return isset($this->variables[$matches[1]])
|
||||
? (is_numeric($this->variables[$matches[1]])
|
||||
? $this->variables[$matches[1]]
|
||||
: '"'.$this->variables[$matches[1]].'"')
|
||||
: $matches[1];
|
||||
if (! isset($this->variables[$matches[1]])) {
|
||||
return $matches[1];
|
||||
}
|
||||
if (is_numeric($this->variables[$matches[1]])) {
|
||||
return $this->variables[$matches[1]];
|
||||
} else {
|
||||
return '\'' . addslashes($this->variables[$matches[1]]) . '\'';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -200,8 +200,8 @@ rule 'Query cache max size' [!fired('Query cache disabled')]
|
||||
Current query cache size: %s | implode(' ',ADVISOR_formatByteDown(value, 2, 2))
|
||||
|
||||
rule 'Query cache min result size' [!fired('Query cache disabled')]
|
||||
value == 1024*1024
|
||||
query_cache_limit
|
||||
value == 1024*1024
|
||||
The max size of the result set in the query cache is the default of 1 MiB.
|
||||
Changing {query_cache_limit} (usually by increasing) may increase efficiency. This variable determines the maximum size a query result may have to be inserted into the query cache. If there are many query results above 1 MiB that are well cacheable (many reads, little writes) then increasing {query_cache_limit} will increase efficiency. Whereas in the case of many query results being above 1 MiB that are not very well cacheable (often invalidated due to table updates) increasing {query_cache_limit} might reduce efficiency.
|
||||
query_cache_limit is set to 1 MiB
|
||||
|
||||
@ -55,7 +55,7 @@ function PMA_ifSetOr(&$var, $default = null, $type = 'similar')
|
||||
* $type can be:
|
||||
* - false : no type checking
|
||||
* - 'scalar' : whether type of $var is integer, float, string or boolean
|
||||
* - 'numeric' : whether type of $var is any number repesentation
|
||||
* - 'numeric' : whether type of $var is any number representation
|
||||
* - 'length' : whether type of $var is scalar with a string length > 0
|
||||
* - 'similar' : whether type of $var is similar to type of $compare
|
||||
* - 'equal' : whether type of $var is identical to type of $compare
|
||||
|
||||
@ -380,7 +380,7 @@ function PMA_getSqlQueryAndCreateDbBeforeCopy()
|
||||
// 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);
|
||||
$GLOBALS['dbi']->query($sql_set_mode);
|
||||
|
||||
// rebuild the database list because PMA_Table::moveCopy
|
||||
// checks in this list if the target db exists
|
||||
@ -428,7 +428,7 @@ function PMA_getSqlConstraintsQueryForFullDb(
|
||||
*
|
||||
* @param array $tables_full array of all tables in given db or dbs
|
||||
* @param object $export_sql_plugin export plugin instance
|
||||
* @param strin $db database name
|
||||
* @param string $db database name
|
||||
*
|
||||
* @return array $views
|
||||
*/
|
||||
|
||||
@ -340,6 +340,8 @@ function PMA_langDetails($lang)
|
||||
return array('uz[-_]lat|uzbek-latin', 'uz-lat', 'O‘zbekcha');
|
||||
case 'uz':
|
||||
return array('uz[-_]cyr|uzbek-cyrillic', 'uz-cyr', 'Ўзбекча');
|
||||
case 'vls':
|
||||
return array('vls|flemish', 'vls', 'West-Vlams');
|
||||
case 'zh_TW':
|
||||
return array('zh[-_](tw|hk)|chinese traditional', 'zh-TW', '中文');
|
||||
case 'zh_CN':
|
||||
|
||||
@ -15,7 +15,7 @@ if (!defined('PHPMYADMIN')) {
|
||||
* @param string $sql SQL query
|
||||
* @param array $databases array with all databases
|
||||
*
|
||||
* @return strin $db new database name
|
||||
* @return string $db new database name
|
||||
*/
|
||||
function PMA_getNewDatabase($sql, $databases)
|
||||
{
|
||||
@ -1028,6 +1028,9 @@ function PMA_addBookmark($pmaAbsoluteUri, $goto)
|
||||
exit;
|
||||
} else {
|
||||
// go back to sql.php to redisplay query; do not use & in this case:
|
||||
/**
|
||||
* @todo In which scenario does this happen?
|
||||
*/
|
||||
PMA_sendHeaderLocation(
|
||||
$pmaAbsoluteUri . $goto
|
||||
. '&label=' . $_POST['bkm_fields']['bkm_label']
|
||||
@ -2013,6 +2016,7 @@ function PMA_sendQueryResponseForResultsReturned($result, $justBrowsing,
|
||||
// value of a transformed field, show it here
|
||||
if (isset($_REQUEST['grid_edit']) && $_REQUEST['grid_edit'] == true) {
|
||||
PMA_sendResponseForGridEdit($result);
|
||||
// script has exited at this point
|
||||
}
|
||||
|
||||
// Gets the list of fields properties
|
||||
@ -2249,7 +2253,7 @@ function PMA_executeQueryAndSendQueryResponse($analyzed_sql_results,
|
||||
$query_type, $sql_query, $selected, $complete_query
|
||||
) {
|
||||
// Include PMA_Index class for use in PMA_DisplayResults class
|
||||
include './libraries/Index.class.php';
|
||||
include_once './libraries/Index.class.php';
|
||||
|
||||
include 'libraries/DisplayResults.class.php';
|
||||
|
||||
|
||||
@ -3041,5 +3041,18 @@ function PMA_SQP_getParserDataMap()
|
||||
'PMA_SQPdata_column_type' => $PMA_SQPdata_column_type,
|
||||
);
|
||||
}
|
||||
/**
|
||||
* Get Parser analyze Map from parse_analyze_inc.php
|
||||
*
|
||||
* @param array $sql_query The SQL string
|
||||
* @param array $db Current DB
|
||||
*
|
||||
* @return Array analyze Map from parse_analyze_inc.php
|
||||
*/
|
||||
function PMA_SQP_getParserAnalyzeMap($sql_query, $db)
|
||||
{
|
||||
include 'libraries/parse_analyze.inc.php';
|
||||
return $analyzed_sql_results;
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@ -176,14 +176,10 @@ class PMA_SysInfoWinnt extends PMA_SysInfo
|
||||
}
|
||||
$arrInstance = array();
|
||||
foreach ($arrProp as $propItem) {
|
||||
if ( empty($strValue)) {
|
||||
eval("\$value = \$objItem->" . $propItem->Name . ";");
|
||||
$arrInstance[$propItem->Name] = trim($value);
|
||||
} else {
|
||||
if (in_array($propItem->Name, $strValue)) {
|
||||
eval("\$value = \$objItem->" . $propItem->Name . ";");
|
||||
$arrInstance[$propItem->Name] = trim($value);
|
||||
}
|
||||
$name = $propItem->Name;
|
||||
if ( empty($strValue) || in_array($name, $strValue)) {
|
||||
$value = $objItem->$name;
|
||||
$arrInstance[$name] = trim($value);
|
||||
}
|
||||
}
|
||||
$arrData[] = $arrInstance;
|
||||
|
||||
7
sql.php
7
sql.php
@ -24,8 +24,6 @@ $header = $response->getHeader();
|
||||
$scripts = $header->getScripts();
|
||||
$scripts->addFile('jquery/jquery-ui-timepicker-addon.js');
|
||||
$scripts->addFile('tbl_change.js');
|
||||
// the next one needed because sql.php may do a "goto" to tbl_structure.php
|
||||
$scripts->addFile('tbl_structure.js');
|
||||
$scripts->addFile('indexes.js');
|
||||
$scripts->addFile('gis_data_editor.js');
|
||||
|
||||
@ -84,17 +82,20 @@ if (isset($_REQUEST['get_relational_values'])
|
||||
&& $_REQUEST['get_relational_values'] == true
|
||||
) {
|
||||
PMA_getRelationalValues($db, $table, $display_field);
|
||||
// script has exited at this point
|
||||
}
|
||||
|
||||
// Just like above, find possible values for enum fields during grid edit.
|
||||
if (isset($_REQUEST['get_enum_values']) && $_REQUEST['get_enum_values'] == true) {
|
||||
PMA_getEnumOrSetValues($db, $table, "enum");
|
||||
// script has exited at this point
|
||||
}
|
||||
|
||||
|
||||
// Find possible values for set fields during grid edit.
|
||||
if (isset($_REQUEST['get_set_values']) && $_REQUEST['get_set_values'] == true) {
|
||||
PMA_getEnumOrSetValues($db, $table, "set");
|
||||
// script has exited at this point
|
||||
}
|
||||
|
||||
/**
|
||||
@ -102,6 +103,7 @@ if (isset($_REQUEST['get_set_values']) && $_REQUEST['get_set_values'] == true) {
|
||||
*/
|
||||
if (isset($_REQUEST['set_col_prefs']) && $_REQUEST['set_col_prefs'] == true) {
|
||||
PMA_setColumnOrderOrVisibility($table, $db);
|
||||
// script has exited at this point
|
||||
}
|
||||
|
||||
// Default to browse if no query set and we have table
|
||||
@ -153,6 +155,7 @@ if (isset($find_real_end) && $find_real_end) {
|
||||
*/
|
||||
if (isset($_POST['store_bkm'])) {
|
||||
PMA_addBookmark($cfg['PmaAbsoluteUri'], $goto);
|
||||
// script has exited at this point
|
||||
} // end if
|
||||
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* handle row specifc actions like edit, delete, export
|
||||
* handle row specific actions like edit, delete, export
|
||||
*
|
||||
* @package PhpMyAdmin
|
||||
*/
|
||||
@ -11,18 +11,7 @@
|
||||
*/
|
||||
require_once 'libraries/common.inc.php';
|
||||
require_once 'libraries/mysql_charsets.inc.php';
|
||||
|
||||
/**
|
||||
* No rows were selected => show again the query and tell that user.
|
||||
*/
|
||||
if (! PMA_isValid($_REQUEST['rows_to_delete'], 'array')
|
||||
&& ! isset($_REQUEST['mult_btn'])
|
||||
) {
|
||||
$disp_message = __('No rows selected');
|
||||
$disp_query = '';
|
||||
include 'sql.php';
|
||||
exit;
|
||||
}
|
||||
require_once 'libraries/sql.lib.php';
|
||||
|
||||
if (isset($_REQUEST['submit_mult'])) {
|
||||
$submit_mult = $_REQUEST['submit_mult'];
|
||||
@ -131,13 +120,17 @@ if (!empty($submit_mult)) {
|
||||
$url_query = $original_url_query;
|
||||
}
|
||||
|
||||
// this is because sql.php could call tbl_structure
|
||||
// which would think it needs to call mult_submits.inc.php:
|
||||
unset($submit_mult, $_REQUEST['mult_btn']);
|
||||
|
||||
$active_page = 'sql.php';
|
||||
include 'sql.php';
|
||||
break;
|
||||
/**
|
||||
* Parse and analyze the query
|
||||
*/
|
||||
require_once 'libraries/parse_analyze.inc.php';
|
||||
|
||||
PMA_executeQueryAndSendQueryResponse(
|
||||
$analyzed_sql_results, false, $db, $table, null, null, null, false, null,
|
||||
null, null, null, $goto, $pmaThemeImage, null, null, null, $sql_query,
|
||||
null, null
|
||||
);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
@ -27,16 +27,6 @@ $scripts->addFile('tbl_change.js');
|
||||
$scripts->addFile('jquery/jquery-ui-timepicker-addon.js');
|
||||
$scripts->addFile('gis_data_editor.js');
|
||||
|
||||
$post_params = array(
|
||||
'ajax_request',
|
||||
'session_max_rows'
|
||||
);
|
||||
foreach ($post_params as $one_post_param) {
|
||||
if (isset($_POST[$one_post_param])) {
|
||||
$GLOBALS[$one_post_param] = $_POST[$one_post_param];
|
||||
}
|
||||
}
|
||||
|
||||
$table_search = new PMA_TableSearch($db, $table, "normal");
|
||||
|
||||
/**
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* Displays table structure infos like fields/columns, indexes, size, rows
|
||||
* and allows manipulation of indexes and columns/fields
|
||||
* Displays table structure infos like columns, indexes, size, rows
|
||||
* and allows manipulation of indexes and columns
|
||||
*
|
||||
* @package PhpMyAdmin
|
||||
*/
|
||||
@ -18,6 +18,8 @@ require_once 'libraries/mysql_charsets.inc.php';
|
||||
*/
|
||||
require_once 'libraries/structure.lib.php';
|
||||
require_once 'libraries/index.lib.php';
|
||||
require_once 'libraries/sql.lib.php';
|
||||
require_once 'libraries/bookmark.lib.php';
|
||||
|
||||
$response = PMA_Response::getInstance();
|
||||
$header = $response->getHeader();
|
||||
@ -91,7 +93,7 @@ if (! empty($submit_mult)) {
|
||||
if (isset($_REQUEST['selected_fld'])) {
|
||||
$err_url = 'tbl_structure.php?' . PMA_generate_common_url($db, $table);
|
||||
if ($submit_mult == 'browse') {
|
||||
// browsing the table displaying only selected fields/columns
|
||||
// browsing the table displaying only selected columns
|
||||
$GLOBALS['active_page'] = 'sql.php';
|
||||
$sql_query = '';
|
||||
foreach ($_REQUEST['selected_fld'] as $idx => $sval) {
|
||||
@ -103,11 +105,18 @@ if (! empty($submit_mult)) {
|
||||
}
|
||||
$sql_query .= ' FROM ' . PMA_Util::backquote($db)
|
||||
. '.' . PMA_Util::backquote($table);
|
||||
include 'sql.php';
|
||||
exit;
|
||||
|
||||
// Parse and analyze the query
|
||||
require_once 'libraries/parse_analyze.inc.php';
|
||||
|
||||
PMA_executeQueryAndSendQueryResponse(
|
||||
$analyzed_sql_results, false, $db, $table, null, null, null, false, null,
|
||||
null, null, null, $goto, $pmaThemeImage, null, null, null, $sql_query,
|
||||
null, null
|
||||
);
|
||||
} else {
|
||||
// handle multiple field commands
|
||||
// handle confirmation of deleting multiple fields/columns
|
||||
// handle confirmation of deleting multiple columns
|
||||
$action = 'tbl_structure.php';
|
||||
include 'libraries/mult_submits.inc.php';
|
||||
/**
|
||||
|
||||
@ -341,5 +341,93 @@ class PMA_TableSearch_Test extends PHPUnit_Framework_TestCase
|
||||
$html
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for buildSqlQuery
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testBuildSqlQueryw()
|
||||
{
|
||||
$_POST['distinct'] = true;
|
||||
$_POST['zoom_submit'] = true;
|
||||
$_POST['table'] = "PMA";
|
||||
$_POST['orderByColumn'] = "name";
|
||||
$_POST['order'] = "asc";
|
||||
$_POST['customWhereClause'] = "name='pma'";
|
||||
|
||||
$tableSearch = new PMA_TableSearch("PMA", "PMA_BookMark", "zoom");
|
||||
|
||||
$sql = $tableSearch->buildSqlQuery();
|
||||
$result = "SELECT DISTINCT * FROM `PMA` WHERE name='pma' ORDER BY `name` asc";
|
||||
$this->assertEquals(
|
||||
$result,
|
||||
$sql
|
||||
);
|
||||
|
||||
unset($_POST['customWhereClause']);
|
||||
$sql = $tableSearch->buildSqlQuery();
|
||||
$result = "SELECT DISTINCT * FROM `PMA` ORDER BY `name` asc";
|
||||
$this->assertEquals(
|
||||
$result,
|
||||
$sql
|
||||
);
|
||||
|
||||
$_POST['criteriaValues'] = array(
|
||||
'value1',
|
||||
'value2',
|
||||
'value3',
|
||||
'value4',
|
||||
'value5',
|
||||
'value6',
|
||||
'value7,value8'
|
||||
);
|
||||
$_POST['criteriaColumnNames'] = array(
|
||||
'name',
|
||||
'id',
|
||||
'index',
|
||||
'index2',
|
||||
'index3',
|
||||
'index4',
|
||||
'index5',
|
||||
);
|
||||
$_POST['criteriaColumnTypes'] = array(
|
||||
'varchar',
|
||||
'int',
|
||||
'enum',
|
||||
'type1',
|
||||
'type2',
|
||||
'type3',
|
||||
'type4'
|
||||
);
|
||||
$_POST['criteriaColumnCollations'] = array(
|
||||
"char1",
|
||||
"char2",
|
||||
"char3",
|
||||
"char4",
|
||||
"char5",
|
||||
"char6",
|
||||
"char7",
|
||||
);
|
||||
$_POST['criteriaColumnOperators'] = array(
|
||||
"!=",
|
||||
">",
|
||||
"IS NULL",
|
||||
"LIKE %...%",
|
||||
"REGEXP ^...$",
|
||||
"IN (...)",
|
||||
"BETWEEN"
|
||||
);
|
||||
|
||||
$sql = $tableSearch->buildSqlQuery();
|
||||
$result = "SELECT DISTINCT * FROM `PMA` WHERE `name` != 'value1' AND `id` > value2 "
|
||||
. "AND `index` IS NULL AND `index2` LIKE '%value4%' AND `index3` REGEXP ^value5$ "
|
||||
. "AND `index4` IN (value6) AND `index5` BETWEEN value7 "
|
||||
. "AND value8 ORDER BY `name` asc";
|
||||
$this->assertEquals(
|
||||
$result,
|
||||
$sql
|
||||
);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
@ -10,6 +10,7 @@
|
||||
* Include to test.
|
||||
*/
|
||||
require_once 'libraries/Table.class.php';
|
||||
require_once 'libraries/sqlparser.lib.php';
|
||||
require_once 'libraries/mysql_charsets.lib.php';
|
||||
require_once 'libraries/Util.class.php';
|
||||
require_once 'libraries/database_interface.inc.php';
|
||||
@ -42,10 +43,15 @@ class PMA_Table_Test extends PHPUnit_Framework_TestCase
|
||||
$GLOBALS['cfg']['MySQLManualType'] = 'viewable';
|
||||
$GLOBALS['cfg']['MySQLManualBase'] = 'http://dev.mysql.com/doc/refman';
|
||||
$GLOBALS['cfg']['ActionLinksMode'] = 'both';
|
||||
$GLOBALS['cfg']['MaxExactCount'] = 100;
|
||||
$GLOBALS['cfg']['MaxExactCountViews'] = 100;
|
||||
$_SESSION['PMA_Theme'] = new PMA_Theme();
|
||||
$GLOBALS['pmaThemeImage'] = 'themes/dot.gif';
|
||||
$GLOBALS['is_ajax_request'] = false;
|
||||
$GLOBALS['cfgRelation'] = PMA_getRelationsParam();
|
||||
$GLOBALS['pma'] = new DataBasePMAMock();
|
||||
$GLOBALS['pma']->databases = new DataBaseMock();
|
||||
|
||||
PMA_Table::$cache["PMA"]["PMA_BookMark"] = array(
|
||||
'ENGINE' => true,
|
||||
'Create_time' => true,
|
||||
@ -151,6 +157,9 @@ class PMA_Table_Test extends PHPUnit_Framework_TestCase
|
||||
'column1',
|
||||
'column3',
|
||||
'column5',
|
||||
'ACCESSIBLE',
|
||||
'ADD',
|
||||
'ALL'
|
||||
)
|
||||
),
|
||||
array(
|
||||
@ -163,6 +172,9 @@ class PMA_Table_Test extends PHPUnit_Framework_TestCase
|
||||
'column1',
|
||||
'column3',
|
||||
'column5',
|
||||
'ACCESSIBLE',
|
||||
'ADD',
|
||||
'ALL'
|
||||
)
|
||||
),
|
||||
);
|
||||
@ -191,6 +203,9 @@ class PMA_Table_Test extends PHPUnit_Framework_TestCase
|
||||
|
||||
$dbi->expects($this->any())->method('numRows')
|
||||
->will($this->returnValue(20));
|
||||
|
||||
$dbi->expects($this->any())->method('tryQuery')
|
||||
->will($this->returnValue(10));
|
||||
|
||||
$triggers = array(
|
||||
array("name" => "name1", "create"=>"crate1"),
|
||||
@ -611,8 +626,6 @@ class PMA_Table_Test extends PHPUnit_Framework_TestCase
|
||||
|
||||
$table_new = 'PMA_BookMark_new';
|
||||
$db_new = 'PMA_new';
|
||||
$GLOBALS['pma'] = new DataBasePMAMock();
|
||||
$GLOBALS['pma']->databases = new DataBaseMock();
|
||||
$result = $table->rename($table_new, $db_new);
|
||||
$this->assertEquals(
|
||||
true,
|
||||
@ -648,8 +661,7 @@ class PMA_Table_Test extends PHPUnit_Framework_TestCase
|
||||
$return
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Test for getIndexedColumns
|
||||
*
|
||||
@ -665,7 +677,10 @@ class PMA_Table_Test extends PHPUnit_Framework_TestCase
|
||||
$expect = array(
|
||||
'`PMA`.`PMA_BookMark`.`column1`',
|
||||
'`PMA`.`PMA_BookMark`.`column3`',
|
||||
'`PMA`.`PMA_BookMark`.`column5`'
|
||||
'`PMA`.`PMA_BookMark`.`column5`',
|
||||
'`PMA`.`PMA_BookMark`.`ACCESSIBLE`',
|
||||
'`PMA`.`PMA_BookMark`.`ADD`',
|
||||
'`PMA`.`PMA_BookMark`.`ALL`',
|
||||
);
|
||||
$this->assertEquals(
|
||||
$expect,
|
||||
@ -689,13 +704,108 @@ class PMA_Table_Test extends PHPUnit_Framework_TestCase
|
||||
$expect = array(
|
||||
'`PMA`.`PMA_BookMark`.`column1`',
|
||||
'`PMA`.`PMA_BookMark`.`column3`',
|
||||
'`PMA`.`PMA_BookMark`.`column5`'
|
||||
'`PMA`.`PMA_BookMark`.`column5`',
|
||||
'`PMA`.`PMA_BookMark`.`ACCESSIBLE`',
|
||||
'`PMA`.`PMA_BookMark`.`ADD`',
|
||||
'`PMA`.`PMA_BookMark`.`ALL`',
|
||||
);
|
||||
$this->assertEquals(
|
||||
$expect,
|
||||
$return
|
||||
);
|
||||
|
||||
$return = $table->getReservedColumnNames();
|
||||
$expect = array(
|
||||
'ACCESSIBLE',
|
||||
'ADD',
|
||||
'ALL',
|
||||
);
|
||||
$this->assertEquals(
|
||||
$expect,
|
||||
$return
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for countRecords
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testCountRecords()
|
||||
{
|
||||
$table = 'PMA_BookMark';
|
||||
$db = 'PMA';
|
||||
PMA_Table::$cache[$db][$table] = array('Comment' => "Comment222");
|
||||
|
||||
$return = PMA_Table::countRecords($db, $table, false, true);
|
||||
$expect = 20;
|
||||
$this->assertEquals(
|
||||
$expect,
|
||||
$return
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for moveCopy
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testMoveCopy()
|
||||
{
|
||||
$source_table = 'PMA_BookMark';
|
||||
$source_db = 'PMA';
|
||||
$target_table = 'PMA_BookMark_new';
|
||||
$target_db = 'PMA_new';
|
||||
$what = "dataonly";
|
||||
$move = true;
|
||||
$mode = "one_table";
|
||||
|
||||
$_REQUEST['drop_if_exists'] = true;
|
||||
|
||||
$return = PMA_Table::moveCopy(
|
||||
$source_db, $source_table, $target_db,
|
||||
$target_table, $what, $move, $mode
|
||||
);
|
||||
|
||||
//successully
|
||||
$expect = true;
|
||||
$this->assertEquals(
|
||||
$expect,
|
||||
$return
|
||||
);
|
||||
$sql_query = "INSERT INTO `PMA_new`.`PMA_BookMark_new` SELECT * FROM `PMA`.`PMA_BookMark`";
|
||||
$this->assertContains(
|
||||
$sql_query,
|
||||
$GLOBALS['sql_query']
|
||||
);
|
||||
$sql_query = "DROP VIEW `PMA`.`PMA_BookMark`";
|
||||
$this->assertContains(
|
||||
$sql_query,
|
||||
$GLOBALS['sql_query']
|
||||
);
|
||||
|
||||
$return = PMA_Table::moveCopy(
|
||||
$source_db, $source_table, $target_db,
|
||||
$target_table, $what, false, $mode
|
||||
);
|
||||
|
||||
//successully
|
||||
$expect = true;
|
||||
$this->assertEquals(
|
||||
$expect,
|
||||
$return
|
||||
);
|
||||
$sql_query = "INSERT INTO `PMA_new`.`PMA_BookMark_new` SELECT * FROM `PMA`.`PMA_BookMark`;";
|
||||
$this->assertContains(
|
||||
$sql_query,
|
||||
$GLOBALS['sql_query']
|
||||
);
|
||||
$sql_query = "DROP VIEW `PMA`.`PMA_BookMark`";
|
||||
$this->assertNotContains(
|
||||
$sql_query,
|
||||
$GLOBALS['sql_query']
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
67
test/libraries/PMA_SQL_parse_analyze_test.php
Normal file
67
test/libraries/PMA_SQL_parse_analyze_test.php
Normal file
@ -0,0 +1,67 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* tests for correctness of SQL parser analyze data
|
||||
*
|
||||
* @package PhpMyAdmin-test
|
||||
*/
|
||||
|
||||
/*
|
||||
* Include to test.
|
||||
*/
|
||||
require_once 'libraries/Util.class.php';
|
||||
require_once 'libraries/sqlparser.lib.php';
|
||||
|
||||
class PMA_SQLParserAnalyze_Test extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testPMA_SQP_getParserAnalyzeMa()
|
||||
{
|
||||
//select statement
|
||||
$sql_query = "select * from PMA.PMAParse";
|
||||
$db = "PMA";
|
||||
$data = PMA_SQP_getParserAnalyzeMap($sql_query, $db);
|
||||
|
||||
$this->assertEquals(
|
||||
array(
|
||||
'type' => 'alpha_reservedWord',
|
||||
'data' => 'select',
|
||||
'pos' => 6,
|
||||
'forbidden' => true,
|
||||
),
|
||||
$data['parsed_sql'][0]
|
||||
);
|
||||
$this->assertEquals(
|
||||
'select * from PMA.PMAParse',
|
||||
$data['analyzed_sql'][0]['unsorted_query']
|
||||
);
|
||||
|
||||
$this->assertTrue($data['is_select']);
|
||||
$this->assertFalse($data['is_group']);
|
||||
$this->assertFalse($data['is_show']);
|
||||
|
||||
//update statement
|
||||
$sql_query = "UPDATE `11`.`pma_bookmark` SET `id` = '2' WHERE `pma_bookmark`.`id` = 1;";
|
||||
$db = "PMA";
|
||||
$data = PMA_SQP_getParserAnalyzeMap($sql_query, $db);
|
||||
|
||||
$this->assertEquals(
|
||||
array(
|
||||
'type' => 'alpha_reservedWord',
|
||||
'data' => 'UPDATE',
|
||||
'pos' => 6,
|
||||
'forbidden' => true,
|
||||
),
|
||||
$data['parsed_sql'][0]
|
||||
);
|
||||
$this->assertEquals(
|
||||
$sql_query,
|
||||
$data['analyzed_sql'][0]['unsorted_query']
|
||||
);
|
||||
$this->assertFalse($data['is_group']);
|
||||
$this->assertFalse($data['is_show']);
|
||||
$this->assertTrue($data['is_affected']);
|
||||
$this->assertFalse($data['is_select']);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
239
test/libraries/PMA_display_export_test.php
Normal file
239
test/libraries/PMA_display_export_test.php
Normal file
@ -0,0 +1,239 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* tests for display_export.lib.php
|
||||
*
|
||||
* @package PhpMyAdmin-test
|
||||
*/
|
||||
|
||||
/*
|
||||
* Include to test.
|
||||
*/
|
||||
require_once 'libraries/Util.class.php';
|
||||
require_once 'libraries/Table.class.php';
|
||||
require_once 'libraries/Advisor.class.php';
|
||||
require_once 'libraries/php-gettext/gettext.inc';
|
||||
require_once 'libraries/url_generating.lib.php';
|
||||
require_once 'libraries/ServerStatusData.class.php';
|
||||
require_once 'libraries/display_export.lib.php';
|
||||
require_once 'libraries/Theme.class.php';
|
||||
require_once 'libraries/database_interface.inc.php';
|
||||
require_once 'libraries/charset_conversion.lib.php';
|
||||
require_once 'libraries/Message.class.php';
|
||||
require_once 'libraries/plugin_interface.lib.php';
|
||||
require_once 'libraries/sanitizing.lib.php';
|
||||
require_once 'libraries/sqlparser.lib.php';
|
||||
require_once 'libraries/js_escape.lib.php';
|
||||
require_once 'libraries/relation.lib.php';
|
||||
|
||||
/**
|
||||
* class PMA_DisplayExport_Test
|
||||
*
|
||||
* this class is for testing display_export.lib.php functions
|
||||
*
|
||||
* @package PhpMyAdmin-test
|
||||
*/
|
||||
class PMA_DisplayExport_Test extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* Test for setUp
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
//$GLOBALS
|
||||
$GLOBALS['cfg']['MaxRows'] = 10;
|
||||
$GLOBALS['cfg']['ServerDefault'] = "PMA_server";
|
||||
$GLOBALS['cfg']['TableNavigationLinksMode'] = 'icons';
|
||||
$GLOBALS['cfg']['LimitChars'] = 100;
|
||||
$GLOBALS['cfg']['ActionLinksMode'] = 'icons';
|
||||
$GLOBALS['cfg']['Server']['host'] = "localhost";
|
||||
$GLOBALS['cfg']['MySQLManualType'] = 'viewable';
|
||||
$GLOBALS['cfg']['Server']['user'] = "pma_user";
|
||||
$GLOBALS['cfg']['ShowHint'] = true;
|
||||
$GLOBALS['cfg']['ActionLinksMode'] = 'icons';
|
||||
$GLOBALS['cfg']['ZipDump'] = true;
|
||||
$GLOBALS['cfg']['GZipDump'] = false;
|
||||
$GLOBALS['cfg']['BZipDump'] = false;
|
||||
$GLOBALS['cfg']['Export']['asfile'] = true;
|
||||
$GLOBALS['cfg']['Export']['file_template_server'] = "file_template_server";
|
||||
$GLOBALS['PMA_PHP_SELF'] = PMA_getenv('PHP_SELF');
|
||||
$GLOBALS['PMA_recoding_engine'] = "InnerDB";
|
||||
$GLOBALS['server'] = 0;
|
||||
|
||||
$GLOBALS['table'] = "table";
|
||||
$GLOBALS['pmaThemeImage'] = 'image';
|
||||
$GLOBALS['db'] = "PMA";
|
||||
|
||||
//$_SESSION
|
||||
$_SESSION['PMA_Theme'] = PMA_Theme::load('./themes/pmahomme');
|
||||
$_SESSION['PMA_Theme'] = new PMA_Theme();
|
||||
$_SESSION['relation'][$GLOBALS['server']] = "";
|
||||
|
||||
$pmaconfig = $this->getMockBuilder('PMA_Config')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$pmaconfig->expects($this->any())
|
||||
->method('getUserValue')
|
||||
->will($this->returnValue('user value for test'));
|
||||
|
||||
$GLOBALS['PMA_Config'] = $pmaconfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for PMA_getHtmlForHiddenInput
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testPMAGetHtmlForHiddenInput()
|
||||
{
|
||||
$export_type = "server";
|
||||
$db = "PMA";
|
||||
$table = "PMA_test";
|
||||
$single_table_str = "PMA_single_str";
|
||||
$sql_query_str = "sql_query_str";
|
||||
|
||||
//Call the test function
|
||||
$html = PMA_getHtmlForHiddenInput(
|
||||
$export_type,
|
||||
$db,
|
||||
$table,
|
||||
$single_table_str,
|
||||
$sql_query_str
|
||||
);
|
||||
|
||||
//validate 1: PMA_generate_common_hidden_inputs
|
||||
//$single_table
|
||||
$this->assertContains(
|
||||
'<input type="hidden" name="single_table" value="TRUE"',
|
||||
$html
|
||||
);
|
||||
//$export_type
|
||||
$this->assertContains(
|
||||
'<input type="hidden" name="export_type" value="server"',
|
||||
$html
|
||||
);
|
||||
$this->assertContains(
|
||||
'<input type="hidden" name="export_method" value="quick"',
|
||||
$html
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for PMA_getHtmlForExportOptions
|
||||
*
|
||||
* @return vgetUserValue
|
||||
*/
|
||||
public function testPMAGetHtmlForExportOptions()
|
||||
{
|
||||
global $cfg;
|
||||
$cfg['Export']['method'] = "XML";
|
||||
$cfg['SaveDir'] = "/tmp";
|
||||
|
||||
$export_type = "server";
|
||||
$db = "PMA";
|
||||
$table = "PMA_test";
|
||||
$multi_values_str = "multi_values_str";
|
||||
$num_tables_str = "10";
|
||||
$export_list = null;
|
||||
$unlim_num_rows_str = "unlim_num_rows_str";
|
||||
$single_table = "single_table";
|
||||
PMA_Table::$cache[$db][$table]['ENGINE'] = "MERGE";
|
||||
|
||||
/* Scan for plugins */
|
||||
$export_list = PMA_getPlugins(
|
||||
"export",
|
||||
'libraries/plugins/export/',
|
||||
array(
|
||||
'export_type' => $export_type,
|
||||
'single_table' => isset($single_table)
|
||||
)
|
||||
);
|
||||
|
||||
//Call the test function
|
||||
$html = PMA_getHtmlForExportOptions(
|
||||
$export_type,
|
||||
$db,
|
||||
$table,
|
||||
$multi_values_str,
|
||||
$num_tables_str,
|
||||
$export_list,
|
||||
$unlim_num_rows_str
|
||||
);
|
||||
|
||||
//validate 1: PMA_getHtmlForExportOptionHeader
|
||||
$this->assertContains(
|
||||
'<div class="exportoptions" id="header">',
|
||||
$html
|
||||
);
|
||||
$this->assertContains(
|
||||
__('Exporting databases from the current server'),
|
||||
$html
|
||||
);
|
||||
|
||||
//validate 2: PMA_getHtmlForExportOptionsMethod
|
||||
$this->assertContains(
|
||||
$cfg['Export']['method'],
|
||||
$html
|
||||
);
|
||||
$this->assertContains(
|
||||
'<div class="exportoptions" id="quick_or_custom">',
|
||||
$html
|
||||
);
|
||||
$this->assertContains(
|
||||
__('Export Method:'),
|
||||
$html
|
||||
);
|
||||
$this->assertContains(
|
||||
__('Custom - display all possible options'),
|
||||
$html
|
||||
);
|
||||
|
||||
//validate 3: PMA_getHtmlForExportOptionsSelection
|
||||
$this->assertContains(
|
||||
'<div class="exportoptions" id="databases_and_tables">',
|
||||
$html
|
||||
);
|
||||
$this->assertContains(
|
||||
'<h3>' . __('Database(s):') . '</h3>',
|
||||
$html
|
||||
);
|
||||
$this->assertContains(
|
||||
$multi_values_str,
|
||||
$html
|
||||
);
|
||||
|
||||
//validate 4: PMA_getHtmlForExportOptionsQuickExport
|
||||
$this->assertContains(
|
||||
'<input type="checkbox" name="onserver" value="saveit" ',
|
||||
$html
|
||||
);
|
||||
$dir = htmlspecialchars(PMA_Util::userDir($cfg['SaveDir']));
|
||||
$this->assertContains(
|
||||
'Save on server in the directory <b>' . $dir . '</b>',
|
||||
$html
|
||||
);
|
||||
|
||||
//validate 5: PMA_getHtmlForExportOptionsOutput
|
||||
$this->assertContains(
|
||||
'<div class="exportoptions" id="output">',
|
||||
$html
|
||||
);
|
||||
$this->assertContains(
|
||||
'user value for test',
|
||||
$html
|
||||
);
|
||||
|
||||
//validate 6: PMA_getHtmlForExportOptionsFormat
|
||||
$this->assertContains(
|
||||
'<div class="exportoptions" id="format">',
|
||||
$html
|
||||
);
|
||||
$this->assertContains(
|
||||
'<h3>' . __('Format:') . '</h3>',
|
||||
$html
|
||||
);
|
||||
}
|
||||
}
|
||||
385
test/libraries/PMA_relation_cleanup_test.php
Normal file
385
test/libraries/PMA_relation_cleanup_test.php
Normal file
@ -0,0 +1,385 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* tests for relation_cleanup.lib.php
|
||||
*
|
||||
* @package PhpMyAdmin-test
|
||||
*/
|
||||
|
||||
/*
|
||||
* Include to test.
|
||||
*/
|
||||
require_once 'libraries/Util.class.php';
|
||||
require_once 'libraries/Theme.class.php';
|
||||
require_once 'libraries/php-gettext/gettext.inc';
|
||||
require_once 'libraries/database_interface.inc.php';
|
||||
require_once 'libraries/Tracker.class.php';
|
||||
require_once 'libraries/relation.lib.php';
|
||||
require_once 'libraries/relation_cleanup.lib.php';
|
||||
|
||||
|
||||
class PMA_Relation_Cleanup_Test extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function setUp()
|
||||
{
|
||||
$_SESSION['relation'] = array();
|
||||
$GLOBALS['server'] = 1;
|
||||
$GLOBALS['cfg']['Server']['user'] = "user";
|
||||
$GLOBALS['cfg']['Server']['pmadb'] = "pmadb";
|
||||
$GLOBALS['cfg']['Server']['bookmarktable'] = 'bookmark';
|
||||
$GLOBALS['cfg']['Server']['relation'] = 'relation';
|
||||
$GLOBALS['cfg']['Server']['table_info'] = 'table_info';
|
||||
$GLOBALS['cfg']['Server']['table_coords'] = 'table_coords';
|
||||
$GLOBALS['cfg']['Server']['designer_coords'] = 'designer_coords';
|
||||
$GLOBALS['cfg']['Server']['column_info'] = 'column_info';
|
||||
$GLOBALS['cfg']['Server']['pdf_pages'] = 'pdf_pages';
|
||||
$GLOBALS['cfg']['Server']['history'] = 'history';
|
||||
$GLOBALS['cfg']['Server']['recent'] = 'recent';
|
||||
$GLOBALS['cfg']['Server']['table_uiprefs'] = 'table_uiprefs';
|
||||
$GLOBALS['cfg']['Server']['tracking'] = 'tracking';
|
||||
$GLOBALS['cfg']['Server']['userconfig'] = 'userconfig';
|
||||
$GLOBALS['cfg']['Server']['users'] = 'users';
|
||||
$GLOBALS['cfg']['Server']['usergroups'] = 'usergroups';
|
||||
|
||||
$this->redefineRelation();
|
||||
}
|
||||
|
||||
public function redefineRelation()
|
||||
{
|
||||
$GLOBALS['dbi'] = new DBI_PMA_Relation_Cleanup();
|
||||
unset($_SESSION['relation'][$GLOBALS['server']]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for PMA_relationsCleanupColumn
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testPMA_relationsCleanupColumn()
|
||||
{
|
||||
$db = "PMA";
|
||||
$table = "PMA_bookmark";
|
||||
$column = "name";
|
||||
$this->redefineRelation();
|
||||
|
||||
//the $cfgRelation value before cleanup column
|
||||
$cfgRelation = PMA_checkRelationsParam();
|
||||
$this->assertEquals(
|
||||
true,
|
||||
$cfgRelation['commwork']
|
||||
);
|
||||
$this->assertEquals(
|
||||
true,
|
||||
$cfgRelation['displaywork']
|
||||
);
|
||||
$this->assertEquals(
|
||||
true,
|
||||
$cfgRelation['relwork']
|
||||
);
|
||||
$this->assertEquals(
|
||||
'column_info',
|
||||
$cfgRelation['column_info']
|
||||
);
|
||||
$this->assertEquals(
|
||||
'table_info',
|
||||
$cfgRelation['table_info']
|
||||
);
|
||||
$this->assertEquals(
|
||||
'relation',
|
||||
$cfgRelation['relation']
|
||||
);
|
||||
|
||||
//cleanup
|
||||
PMA_relationsCleanupColumn($db, $table, $column);
|
||||
|
||||
//the $cfgRelation value after cleanup column
|
||||
$cfgRelation = PMA_checkRelationsParam();
|
||||
|
||||
$is_defined_column_info
|
||||
= isset($cfgRelation['column_info'])? $cfgRelation['column_info'] : null;
|
||||
$is_defined_table_info
|
||||
= isset($cfgRelation['table_info'])? $cfgRelation['table_info'] : null;
|
||||
$is_defined_relation
|
||||
= isset($cfgRelation['relation'])? $cfgRelation['relation'] : null;
|
||||
|
||||
$this->assertEquals(
|
||||
null,
|
||||
$is_defined_column_info
|
||||
);
|
||||
$this->assertEquals(
|
||||
null,
|
||||
$is_defined_table_info
|
||||
);
|
||||
$this->assertEquals(
|
||||
null,
|
||||
$is_defined_relation
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for PMA_relationsCleanupTable
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testPMA_relationsCleanupTable()
|
||||
{
|
||||
$db = "PMA";
|
||||
$table = "PMA_bookmark";
|
||||
$this->redefineRelation();
|
||||
|
||||
//the $cfgRelation value before cleanup column
|
||||
$cfgRelation = PMA_checkRelationsParam();
|
||||
$this->assertEquals(
|
||||
'column_info',
|
||||
$cfgRelation['column_info']
|
||||
);
|
||||
$this->assertEquals(
|
||||
'table_info',
|
||||
$cfgRelation['table_info']
|
||||
);
|
||||
$this->assertEquals(
|
||||
'table_coords',
|
||||
$cfgRelation['table_coords']
|
||||
);
|
||||
$this->assertEquals(
|
||||
'designer_coords',
|
||||
$cfgRelation['designer_coords']
|
||||
);
|
||||
$this->assertEquals(
|
||||
'relation',
|
||||
$cfgRelation['relation']
|
||||
);
|
||||
|
||||
//PMA_relationsCleanupTable
|
||||
PMA_relationsCleanupTable($db, $table);
|
||||
|
||||
//the $cfgRelation value after cleanup column
|
||||
$cfgRelation = PMA_checkRelationsParam();
|
||||
|
||||
$is_defined_column_info
|
||||
= isset($cfgRelation['column_info'])? $cfgRelation['column_info'] : null;
|
||||
$is_defined_table_info
|
||||
= isset($cfgRelation['table_info'])? $cfgRelation['table_info'] : null;
|
||||
$is_defined_relation
|
||||
= isset($cfgRelation['relation'])? $cfgRelation['relation'] : null;
|
||||
$is_defined_table_coords
|
||||
= isset($cfgRelation['table_coords'])
|
||||
? $cfgRelation['table_coords']
|
||||
: null;
|
||||
$is_defined_designer_coords
|
||||
= isset($cfgRelation['designer_coords'])
|
||||
? $cfgRelation['designer_coords']
|
||||
: null;
|
||||
|
||||
$this->assertEquals(
|
||||
null,
|
||||
$is_defined_column_info
|
||||
);
|
||||
$this->assertEquals(
|
||||
null,
|
||||
$is_defined_table_info
|
||||
);
|
||||
$this->assertEquals(
|
||||
null,
|
||||
$is_defined_relation
|
||||
);
|
||||
$this->assertEquals(
|
||||
null,
|
||||
$is_defined_table_coords
|
||||
);
|
||||
$this->assertEquals(
|
||||
null,
|
||||
$is_defined_designer_coords
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for PMA_relationsCleanupDatabase
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testPMA_relationsCleanupDatabase()
|
||||
{
|
||||
$db = "PMA";
|
||||
$this->redefineRelation();
|
||||
|
||||
//the $cfgRelation value before cleanup column
|
||||
$cfgRelation = PMA_checkRelationsParam();
|
||||
$this->assertEquals(
|
||||
'column_info',
|
||||
$cfgRelation['column_info']
|
||||
);
|
||||
$this->assertEquals(
|
||||
'bookmark',
|
||||
$cfgRelation['bookmark']
|
||||
);
|
||||
$this->assertEquals(
|
||||
'table_info',
|
||||
$cfgRelation['table_info']
|
||||
);
|
||||
$this->assertEquals(
|
||||
'pdf_pages',
|
||||
$cfgRelation['pdf_pages']
|
||||
);
|
||||
$this->assertEquals(
|
||||
'table_coords',
|
||||
$cfgRelation['table_coords']
|
||||
);
|
||||
$this->assertEquals(
|
||||
'designer_coords',
|
||||
$cfgRelation['designer_coords']
|
||||
);
|
||||
$this->assertEquals(
|
||||
'relation',
|
||||
$cfgRelation['relation']
|
||||
);
|
||||
|
||||
//cleanup
|
||||
PMA_relationsCleanupDatabase($db);
|
||||
|
||||
//the value after cleanup column
|
||||
$cfgRelation = PMA_checkRelationsParam();
|
||||
|
||||
$is_defined_column_info
|
||||
= isset($cfgRelation['column_info'])? $cfgRelation['column_info'] : null;
|
||||
$is_defined_table_info
|
||||
= isset($cfgRelation['table_info'])? $cfgRelation['table_info'] : null;
|
||||
$is_defined_relation
|
||||
= isset($cfgRelation['relation'])? $cfgRelation['relation'] : null;
|
||||
$is_defined_table_coords
|
||||
= isset($cfgRelation['table_coords'])
|
||||
? $cfgRelation['table_coords']
|
||||
: null;
|
||||
$is_defined_designer_coords
|
||||
= isset($cfgRelation['designer_coords'])
|
||||
? $cfgRelation['designer_coords']
|
||||
: null;
|
||||
|
||||
$this->assertEquals(
|
||||
null,
|
||||
$is_defined_column_info
|
||||
);
|
||||
$this->assertEquals(
|
||||
null,
|
||||
$is_defined_table_info
|
||||
);
|
||||
$this->assertEquals(
|
||||
null,
|
||||
$is_defined_relation
|
||||
);
|
||||
$this->assertEquals(
|
||||
null,
|
||||
$is_defined_table_coords
|
||||
);
|
||||
$this->assertEquals(
|
||||
null,
|
||||
$is_defined_designer_coords
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//Mock DBI
|
||||
class DBI_PMA_Relation_Cleanup extends PMA_DatabaseInterface
|
||||
{
|
||||
var $index;
|
||||
var $values = array();
|
||||
var $indexs = array();
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->index = 0;
|
||||
$this->values = array(
|
||||
'bookmark',
|
||||
'relation',
|
||||
'table_info',
|
||||
'table_coords',
|
||||
'designer_coords',
|
||||
'column_info',
|
||||
'pdf_pages',
|
||||
'history',
|
||||
'recent',
|
||||
'table_uiprefs',
|
||||
'tracking',
|
||||
'userconfig',
|
||||
'users',
|
||||
'usergroups',
|
||||
);
|
||||
$this->indexs = array(
|
||||
'bookmark' => 0,
|
||||
'relation' => 1,
|
||||
'table_info' => 2,
|
||||
'table_coords' => 3,
|
||||
'designer_coords' => 4,
|
||||
'column_info' => 5,
|
||||
'pdf_pages' => 6,
|
||||
'history' => 7,
|
||||
'recent' => 8,
|
||||
'table_uiprefs' => 9,
|
||||
'tracking' => 10,
|
||||
'userconfig' => 11,
|
||||
'users' => 12,
|
||||
'usergroups' => 13,
|
||||
);
|
||||
}
|
||||
|
||||
function fetchRow($result)
|
||||
{
|
||||
if ($this->index < count($this->values)) {
|
||||
$curr_table[0] = $this->values[$this->index];
|
||||
$this->index++;
|
||||
return $curr_table;
|
||||
}
|
||||
|
||||
$this->index = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
function query($sql, $link = null, $options = 0, $cache_affected_rows = true)
|
||||
{
|
||||
if (stripos($sql, "column_info") !== false) {
|
||||
unset($this->values[$this->indexs['column_info']]);
|
||||
}
|
||||
|
||||
if (stripos($sql, "table_info") !== false) {
|
||||
unset ($this->values[$this->indexs['table_info']]);
|
||||
}
|
||||
|
||||
if (stripos($sql, "table_coords") !== false) {
|
||||
unset($this->values[$this->indexs['table_coords']]);
|
||||
}
|
||||
|
||||
if (stripos($sql, "designer_coords") !== false) {
|
||||
unset($this->values[$this->indexs['designer_coords']]);
|
||||
}
|
||||
|
||||
if (stripos($sql, "relation") !== false) {
|
||||
unset($this->values[$this->indexs['relation']]);
|
||||
}
|
||||
|
||||
if (stripos($sql, "pdf_pages") !== false) {
|
||||
unset($GLOBALS [$this->indexs['pdf_pages']]);
|
||||
}
|
||||
|
||||
if (stripos($sql, "bookmark") !== false) {
|
||||
unset($GLOBALS [$this->indexs['bookmark']]);
|
||||
}
|
||||
}
|
||||
|
||||
public function tryQuery(
|
||||
$query, $link = null, $options = 0, $cache_affected_rows = true
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function selectDb($dbname, $link = null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function freeResult($result)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -25,9 +25,11 @@ class PMA_Relation_Test extends PHPUnit_Framework_TestCase
|
||||
$GLOBALS['cfg']['Server']['pmadb'] = 'phpmyadmin';
|
||||
$_SESSION['relation'][$GLOBALS['server']] = "PMA_relation";
|
||||
$_SESSION['PMA_Theme'] = new PMA_Theme();
|
||||
$_SESSION['relation'] = array();
|
||||
|
||||
$GLOBALS['pmaThemePath'] = $_SESSION['PMA_Theme']->getPath();
|
||||
$GLOBALS['pmaThemeImage'] = 'theme/';
|
||||
$GLOBALS['cfg']['ServerDefault'] = 0;
|
||||
|
||||
include_once 'libraries/relation.lib.php';
|
||||
}
|
||||
@ -71,9 +73,6 @@ class PMA_Relation_Test extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testPMA_getRelationsParam()
|
||||
{
|
||||
$GLOBALS['cfg']['ServerDefault'] = 0;
|
||||
$_SESSION['relation'] = array();
|
||||
|
||||
$relationsPara = PMA_getRelationsParam();
|
||||
$this->assertEquals(
|
||||
false,
|
||||
@ -137,5 +136,84 @@ class PMA_Relation_Test extends PHPUnit_Framework_TestCase
|
||||
$retval
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for PMA_getDisplayField
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testPMA_getDisplayField()
|
||||
{
|
||||
|
||||
$db = 'information_schema';
|
||||
$table = 'CHARACTER_SETS';
|
||||
$this->assertEquals(
|
||||
'DESCRIPTION',
|
||||
PMA_getDisplayField($db, $table)
|
||||
);
|
||||
|
||||
$db = 'information_schema';
|
||||
$table = 'TABLES';
|
||||
$this->assertEquals(
|
||||
'TABLE_COMMENT',
|
||||
PMA_getDisplayField($db, $table)
|
||||
);
|
||||
|
||||
$db = 'information_schema';
|
||||
$table = 'PMA';
|
||||
$this->assertEquals(
|
||||
false,
|
||||
PMA_getDisplayField($db, $table)
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for PMA_getComments
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testPMA_getComments()
|
||||
{
|
||||
$GLOBALS['cfg']['ServerDefault'] = 0;
|
||||
$_SESSION['relation'] = array();
|
||||
|
||||
$dbi = $this->getMockBuilder('PMA_DatabaseInterface')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$getColumnsResult = array(
|
||||
array(
|
||||
'Field' => 'field1',
|
||||
'Type' => 'int(11)',
|
||||
'Comment' => 'Comment1'
|
||||
),
|
||||
array(
|
||||
'Field' => 'field2',
|
||||
'Type' => 'text',
|
||||
'Comment' => 'Comment1'
|
||||
)
|
||||
);
|
||||
$dbi->expects($this->any())->method('getColumns')
|
||||
->will($this->returnValue($getColumnsResult));
|
||||
|
||||
$GLOBALS['dbi'] = $dbi;
|
||||
|
||||
$db = 'information_schema';
|
||||
$this->assertEquals(
|
||||
array(''),
|
||||
PMA_getComments($db)
|
||||
);
|
||||
|
||||
$db = 'information_schema';
|
||||
$table = 'TABLES';
|
||||
$this->assertEquals(
|
||||
array(
|
||||
'field1' => 'Comment1',
|
||||
'field2' => 'Comment1'
|
||||
),
|
||||
PMA_getComments($db, $table)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -2811,3 +2811,12 @@ body .ui-widget {
|
||||
color: #235A81;
|
||||
}
|
||||
|
||||
/* over-riding jqplot-yaxis class */
|
||||
.jqplot-yaxis {
|
||||
left:0px !important;
|
||||
min-width:25px;
|
||||
width:auto;
|
||||
}
|
||||
.jqplot-axis {
|
||||
overflow:hidden;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user