Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
f27a03bc14
@ -26,7 +26,9 @@ if (isset($_REQUEST['ajax_request']) && $_REQUEST['ajax_request'] == true) {
|
||||
switch($_REQUEST['type']) {
|
||||
// Process and Connections realtime chart
|
||||
case 'proc':
|
||||
$c = PMA_DBI_fetch_result("SHOW GLOBAL STATUS WHERE Variable_name = 'Connections'", 0, 1);
|
||||
$c = PMA_DBI_fetch_result(
|
||||
"SHOW GLOBAL STATUS WHERE Variable_name = 'Connections'", 0, 1
|
||||
);
|
||||
$result = PMA_DBI_query('SHOW PROCESSLIST');
|
||||
$num_procs = PMA_DBI_num_rows($result);
|
||||
|
||||
@ -106,7 +108,8 @@ if (isset($_REQUEST['ajax_request']) && $_REQUEST['ajax_request'] == true) {
|
||||
|
||||
switch ($dataPoint['type']) {
|
||||
/* We only collect the status and server variables here to
|
||||
* read them all in one query, and only afterwards assign them.
|
||||
* read them all in one query,
|
||||
* and only afterwards assign them.
|
||||
* Also do some white list filtering on the names
|
||||
*/
|
||||
case 'servervar':
|
||||
@ -123,7 +126,8 @@ if (isset($_REQUEST['ajax_request']) && $_REQUEST['ajax_request'] == true) {
|
||||
|
||||
case 'proc':
|
||||
$result = PMA_DBI_query('SHOW PROCESSLIST');
|
||||
$ret[$chart_id][$node_id][$point_id]['value'] = PMA_DBI_num_rows($result);
|
||||
$ret[$chart_id][$node_id][$point_id]['value']
|
||||
= PMA_DBI_num_rows($result);
|
||||
break;
|
||||
|
||||
case 'cpu':
|
||||
@ -136,10 +140,13 @@ if (isset($_REQUEST['ajax_request']) && $_REQUEST['ajax_request'] == true) {
|
||||
}
|
||||
|
||||
if (PHP_OS == 'Linux') {
|
||||
$ret[$chart_id][$node_id][$point_id]['idle'] = $cpuload['idle'];
|
||||
$ret[$chart_id][$node_id][$point_id]['busy'] = $cpuload['busy'];
|
||||
$ret[$chart_id][$node_id][$point_id]['idle']
|
||||
= $cpuload['idle'];
|
||||
$ret[$chart_id][$node_id][$point_id]['busy']
|
||||
= $cpuload['busy'];
|
||||
} else
|
||||
$ret[$chart_id][$node_id][$point_id]['value'] = $cpuload['loadavg'];
|
||||
$ret[$chart_id][$node_id][$point_id]['value']
|
||||
= $cpuload['loadavg'];
|
||||
|
||||
break;
|
||||
|
||||
@ -152,7 +159,8 @@ if (isset($_REQUEST['ajax_request']) && $_REQUEST['ajax_request'] == true) {
|
||||
$memory = $sysinfo->memory();
|
||||
}
|
||||
|
||||
$ret[$chart_id][$node_id][$point_id]['value'] = $memory[$pName];
|
||||
$ret[$chart_id][$node_id][$point_id]['value']
|
||||
= $memory[$pName];
|
||||
break;
|
||||
} /* switch */
|
||||
} /* foreach */
|
||||
@ -185,10 +193,12 @@ if (isset($_REQUEST['ajax_request']) && $_REQUEST['ajax_request'] == true) {
|
||||
foreach ($nodeDataPoints as $point_id => $dataPoint) {
|
||||
switch($dataPoint['type']) {
|
||||
case 'statusvar':
|
||||
$ret[$chart_id][$node_id][$point_id]['value'] = $statusVarValues[$dataPoint['name']];
|
||||
$ret[$chart_id][$node_id][$point_id]['value']
|
||||
= $statusVarValues[$dataPoint['name']];
|
||||
break;
|
||||
case 'servervar':
|
||||
$ret[$chart_id][$node_id][$point_id]['value'] = $serverVarValues[$dataPoint['name']];
|
||||
$ret[$chart_id][$node_id][$point_id]['value']
|
||||
= $serverVarValues[$dataPoint['name']];
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -211,10 +221,15 @@ if (isset($_REQUEST['ajax_request']) && $_REQUEST['ajax_request'] == true) {
|
||||
$end = intval($_REQUEST['time_end']);
|
||||
|
||||
if ($_REQUEST['type'] == 'slow') {
|
||||
$q = 'SELECT start_time, user_host, Sec_to_Time(Sum(Time_to_Sec(query_time))) as query_time, Sec_to_Time(Sum(Time_to_Sec(lock_time))) as lock_time, '.
|
||||
'SUM(rows_sent) AS rows_sent, SUM(rows_examined) AS rows_examined, db, sql_text, COUNT(sql_text) AS \'#\' '.
|
||||
'FROM `mysql`.`slow_log` WHERE start_time > FROM_UNIXTIME(' . $start . ') '.
|
||||
'AND start_time < FROM_UNIXTIME(' . $end . ') GROUP BY sql_text';
|
||||
$q = 'SELECT start_time, user_host, ';
|
||||
$q .= 'Sec_to_Time(Sum(Time_to_Sec(query_time))) as query_time, ';
|
||||
$q .= 'Sec_to_Time(Sum(Time_to_Sec(lock_time))) as lock_time, ';
|
||||
$q .= 'SUM(rows_sent) AS rows_sent, ';
|
||||
$q .= 'SUM(rows_examined) AS rows_examined, db, sql_text, ';
|
||||
$q .= 'COUNT(sql_text) AS \'#\' ';
|
||||
$q .= 'FROM `mysql`.`slow_log` ';
|
||||
$q .= 'WHERE start_time > FROM_UNIXTIME(' . $start . ') ';
|
||||
$q .= 'AND start_time < FROM_UNIXTIME(' . $end . ') GROUP BY sql_text';
|
||||
|
||||
$result = PMA_DBI_try_query($q);
|
||||
|
||||
@ -222,17 +237,20 @@ if (isset($_REQUEST['ajax_request']) && $_REQUEST['ajax_request'] == true) {
|
||||
$type = '';
|
||||
|
||||
while ($row = PMA_DBI_fetch_assoc($result)) {
|
||||
$type = strtolower(substr($row['sql_text'], 0, strpos($row['sql_text'], ' ')));
|
||||
$type = strtolower(
|
||||
substr($row['sql_text'], 0, strpos($row['sql_text'], ' '))
|
||||
);
|
||||
|
||||
switch($type) {
|
||||
case 'insert':
|
||||
case 'update':
|
||||
// Cut off big inserts and updates, but append byte count therefor
|
||||
//Cut off big inserts and updates, but append byte count instead
|
||||
if (strlen($row['sql_text']) > 220) {
|
||||
$implode_sql_text = implode(
|
||||
' ', PMA_formatByteDown(strlen($row['sql_text']), 2, 2)
|
||||
);
|
||||
$row['sql_text'] = substr($row['sql_text'], 0, 200)
|
||||
. '... ['
|
||||
. implode(' ', PMA_formatByteDown(strlen($row['sql_text']), 2, 2))
|
||||
. ']';
|
||||
. '... [' . $implode_sql_text . ']';
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@ -256,12 +274,15 @@ if (isset($_REQUEST['ajax_request']) && $_REQUEST['ajax_request'] == true) {
|
||||
|
||||
if ($_REQUEST['type'] == 'general') {
|
||||
$limitTypes = (isset($_REQUEST['limitTypes']) && $_REQUEST['limitTypes'])
|
||||
? 'AND argument REGEXP \'^(INSERT|SELECT|UPDATE|DELETE)\' ' : '';
|
||||
? 'AND argument REGEXP \'^(INSERT|SELECT|UPDATE|DELETE)\' ' : '';
|
||||
|
||||
$q = 'SELECT TIME(event_time) as event_time, user_host, thread_id, server_id, argument, count(argument) as \'#\' '.
|
||||
'FROM `mysql`.`general_log` WHERE command_type=\'Query\' '.
|
||||
'AND event_time > FROM_UNIXTIME(' . $start . ') AND event_time < FROM_UNIXTIME(' . $end . ') '.
|
||||
$limitTypes . 'GROUP by argument'; // HAVING count > 1';
|
||||
$q = 'SELECT TIME(event_time) as event_time, user_host, thread_id, ';
|
||||
$q .= 'server_id, argument, count(argument) as \'#\' ';
|
||||
$q .= 'FROM `mysql`.`general_log` ';
|
||||
$q .= 'WHERE command_type=\'Query\' ';
|
||||
$q .= 'AND event_time > FROM_UNIXTIME(' . $start . ') ';
|
||||
$q .= 'AND event_time < FROM_UNIXTIME(' . $end . ') ';
|
||||
$q .= $limitTypes . 'GROUP by argument'; // HAVING count > 1';
|
||||
|
||||
$result = PMA_DBI_try_query($q);
|
||||
|
||||
@ -270,7 +291,8 @@ if (isset($_REQUEST['ajax_request']) && $_REQUEST['ajax_request'] == true) {
|
||||
$insertTables = array();
|
||||
$insertTablesFirst = -1;
|
||||
$i = 0;
|
||||
$removeVars = isset($_REQUEST['removeVariables']) && $_REQUEST['removeVariables'];
|
||||
$removeVars = isset($_REQUEST['removeVariables'])
|
||||
&& $_REQUEST['removeVariables'];
|
||||
|
||||
while ($row = PMA_DBI_fetch_assoc($result)) {
|
||||
preg_match('/^(\w+)\s/', $row['argument'], $match);
|
||||
@ -287,7 +309,8 @@ if (isset($_REQUEST['ajax_request']) && $_REQUEST['ajax_request'] == true) {
|
||||
if ($removeVars && preg_match('/^INSERT INTO (`|\'|"|)([^\s\\1]+)\\1/i', $row['argument'], $matches)) {
|
||||
$insertTables[$matches[2]]++;
|
||||
if ($insertTables[$matches[2]] > 1) {
|
||||
$return['rows'][$insertTablesFirst]['#'] = $insertTables[$matches[2]];
|
||||
$return['rows'][$insertTablesFirst]['#']
|
||||
= $insertTables[$matches[2]];
|
||||
|
||||
// Add a ... to the end of this query to indicate that there's been other queries
|
||||
if ($return['rows'][$insertTablesFirst]['argument'][strlen($return['rows'][$insertTablesFirst]['argument'])-1] != '.') {
|
||||
@ -1484,7 +1507,7 @@ function printVariablesTable()
|
||||
<th class="name"><?php
|
||||
echo htmlspecialchars(str_replace('_', ' ', $name));
|
||||
/* Fields containing % are calculated, they can not be described in MySQL documentation */
|
||||
if (strpos($name, '%') === FALSE) {
|
||||
if (strpos($name, '%') === false) {
|
||||
echo PMA_showMySQLDocu('server-status-variables', 'server-status-variables', false, 'statvar_' . $name);
|
||||
}
|
||||
?>
|
||||
|
||||
@ -95,12 +95,22 @@ if (isset($_REQUEST['do_save_data'])) {
|
||||
|
||||
// To allow replication, we first select the db to use and then run queries
|
||||
// on this db.
|
||||
PMA_DBI_select_db($db) or PMA_mysqlDie(PMA_DBI_getError(), 'USE ' . PMA_backquote($db) . ';', '', $err_url);
|
||||
$sql_query = 'ALTER TABLE ' . PMA_backquote($table) . ' ' . implode(', ', $changes) . $key_query;
|
||||
if (! PMA_DBI_select_db($db)) {
|
||||
PMA_mysqlDie(
|
||||
PMA_DBI_getError(),
|
||||
'USE ' . PMA_backquote($db) . ';',
|
||||
'',
|
||||
$err_url
|
||||
);
|
||||
}
|
||||
$sql_query = 'ALTER TABLE ' . PMA_backquote($table) . ' ';
|
||||
$sql_query .= implode(', ', $changes) . $key_query;
|
||||
$result = PMA_DBI_try_query($sql_query);
|
||||
|
||||
if ($result !== false) {
|
||||
$message = PMA_Message::success(__('Table %1$s has been altered successfully'));
|
||||
$message = PMA_Message::success(
|
||||
__('Table %1$s has been altered successfully')
|
||||
);
|
||||
$message->addParam($table);
|
||||
$btnDrop = 'Fake';
|
||||
|
||||
@ -113,8 +123,10 @@ if (isset($_REQUEST['do_save_data'])) {
|
||||
if (isset($_REQUEST['field_orig']) && is_array($_REQUEST['field_orig'])) {
|
||||
foreach ($_REQUEST['field_orig'] as $fieldindex => $fieldcontent) {
|
||||
if ($_REQUEST['field_name'][$fieldindex] != $fieldcontent) {
|
||||
PMA_REL_renameField($db, $table, $fieldcontent,
|
||||
$_REQUEST['field_name'][$fieldindex]);
|
||||
PMA_REL_renameField(
|
||||
$db, $table, $fieldcontent,
|
||||
$_REQUEST['field_name'][$fieldindex]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -125,11 +137,14 @@ if (isset($_REQUEST['do_save_data'])) {
|
||||
&& $cfg['BrowseMIME']) {
|
||||
foreach ($_REQUEST['field_mimetype'] as $fieldindex => $mimetype) {
|
||||
if (isset($_REQUEST['field_name'][$fieldindex])
|
||||
&& strlen($_REQUEST['field_name'][$fieldindex])) {
|
||||
PMA_setMIME($db, $table, $_REQUEST['field_name'][$fieldindex],
|
||||
&& strlen($_REQUEST['field_name'][$fieldindex])
|
||||
) {
|
||||
PMA_setMIME(
|
||||
$db, $table, $_REQUEST['field_name'][$fieldindex],
|
||||
$mimetype,
|
||||
$_REQUEST['field_transformation'][$fieldindex],
|
||||
$_REQUEST['field_transformation_options'][$fieldindex]);
|
||||
$_REQUEST['field_transformation_options'][$fieldindex]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -195,7 +210,10 @@ if ($abort == false) {
|
||||
// SHOW FULL COLUMNS says NULL and SHOW CREATE TABLE says NOT NULL (tested
|
||||
// in MySQL 4.0.25).
|
||||
|
||||
$show_create_table = PMA_DBI_fetch_value('SHOW CREATE TABLE ' . PMA_backquote($db) . '.' . PMA_backquote($table), 0, 1);
|
||||
$show_create_table = PMA_DBI_fetch_value(
|
||||
'SHOW CREATE TABLE ' . PMA_backquote($db) . '.' . PMA_backquote($table),
|
||||
0, 1
|
||||
);
|
||||
$analyzed_sql = PMA_SQP_analyze(PMA_SQP_parse($show_create_table));
|
||||
unset($show_create_table);
|
||||
/**
|
||||
|
||||
@ -1,32 +1,39 @@
|
||||
<?php
|
||||
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* Selenium Helper Class
|
||||
*
|
||||
* @package PhpMyAdmin-test
|
||||
* @subpackage Selenium
|
||||
*/
|
||||
require_once 'TestConfig.php';
|
||||
|
||||
class Helper {
|
||||
class Helper
|
||||
{
|
||||
public static $selenium;
|
||||
public static $config;
|
||||
|
||||
public static $selenium;
|
||||
public static $config;
|
||||
function __construct()
|
||||
{
|
||||
self::$config = new TestConfig();
|
||||
}
|
||||
|
||||
function __construct() {
|
||||
self::$config = new TestConfig();
|
||||
}
|
||||
public static function isLoggedIn($selenium)
|
||||
{
|
||||
return $selenium->isElementPresent('//*[@id="serverinfo"]/a[1]');
|
||||
}
|
||||
|
||||
public static function isLoggedIn($selenium) {
|
||||
return $selenium->isElementPresent('//*[@id="serverinfo"]/a[1]');
|
||||
}
|
||||
|
||||
public static function logOutIfLoggedIn($selenium) {
|
||||
if (self::isLoggedIn($selenium)) {
|
||||
$selenium->selectFrame("frame_navigation");
|
||||
$selenium->clickAndWait("css=img.icon.ic_b_home");
|
||||
}
|
||||
}
|
||||
|
||||
public static function getBrowserString() {
|
||||
$browserString = self::$config->getCurrentBrowser();
|
||||
return $browserString;
|
||||
}
|
||||
public static function logOutIfLoggedIn($selenium)
|
||||
{
|
||||
if (self::isLoggedIn($selenium)) {
|
||||
$selenium->selectFrame("frame_navigation");
|
||||
$selenium->clickAndWait("css=img.icon.ic_b_home");
|
||||
}
|
||||
}
|
||||
|
||||
public static function getBrowserString() {
|
||||
$browserString = self::$config->getCurrentBrowser();
|
||||
return $browserString;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@ -1,37 +1,37 @@
|
||||
<?php
|
||||
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* Selenium TestCase for login related tests
|
||||
*
|
||||
* @package PhpMyAdmin-test
|
||||
* @group Selenium
|
||||
* @package PhpMyAdmin-test
|
||||
* @subpackage Selenium
|
||||
*/
|
||||
require_once 'PmaSeleniumTestCase.php';
|
||||
require_once 'Helper.php';
|
||||
|
||||
class PmaSeleniumLoginTest extends PHPUnit_Extensions_SeleniumTestCase {
|
||||
class PmaSeleniumLoginTest extends PHPUnit_Extensions_SeleniumTestCase
|
||||
{
|
||||
public function setUp()
|
||||
{
|
||||
$helper = new Helper();
|
||||
$this->setBrowser(Helper::getBrowserString());
|
||||
$this->setBrowserUrl(TESTSUITE_PHPMYADMIN_HOST . TESTSUITE_PHPMYADMIN_URL);
|
||||
}
|
||||
|
||||
public function setUp() {
|
||||
$helper = new Helper();
|
||||
$this->setBrowser(Helper::getBrowserString());
|
||||
$this->setBrowserUrl(TESTSUITE_PHPMYADMIN_HOST . TESTSUITE_PHPMYADMIN_URL);
|
||||
}
|
||||
|
||||
public function testSuccessfulLogin() {
|
||||
$log = new PmaSeleniumTestCase($this);
|
||||
$log->login(TESTSUITE_USER, TESTSUITE_PASSWORD);
|
||||
$this->assertTrue($log->isSuccessLogin());
|
||||
Helper::logOutIfLoggedIn($this);
|
||||
}
|
||||
|
||||
public function testLoginWithWrongPassword() {
|
||||
$log = new PmaSeleniumTestCase($this);
|
||||
$log->login("Admin", "Admin");
|
||||
$this->assertTrue($log->isUnsuccessLogin());
|
||||
Helper::logOutIfLoggedIn($this);
|
||||
}
|
||||
public function testSuccessfulLogin()
|
||||
{
|
||||
$log = new PmaSeleniumTestCase($this);
|
||||
$log->login(TESTSUITE_USER, TESTSUITE_PASSWORD);
|
||||
$this->assertTrue($log->isSuccessLogin());
|
||||
Helper::logOutIfLoggedIn($this);
|
||||
}
|
||||
|
||||
public function testLoginWithWrongPassword()
|
||||
{
|
||||
$log = new PmaSeleniumTestCase($this);
|
||||
$log->login("Admin", "Admin");
|
||||
$this->assertTrue($log->isUnsuccessLogin());
|
||||
Helper::logOutIfLoggedIn($this);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@ -1,57 +1,55 @@
|
||||
<?php
|
||||
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* Selenium TestCase for privilege related tests
|
||||
*
|
||||
* @package PhpMyAdmin-test
|
||||
* @group Selenium
|
||||
* @subpackage Selenium
|
||||
*/
|
||||
require_once 'PmaSeleniumTestCase.php';
|
||||
require_once 'Helper.php';
|
||||
|
||||
class PmaSeleniumPrivilegesTest extends PHPUnit_Extensions_SeleniumTestCase {
|
||||
|
||||
public function setUp() {
|
||||
$helper = new Helper();
|
||||
$this->setBrowser(Helper::getBrowserString());
|
||||
$this->setBrowserUrl(TESTSUITE_PHPMYADMIN_HOST . TESTSUITE_PHPMYADMIN_URL);
|
||||
}
|
||||
|
||||
public function testChangePassword() {
|
||||
$log = new PmaSeleniumTestCase($this);
|
||||
$log->login(TESTSUITE_USER, TESTSUITE_PASSWORD);
|
||||
$this->selectFrame("frame_content");
|
||||
$this->click("link=Change password");
|
||||
$this->waitForPageToLoad("20000");
|
||||
try {
|
||||
$this->assertEquals("", $this->getValue("text_pma_pw"));
|
||||
} catch (PHPUnit_Framework_AssertionFailedError $e) {
|
||||
array_push($this->verificationErrors, $e->toString());
|
||||
}
|
||||
try {
|
||||
$this->assertEquals("", $this->getValue("text_pma_pw2"));
|
||||
} catch (PHPUnit_Framework_AssertionFailedError $e) {
|
||||
array_push($this->verificationErrors, $e->toString());
|
||||
}
|
||||
try {
|
||||
$this->assertEquals("", $this->getValue("generated_pw"));
|
||||
} catch (PHPUnit_Framework_AssertionFailedError $e) {
|
||||
array_push($this->verificationErrors, $e->toString());
|
||||
}
|
||||
$this->click("button_generate_password");
|
||||
$this->assertNotEquals("", $this->getValue("text_pma_pw"));
|
||||
$this->assertNotEquals("", $this->getValue("text_pma_pw2"));
|
||||
$this->assertNotEquals("", $this->getValue("generated_pw"));
|
||||
$this->type("text_pma_pw", TESTSUITE_PASSWORD);
|
||||
$this->type("text_pma_pw2", TESTSUITE_PASSWORD);
|
||||
$this->click("//button[@type='button']");
|
||||
$this->waitForPageToLoad("20000");
|
||||
$this->assertTrue($this->isTextPresent(""));
|
||||
$this->assertTrue($this->isTextPresent(""));
|
||||
|
||||
}
|
||||
class PmaSeleniumPrivilegesTest extends PHPUnit_Extensions_SeleniumTestCase
|
||||
{
|
||||
public function setUp()
|
||||
{
|
||||
$helper = new Helper();
|
||||
$this->setBrowser(Helper::getBrowserString());
|
||||
$this->setBrowserUrl(TESTSUITE_PHPMYADMIN_HOST . TESTSUITE_PHPMYADMIN_URL);
|
||||
}
|
||||
|
||||
public function testChangePassword()
|
||||
{
|
||||
$log = new PmaSeleniumTestCase($this);
|
||||
$log->login(TESTSUITE_USER, TESTSUITE_PASSWORD);
|
||||
$this->selectFrame("frame_content");
|
||||
$this->click("link=Change password");
|
||||
$this->waitForPageToLoad("20000");
|
||||
try {
|
||||
$this->assertEquals("", $this->getValue("text_pma_pw"));
|
||||
} catch (PHPUnit_Framework_AssertionFailedError $e) {
|
||||
array_push($this->verificationErrors, $e->toString());
|
||||
}
|
||||
try {
|
||||
$this->assertEquals("", $this->getValue("text_pma_pw2"));
|
||||
} catch (PHPUnit_Framework_AssertionFailedError $e) {
|
||||
array_push($this->verificationErrors, $e->toString());
|
||||
}
|
||||
try {
|
||||
$this->assertEquals("", $this->getValue("generated_pw"));
|
||||
} catch (PHPUnit_Framework_AssertionFailedError $e) {
|
||||
array_push($this->verificationErrors, $e->toString());
|
||||
}
|
||||
$this->click("button_generate_password");
|
||||
$this->assertNotEquals("", $this->getValue("text_pma_pw"));
|
||||
$this->assertNotEquals("", $this->getValue("text_pma_pw2"));
|
||||
$this->assertNotEquals("", $this->getValue("generated_pw"));
|
||||
$this->type("text_pma_pw", TESTSUITE_PASSWORD);
|
||||
$this->type("text_pma_pw2", TESTSUITE_PASSWORD);
|
||||
$this->click("//button[@type='button']");
|
||||
$this->waitForPageToLoad("20000");
|
||||
$this->assertTrue($this->isTextPresent(""));
|
||||
$this->assertTrue($this->isTextPresent(""));
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
* Selenium parent class for TestCases
|
||||
*
|
||||
* @package PhpMyAdmin-test
|
||||
* @group Selenium
|
||||
* @subpackage Selenium
|
||||
*/
|
||||
|
||||
class PmaSeleniumTestCase
|
||||
@ -15,55 +15,57 @@ class PmaSeleniumTestCase
|
||||
private $selenium;
|
||||
private $config;
|
||||
|
||||
public function __construct($selenium) {
|
||||
public function __construct($selenium)
|
||||
{
|
||||
$this->txtUsername = 'input_username';
|
||||
$this->txtPassword = 'input_password';
|
||||
$this->btnLogin = 'input_go';
|
||||
$this->config = new TestConfig();
|
||||
$this->config = new TestConfig();
|
||||
$this->selenium = $selenium;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* perform a login
|
||||
* @param <type> $username
|
||||
* @param <type> $password
|
||||
*
|
||||
* @param string $username Username
|
||||
* @param string $password Password
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function login($username, $password) {
|
||||
|
||||
public function login($username, $password)
|
||||
{
|
||||
$this->selenium->open($this->config->getLoginURL());
|
||||
$this->selenium->type($this->txtUsername, $username);
|
||||
$this->selenium->type($this->txtPassword, $password);
|
||||
$this->selenium->click($this->btnLogin);
|
||||
$this->selenium->waitForPageToLoad($this->config->getTimeoutValue());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isSuccessLogin() {
|
||||
if($this->selenium->isElementPresent("//*[@id=\"serverinfo\"]")){
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isUnsuccessLogin() {
|
||||
$val = $this->selenium->getValue('input_go');
|
||||
if($this->selenium->isElementPresent("//html/body/div/div[@class='error']")){
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
public function isSuccessLogin()
|
||||
{
|
||||
if ($this->selenium->isElementPresent("//*[@id=\"serverinfo\"]")) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isUnsuccessLogin()
|
||||
{
|
||||
$val = $this->selenium->getValue('input_go');
|
||||
if ($this->selenium->isElementPresent("//html/body/div/div[@class='error']")) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@ -1,33 +1,32 @@
|
||||
<?php
|
||||
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* Selenium TestCase for XSS related tests
|
||||
*
|
||||
* @package PhpMyAdmin-test
|
||||
* @group Selenium
|
||||
* @subpackage Selenium
|
||||
*/
|
||||
require_once 'PmaSeleniumTestCase.php';
|
||||
require_once 'Helper.php';
|
||||
|
||||
class PmaSeleniumXSSTest extends PHPUnit_Extensions_SeleniumTestCase {
|
||||
|
||||
public function setUp() {
|
||||
$helper = new Helper();
|
||||
$this->setBrowser(Helper::getBrowserString());
|
||||
$this->setBrowserUrl(TESTSUITE_PHPMYADMIN_HOST . TESTSUITE_PHPMYADMIN_URL);
|
||||
}
|
||||
|
||||
public function testQueryTabWithNullValue() {
|
||||
$log = new PmaSeleniumTestCase($this);
|
||||
$log->login(TESTSUITE_USER, TESTSUITE_PASSWORD);
|
||||
$this->selectFrame("frame_content");
|
||||
$this->click("link=SQL");
|
||||
$this->waitForPageToLoad("30000");
|
||||
$this->click("button_submit_query");
|
||||
$this->assertAlert("Missing value in the form!");
|
||||
}
|
||||
class PmaSeleniumXSSTest extends PHPUnit_Extensions_SeleniumTestCase
|
||||
{
|
||||
public function setUp()
|
||||
{
|
||||
$helper = new Helper();
|
||||
$this->setBrowser(Helper::getBrowserString());
|
||||
$this->setBrowserUrl(TESTSUITE_PHPMYADMIN_HOST . TESTSUITE_PHPMYADMIN_URL);
|
||||
}
|
||||
|
||||
public function testQueryTabWithNullValue()
|
||||
{
|
||||
$log = new PmaSeleniumTestCase($this);
|
||||
$log->login(TESTSUITE_USER, TESTSUITE_PASSWORD);
|
||||
$this->selectFrame("frame_content");
|
||||
$this->click("link=SQL");
|
||||
$this->waitForPageToLoad("30000");
|
||||
$this->click("button_submit_query");
|
||||
$this->assertAlert("Missing value in the form!");
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
Guide to run the AllSeleniumTests.php (Yasitha Pandithawatta)
|
||||
=====================================
|
||||
=============================================================
|
||||
|
||||
1. Tested with version 4.0
|
||||
2. Configure the testing environment - Browser and the following feilds in phpunit.xml.dist
|
||||
2. Configure the testing environment - Browser and add the following fields to
|
||||
phpunit.xml.dist
|
||||
<php>
|
||||
<const name="TESTSUITE_SERVER" value="localhost"/>
|
||||
<const name="TESTSUITE_USER" value="root"/>
|
||||
@ -12,8 +13,6 @@ Guide to run the AllSeleniumTests.php (Yasitha Pandithawatta)
|
||||
<const name="TESTSUITE_PHPMYADMIN_URL" value="/phpmyadmin-dev" />
|
||||
</php>
|
||||
3. Start the selenium server
|
||||
4. run $ phpunit test/AllSeleniumTests.php
|
||||
4. Run $ phpunit test/AllSeleniumTests.php
|
||||
|
||||
Note: Only PmaSeleniumLoginTest.php is fixed and added to the test suit.
|
||||
|
||||
|
||||
|
||||
@ -1,52 +1,59 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* Selenium TestConfig
|
||||
*
|
||||
* @package PhpMyAdmin-test
|
||||
* @subpackage Selenium
|
||||
*/
|
||||
|
||||
class TestConfig {
|
||||
class TestConfig
|
||||
{
|
||||
private $loginURL;
|
||||
private $timeoutValue;
|
||||
|
||||
private $loginURL;
|
||||
private $timeoutValue;
|
||||
public function __construct()
|
||||
{
|
||||
$xml = simplexml_load_file("phpunit.xml.dist");
|
||||
$xmlDoc = new DOMDocument();
|
||||
$xmlDoc->load('phpunit.xml.dist');
|
||||
$searchNode = $xmlDoc->getElementsByTagName("browser");
|
||||
foreach ($searchNode as $searchNode) {
|
||||
$this->setCurrentBrowser($searchNode->getAttribute('browser'));
|
||||
$this->setTimeoutValue($searchNode->getAttribute('timeout'));
|
||||
}
|
||||
$this->setLoginURL(TESTSUITE_PHPMYADMIN_HOST . TESTSUITE_PHPMYADMIN_URL);
|
||||
}
|
||||
|
||||
public function __construct() {
|
||||
$xml = simplexml_load_file("phpunit.xml.dist");
|
||||
$xmlDoc = new DOMDocument();
|
||||
$xmlDoc->load('phpunit.xml.dist');
|
||||
$searchNode = $xmlDoc->getElementsByTagName("browser");
|
||||
foreach ($searchNode as $searchNode) {
|
||||
$this->setCurrentBrowser($searchNode->getAttribute('browser'));
|
||||
$this->setTimeoutValue($searchNode->getAttribute('timeout'));
|
||||
}
|
||||
$this->setLoginURL(TESTSUITE_PHPMYADMIN_HOST . TESTSUITE_PHPMYADMIN_URL);
|
||||
}
|
||||
public function setLoginURL($value)
|
||||
{
|
||||
$this->loginURL = $value;
|
||||
}
|
||||
|
||||
public function setLoginURL($value) {
|
||||
public function getLoginURL()
|
||||
{
|
||||
return $this->loginURL;
|
||||
}
|
||||
|
||||
$this->loginURL = $value;
|
||||
}
|
||||
public function setTimeoutValue($value)
|
||||
{
|
||||
$this->timeoutValue = $value;
|
||||
}
|
||||
|
||||
public function getLoginURL() {
|
||||
public function getTimeoutValue()
|
||||
{
|
||||
return $this->timeoutValue;
|
||||
}
|
||||
|
||||
return $this->loginURL;
|
||||
}
|
||||
|
||||
public function setTimeoutValue($value) {
|
||||
|
||||
$this->timeoutValue = $value;
|
||||
}
|
||||
|
||||
public function getTimeoutValue() {
|
||||
|
||||
return $this->timeoutValue;
|
||||
}
|
||||
|
||||
public function setCurrentBrowser($value) {
|
||||
|
||||
$this->currentBrowser = $value;
|
||||
}
|
||||
|
||||
public function getCurrentBrowser() {
|
||||
|
||||
return $this->currentBrowser;
|
||||
}
|
||||
public function setCurrentBrowser($value)
|
||||
{
|
||||
$this->currentBrowser = $value;
|
||||
}
|
||||
|
||||
public function getCurrentBrowser()
|
||||
{
|
||||
return $this->currentBrowser;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user