Merge branch 'QA_4_5'

This commit is contained in:
Madhura Jayaratne 2015-08-31 22:56:54 +10:00
commit 26087dafc7
4 changed files with 86 additions and 20 deletions

View File

@ -167,11 +167,14 @@ function PMA_getHtmlForLinkTemplates()
* Prints Html for Server Variables
*
* @param Array $variable_doc_links documentation links
* @param Array $serverVars global variables
* @param Array $serverVarsSession session variables
*
* @return string
*/
function PMA_getHtmlForServerVariables($variable_doc_links)
{
function PMA_getHtmlForServerVariables(
$variable_doc_links, $serverVars, $serverVarsSession
) {
$value = ! empty($_REQUEST['filter'])
? htmlspecialchars($_REQUEST['filter'])
: '';
@ -194,7 +197,9 @@ function PMA_getHtmlForServerVariables($variable_doc_links)
. '</tr>'
. '</thead>';
$output .= PMA_getHtmlForServerVariablesItems($variable_doc_links);
$output .= PMA_getHtmlForServerVariablesItems(
$variable_doc_links, $serverVars, $serverVarsSession
);
$output .= '</table>';
@ -206,18 +211,14 @@ function PMA_getHtmlForServerVariables($variable_doc_links)
* Prints Html for Server Variables Items
*
* @param Array $variable_doc_links documentation links
* @param Array $serverVars global variables
* @param Array $serverVarsSession session variables
*
* @return string
*/
function PMA_getHtmlForServerVariablesItems($variable_doc_links)
{
/**
* Sends the queries and buffers the results
*/
$serverVarsSession
= $GLOBALS['dbi']->fetchResult('SHOW SESSION VARIABLES;', 0, 1);
$serverVars = $GLOBALS['dbi']->fetchResult('SHOW GLOBAL VARIABLES;', 0, 1);
function PMA_getHtmlForServerVariablesItems(
$variable_doc_links, $serverVars, $serverVarsSession
) {
// list of static system variables
$static_variables = PMA_getStaticSystemVariables();

View File

@ -46,13 +46,42 @@ $doc_link = PMA_Util::showMySQLDocu('server_system_variables');
$response->addHtml(PMA_getHtmlForSubPageHeader('variables', $doc_link));
/**
* Link templates
* Sends the queries and buffers the results
*/
$response->addHtml(PMA_getHtmlForLinkTemplates());
$serverVarsResult = $GLOBALS['dbi']->tryQuery('SHOW SESSION VARIABLES;');
/**
* Displays the page
*/
$response->addHtml(PMA_getHtmlForServerVariables($variable_doc_links));
if ($serverVarsResult !== false) {
$serverVarsSession = array();
while ($arr = $GLOBALS['dbi']->fetchRow($serverVarsResult)) {
$serverVarsSession[$arr[0]] = $arr[1];
}
$GLOBALS['dbi']->freeResult($serverVarsResult);
$serverVars = $GLOBALS['dbi']->fetchResult('SHOW GLOBAL VARIABLES;', 0, 1);
/**
* Link templates
*/
$response->addHtml(PMA_getHtmlForLinkTemplates());
/**
* Displays the page
*/
$response->addHtml(
PMA_getHtmlForServerVariables(
$variable_doc_links, $serverVars, $serverVarsSession
)
);
} else {
/**
* Display the error message
*/
$response->addHTML(
PMA_Message::error(
__('Not enough privilege to view server variables and settings.')
)->getDisplay()
);
}
exit;

View File

@ -107,6 +107,32 @@ class PMA_ServerStatus_Test extends PHPUnit_Framework_TestCase
),
);
$dbi->expects($this->at(0))
->method('tryQuery')
->with('SHOW GLOBAL STATUS')
->will($this->returnValue(true));
$dbi->expects($this->at(1))
->method('fetchRow')
->will($this->returnValue(array("Aborted_clients", "0")));
$dbi->expects($this->at(2))
->method('fetchRow')
->will($this->returnValue(array("Aborted_connects", "0")));
$dbi->expects($this->at(3))
->method('fetchRow')
->will($this->returnValue(array("Com_delete_multi", "0")));
$dbi->expects($this->at(4))
->method('fetchRow')
->will($this->returnValue(array("Com_create_function", "0")));
$dbi->expects($this->at(5))
->method('fetchRow')
->will($this->returnValue(array("Com_empty_query", "0")));
$dbi->expects($this->at(6))
->method('fetchRow')
->will($this->returnValue(false));
$dbi->expects($this->at(7))->method('freeResult');
$dbi->expects($this->any())->method('fetchResult')
->will($this->returnValueMap($fetchResult));

View File

@ -175,7 +175,12 @@ class PMA_ServerVariables_Test extends PHPUnit_Framework_TestCase
$_REQUEST['filter'] = "auto-commit";
$variable_doc_links = PMA_getArrayForDocumentLinks();
$html = PMA_getHtmlForServerVariables($variable_doc_links);
$serverVarsSession
= $GLOBALS['dbi']->fetchResult('SHOW SESSION VARIABLES;', 0, 1);
$serverVars = $GLOBALS['dbi']->fetchResult('SHOW GLOBAL VARIABLES;', 0, 1);
$html = PMA_getHtmlForServerVariables(
$variable_doc_links, $serverVars, $serverVarsSession
);
//validate 1: Filters
$this->assertContains(
@ -216,7 +221,12 @@ class PMA_ServerVariables_Test extends PHPUnit_Framework_TestCase
//Call the test function
$variable_doc_links = PMA_getArrayForDocumentLinks();
$html = PMA_getHtmlForServerVariablesItems($variable_doc_links);
$serverVarsSession
= $GLOBALS['dbi']->fetchResult('SHOW SESSION VARIABLES;', 0, 1);
$serverVars = $GLOBALS['dbi']->fetchResult('SHOW GLOBAL VARIABLES;', 0, 1);
$html = PMA_getHtmlForServerVariablesItems(
$variable_doc_links, $serverVars, $serverVarsSession
);
//validate 1: variable: auto_increment_increment
$name = "auto_increment_increment";