Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
9938f346f9
@ -2526,7 +2526,8 @@ function PMA_getHtmlForDisplaySelectDbInEditPrivs($found_rows)
|
||||
}
|
||||
$html_output .= '</select>' . "\n";
|
||||
}
|
||||
$html_output .= '<input type="text" id="text_dbname" name="dbname" required />' . "\n"
|
||||
$html_output .= '<input type="text" id="text_dbname" name="dbname" required />'
|
||||
. "\n"
|
||||
. PMA_Util::showHint(
|
||||
__('Wildcards % and _ should be escaped with a \ to use them literally.')
|
||||
);
|
||||
@ -3281,11 +3282,19 @@ function PMA_addUser(
|
||||
*/
|
||||
function PMA_getDataForDBInfo()
|
||||
{
|
||||
$username = null;
|
||||
$hostname = null;
|
||||
$dbname = null;
|
||||
$tablename = null;
|
||||
$db_and_table = null;
|
||||
$dbname_is_wildcard = null;
|
||||
|
||||
if (isset ($_REQUEST['username'])) {
|
||||
$username = $_REQUEST['username'];
|
||||
}
|
||||
if (isset ($_REQUEST['hostname'])) {
|
||||
$hostname = $_REQUEST['hostname'];
|
||||
}
|
||||
/**
|
||||
* Checks if a dropdown box has been used for selecting a database / table
|
||||
*/
|
||||
@ -3330,6 +3339,7 @@ function PMA_getDataForDBInfo()
|
||||
}
|
||||
|
||||
return array(
|
||||
$username, $hostname,
|
||||
isset($dbname)? $dbname : null,
|
||||
isset($tablename)? $tablename : null,
|
||||
$db_and_table,
|
||||
@ -3785,7 +3795,8 @@ function PMA_getHtmlToEditUserGroup($userGroup = null)
|
||||
|
||||
if ($userGroup == null) {
|
||||
$html_output .= '<label for="userGroup">' . __('Group name:') . '</label>';
|
||||
$html_output .= '<input type="text" name="userGroup" autocomplete="off" required />';
|
||||
$html_output .= '<input type="text" name="userGroup" '
|
||||
. 'autocomplete="off" required />';
|
||||
$html_output .= '<div class="clearfloat"></div>';
|
||||
}
|
||||
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* include common file
|
||||
*/
|
||||
require_once 'libraries/common.inc.php';
|
||||
|
||||
@ -34,15 +34,6 @@ if ((empty($_REQUEST['viewing_mode']) || $_REQUEST['viewing_mode'] != 'db')
|
||||
$response->addHTML(PMA_getHtmlForSubMenusOnUsersPage('server_privileges.php'));
|
||||
}
|
||||
|
||||
$_add_user_error = false;
|
||||
|
||||
if (isset ($_REQUEST['username'])) {
|
||||
$username = $_REQUEST['username'];
|
||||
}
|
||||
if (isset ($_REQUEST['hostname'])) {
|
||||
$hostname = $_REQUEST['hostname'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets globals from $_POST patterns, for privileges and max_* vars
|
||||
*/
|
||||
@ -92,7 +83,7 @@ $strPrivDescMaxQuestions = __(
|
||||
'Limits the number of queries the user may send to the server per hour.'
|
||||
);
|
||||
$strPrivDescMaxUpdates = __(
|
||||
'Limits the number of commands that change any table or database '
|
||||
'Limits the number of commands that change any table or database '
|
||||
. 'the user may execute per hour.'
|
||||
);
|
||||
$strPrivDescMaxUserConnections = __(
|
||||
@ -112,20 +103,23 @@ $strPrivDescShowDb = __('Gives access to the complete list of databases.');
|
||||
$strPrivDescShowView = __('Allows performing SHOW CREATE VIEW queries.');
|
||||
$strPrivDescShutdown = __('Allows shutting down the server.');
|
||||
$strPrivDescSuper = __(
|
||||
'Allows connecting, even if maximum number of connections is reached; '
|
||||
. 'required for most administrative operations like setting global variables '
|
||||
'Allows connecting, even if maximum number of connections is reached; '
|
||||
. 'required for most administrative operations like setting global variables '
|
||||
. 'or killing threads of other users.'
|
||||
);
|
||||
$strPrivDescTrigger = __('Allows creating and dropping triggers');
|
||||
$strPrivDescUpdate = __('Allows changing data.');
|
||||
$strPrivDescUsage = __('No privileges.');
|
||||
|
||||
|
||||
$_add_user_error = false;
|
||||
/**
|
||||
* Get DB information: dbname, tablename, db_and_table, dbname_is_wildcard
|
||||
* Get DB information: username, hostname, dbname,
|
||||
* tablename, db_and_table, dbname_is_wildcard
|
||||
*/
|
||||
list($dbname, $tablename, $db_and_table, $dbname_is_wildcard)
|
||||
= PMA_getDataForDBInfo();
|
||||
list(
|
||||
$username, $hostname, $dbname, $tablename,
|
||||
$db_and_table, $dbname_is_wildcard
|
||||
) = PMA_getDataForDBInfo();
|
||||
|
||||
/**
|
||||
* Checks if the user is allowed to do what he tries to...
|
||||
@ -140,15 +134,15 @@ if (! $is_superuser) {
|
||||
* Changes / copies a user, part I
|
||||
*/
|
||||
list($queries, $password) = PMA_getDataForChangeOrCopyUser();
|
||||
|
||||
|
||||
/**
|
||||
* Adds a user
|
||||
* (Changes / copies a user, part II)
|
||||
*/
|
||||
list($ret_message, $ret_queries, $queries_for_display, $sql_query, $_add_user_error)
|
||||
*/
|
||||
list($ret_message, $ret_queries, $queries_for_display, $sql_query, $_add_user_error)
|
||||
= PMA_addUser(
|
||||
isset($dbname)? $dbname : null,
|
||||
isset($username)? $username : null,
|
||||
isset($dbname)? $dbname : null,
|
||||
isset($username)? $username : null,
|
||||
isset($hostname)? $hostname : null,
|
||||
isset($password)? $password : null,
|
||||
$cfgRelation['menuswork']
|
||||
@ -239,8 +233,8 @@ if (isset($_REQUEST['change_copy'])) {
|
||||
* Reloads the privilege tables into memory
|
||||
*/
|
||||
$message_ret = PMA_updateMessageForReload();
|
||||
if (isset($message_ret)) {
|
||||
$message = $message_ret;
|
||||
if (isset($message_ret)) {
|
||||
$message = $message_ret;
|
||||
unset($message_ret);
|
||||
}
|
||||
|
||||
@ -302,7 +296,7 @@ if (isset($_REQUEST['viewing_mode']) && $_REQUEST['viewing_mode'] == 'db') {
|
||||
*/
|
||||
$response->addHTML(
|
||||
PMA_getHtmlForUserGroupDialog(
|
||||
isset($username)? $username : null,
|
||||
isset($username)? $username : null,
|
||||
$cfgRelation['menuswork']
|
||||
)
|
||||
);
|
||||
|
||||
@ -102,10 +102,22 @@ class PMA_ServerPrivileges_Test extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testPMAGetDataForDBInfo()
|
||||
{
|
||||
$_REQUEST['username'] = "PMA_username";
|
||||
$_REQUEST['hostname'] = "PMA_hostname";
|
||||
$_REQUEST['tablename'] = "PMA_tablename";
|
||||
$_REQUEST['dbname'] = "PMA_dbname";
|
||||
list($dbname, $tablename, $db_and_table, $dbname_is_wildcard)
|
||||
= PMA_getDataForDBInfo();
|
||||
list(
|
||||
$username, $hostname, $dbname, $tablename,
|
||||
$db_and_table, $dbname_is_wildcard
|
||||
) = PMA_getDataForDBInfo();
|
||||
$this->assertEquals(
|
||||
"PMA_username",
|
||||
$username
|
||||
);
|
||||
$this->assertEquals(
|
||||
"PMA_hostname",
|
||||
$hostname
|
||||
);
|
||||
$this->assertEquals(
|
||||
"PMA_dbname",
|
||||
$dbname
|
||||
@ -126,8 +138,10 @@ class PMA_ServerPrivileges_Test extends PHPUnit_Framework_TestCase
|
||||
//pre variable have been defined
|
||||
$_REQUEST['pred_tablename'] = "PMA_pred__tablename";
|
||||
$_REQUEST['pred_dbname'] = "PMA_pred_dbname";
|
||||
list($dbname, $tablename, $db_and_table, $dbname_is_wildcard)
|
||||
= PMA_getDataForDBInfo();
|
||||
list(
|
||||
$username, $hostname, $dbname, $tablename,
|
||||
$db_and_table, $dbname_is_wildcard
|
||||
) = PMA_getDataForDBInfo();
|
||||
$this->assertEquals(
|
||||
"PMA_pred_dbname",
|
||||
$dbname
|
||||
|
||||
@ -205,6 +205,14 @@ class Helper
|
||||
return $browserString;
|
||||
}
|
||||
|
||||
/**
|
||||
* Wait for an element to be present on the page
|
||||
*
|
||||
* @param string $func Locate using - byCss, byXPath, etc
|
||||
* @param string $arg Selector
|
||||
*
|
||||
* @return PHPUnit_Extensions_Selenium2TestCase_Element Element waited for
|
||||
*/
|
||||
public function waitForElement($func, $arg)
|
||||
{
|
||||
$this->_selenium->timeouts()->implicitWait(10000);
|
||||
@ -215,10 +223,17 @@ class Helper
|
||||
return $element;
|
||||
}
|
||||
|
||||
/**
|
||||
* Wait for an element to disappear
|
||||
*
|
||||
* @param string $func Locate using - byCss, byXPath, etc
|
||||
* @param string $arg Selector
|
||||
*
|
||||
* @return bool Whether or not the element disappeared
|
||||
*/
|
||||
public function waitForElementNotPresent($func, $arg)
|
||||
{
|
||||
while(true)
|
||||
{
|
||||
while (true) {
|
||||
if (!$this->isElementPresent($func, $arg)) {
|
||||
return true;
|
||||
}
|
||||
@ -226,6 +241,14 @@ class Helper
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if element is present or not
|
||||
*
|
||||
* @param string $func Locate using - byCss, byXPath, etc
|
||||
* @param string $arg Selector
|
||||
*
|
||||
* @return bool Whether or not the element is present
|
||||
*/
|
||||
public function isElementPresent($func, $arg)
|
||||
{
|
||||
try {
|
||||
@ -240,16 +263,30 @@ class Helper
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get table cell data
|
||||
*
|
||||
* @param string $identifier Identifier: tableId.row.column
|
||||
*
|
||||
* @return text Data from the particular table cell
|
||||
*/
|
||||
public function getTable($identifier)
|
||||
{
|
||||
list($tableID, $row, $column) = explode(".", $identifier);
|
||||
$selector = "table#{$tableID} tbody tr:nth-child({$row}) td:nth-child({$column})";
|
||||
$sel = "table#{$tableID} tbody tr:nth-child({$row}) td:nth-child({$column})";
|
||||
$element = $this->_selenium->byCssSelector(
|
||||
$selector
|
||||
$sel
|
||||
);
|
||||
return $element->text();
|
||||
}
|
||||
|
||||
/**
|
||||
* Type text in textarea (CodeMirror enabled)
|
||||
*
|
||||
* @param string $text Text to type
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function typeInTextArea($text)
|
||||
{
|
||||
$text = str_replace(
|
||||
|
||||
@ -125,7 +125,8 @@ class PmaSeleniumDbEventsTest extends PHPUnit_Extensions_Selenium2TestCase
|
||||
|
||||
$ele = $this->_helper->waitForElement(
|
||||
"byXPath",
|
||||
"//div[@class='success' and contains(., 'Event `test_event` has been created')]"
|
||||
"//div[@class='success' and contains(., "
|
||||
. "'Event `test_event` has been created')]"
|
||||
);
|
||||
|
||||
$this->assertTrue(
|
||||
@ -177,7 +178,8 @@ class PmaSeleniumDbEventsTest extends PHPUnit_Extensions_Selenium2TestCase
|
||||
|
||||
$ele = $this->_helper->waitForElement(
|
||||
"byXPath",
|
||||
"//div[@class='success' and contains(., 'Event `test_event` has been modified')]"
|
||||
"//div[@class='success' and contains(., "
|
||||
. "'Event `test_event` has been modified')]"
|
||||
);
|
||||
|
||||
usleep(2000000);
|
||||
@ -209,7 +211,7 @@ class PmaSeleniumDbEventsTest extends PHPUnit_Extensions_Selenium2TestCase
|
||||
$this->byLinkText("Drop")->click();
|
||||
$this->_helper->waitForElement(
|
||||
"byXPath", "//button[contains(., 'OK')]"
|
||||
)->click();
|
||||
)->click();
|
||||
|
||||
$this->_helper->waitForElement("byId", "nothing2display");
|
||||
|
||||
|
||||
@ -93,7 +93,7 @@ class PmaSeleniumDbOperationsTest extends PHPUnit_Extensions_Selenium2TestCase
|
||||
|
||||
$this->_helper->waitForElement(
|
||||
"byXPath", "//button[contains(., 'OK')]"
|
||||
)->click();
|
||||
)->click();
|
||||
|
||||
$this->_helper->waitForElement(
|
||||
"byXPath",
|
||||
|
||||
@ -102,14 +102,14 @@ class PmaSeleniumDbProceduresTest extends PHPUnit_Extensions_Selenium2TestCase
|
||||
$this->byName("item_param_name[0]")->value("inp");
|
||||
$this->select(
|
||||
$this->byName("item_param_type[0]")
|
||||
)->selectOptionByLabel("VARCHAR");
|
||||
)->selectOptionByLabel("VARCHAR");
|
||||
$this->byName("item_param_length[0]")->value("10");
|
||||
|
||||
$this->byCssSelector("input[value='Add parameter']")->click();
|
||||
|
||||
$this->select(
|
||||
$this->byName("item_param_dir[1]")
|
||||
)->selectOptionByLabel("OUT");
|
||||
)->selectOptionByLabel("OUT");
|
||||
$ele = $this->_helper->waitForElement("byName", "item_param_name[1]");
|
||||
$ele->value("outp");
|
||||
|
||||
@ -118,13 +118,14 @@ class PmaSeleniumDbProceduresTest extends PHPUnit_Extensions_Selenium2TestCase
|
||||
|
||||
$this->select(
|
||||
$this->byName("item_sqldataaccess")
|
||||
)->selectOptionByLabel("READS SQL DATA");
|
||||
)->selectOptionByLabel("READS SQL DATA");
|
||||
|
||||
$this->byXPath("//button[contains(., 'Go')]")->click();
|
||||
|
||||
$ele = $this->_helper->waitForElement(
|
||||
"byXPath",
|
||||
"//div[@class='success' and contains(., 'Routine `test_procedure` has been created')]"
|
||||
"//div[@class='success' and contains(., "
|
||||
. "'Routine `test_procedure` has been created')]"
|
||||
);
|
||||
|
||||
$result = $this->_helper->dbQuery(
|
||||
@ -162,7 +163,8 @@ class PmaSeleniumDbProceduresTest extends PHPUnit_Extensions_Selenium2TestCase
|
||||
|
||||
$ele = $this->_helper->waitForElement(
|
||||
"byXPath",
|
||||
"//div[@class='success' and contains(., 'Routine `test_procedure` has been modified')]"
|
||||
"//div[@class='success' and contains(., "
|
||||
. "'Routine `test_procedure` has been modified')]"
|
||||
);
|
||||
|
||||
$this->_executeProcedure("abcabcabcabcabcabcabc", 12);
|
||||
@ -189,7 +191,7 @@ class PmaSeleniumDbProceduresTest extends PHPUnit_Extensions_Selenium2TestCase
|
||||
$this->byLinkText("Drop")->click();
|
||||
$this->_helper->waitForElement(
|
||||
"byXPath", "//button[contains(., 'OK')]"
|
||||
)->click();
|
||||
)->click();
|
||||
|
||||
$this->_helper->waitForElement("byId", "nothing2display");
|
||||
|
||||
@ -203,6 +205,9 @@ class PmaSeleniumDbProceduresTest extends PHPUnit_Extensions_Selenium2TestCase
|
||||
/**
|
||||
* Execute procedure
|
||||
*
|
||||
* @param string $text String to pass as inp param
|
||||
* @param int $length Expected output length
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function _executeProcedure($text, $length)
|
||||
|
||||
@ -89,12 +89,13 @@ class PmaSeleniumDbStructureTest extends PHPUnit_Extensions_Selenium2TestCase
|
||||
$this->_helper->waitForElement(
|
||||
"byXPath",
|
||||
"//button[contains(., 'OK')]"
|
||||
)->click();
|
||||
)->click();
|
||||
|
||||
$this->assertNotNull(
|
||||
$this->_helper->waitForElement(
|
||||
"byXPath",
|
||||
"//div[@class='success' and contains(., 'MySQL returned an empty result')]"
|
||||
"//div[@class='success' and contains(., "
|
||||
. "'MySQL returned an empty result')]"
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
@ -51,7 +51,8 @@ class PmaSeleniumDbTriggersTest extends PHPUnit_Extensions_Selenium2TestCase
|
||||
. " PRIMARY KEY (`id`)"
|
||||
. ")"
|
||||
);
|
||||
$this->_helper->dbQuery(
|
||||
|
||||
$this->_helper->dbQuery(
|
||||
"CREATE TABLE `test_table2` ("
|
||||
. " `id` int(11) NOT NULL AUTO_INCREMENT,"
|
||||
. " `val` int(11) NOT NULL,"
|
||||
@ -123,7 +124,8 @@ class PmaSeleniumDbTriggersTest extends PHPUnit_Extensions_Selenium2TestCase
|
||||
|
||||
$ele = $this->_helper->waitForElement(
|
||||
"byXPath",
|
||||
"//div[@class='success' and contains(., 'Trigger `test_trigger` has been created')]"
|
||||
"//div[@class='success' and contains(., "
|
||||
. "'Trigger `test_trigger` has been created')]"
|
||||
);
|
||||
|
||||
$this->assertTrue(
|
||||
@ -172,7 +174,8 @@ class PmaSeleniumDbTriggersTest extends PHPUnit_Extensions_Selenium2TestCase
|
||||
|
||||
$ele = $this->_helper->waitForElement(
|
||||
"byXPath",
|
||||
"//div[@class='success' and contains(., 'Trigger `test_trigger` has been modified')]"
|
||||
"//div[@class='success' and contains(., "
|
||||
. "'Trigger `test_trigger` has been modified')]"
|
||||
);
|
||||
|
||||
// test trigger
|
||||
@ -203,7 +206,7 @@ class PmaSeleniumDbTriggersTest extends PHPUnit_Extensions_Selenium2TestCase
|
||||
$this->byLinkText("Drop")->click();
|
||||
$this->_helper->waitForElement(
|
||||
"byXPath", "//button[contains(., 'OK')]"
|
||||
)->click();
|
||||
)->click();
|
||||
|
||||
$this->_helper->waitForElement("byId", "nothing2display");
|
||||
|
||||
|
||||
227
test/selenium/PmaSeleniumExportTest.php
Normal file
227
test/selenium/PmaSeleniumExportTest.php
Normal file
@ -0,0 +1,227 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* Selenium TestCase for export related tests
|
||||
*
|
||||
* @package PhpMyAdmin-test
|
||||
* @subpackage Selenium
|
||||
*/
|
||||
require_once 'Helper.php';
|
||||
|
||||
/**
|
||||
* PmaSeleniumExportTest class
|
||||
*
|
||||
* @package PhpMyAdmin-test
|
||||
* @subpackage Selenium
|
||||
*/
|
||||
class PmaSeleniumExportTest extends PHPUnit_Extensions_Selenium2TestCase
|
||||
{
|
||||
/**
|
||||
* Name of database for the test
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_dbname;
|
||||
|
||||
/**
|
||||
* Helper Object
|
||||
*
|
||||
* @var obj
|
||||
*/
|
||||
private $_helper;
|
||||
|
||||
/**
|
||||
* Setup the browser environment to run the selenium test case
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
$this->_helper = new Helper($this);
|
||||
$this->setBrowser($this->_helper->getBrowserString());
|
||||
$this->setBrowserUrl(TESTSUITE_PHPMYADMIN_HOST . TESTSUITE_PHPMYADMIN_URL);
|
||||
$this->_helper->dbConnect();
|
||||
$this->_dbname = 'pma_db_' . time();
|
||||
$this->_helper->dbQuery('CREATE DATABASE ' . $this->_dbname);
|
||||
$this->_helper->dbQuery('USE ' . $this->_dbname);
|
||||
$this->_helper->dbQuery(
|
||||
"CREATE TABLE `test_table` ("
|
||||
. " `id` int(11) NOT NULL AUTO_INCREMENT,"
|
||||
. " `val` int(11) NOT NULL,"
|
||||
. " PRIMARY KEY (`id`)"
|
||||
. ")"
|
||||
);
|
||||
$this->_helper->dbQuery(
|
||||
"INSERT INTO `test_table` (val) VALUES (2);"
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* setUp function that can use the selenium session (called before each test)
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setUpPage()
|
||||
{
|
||||
$this->_helper->login(TESTSUITE_USER, TESTSUITE_PASSWORD);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for server level export
|
||||
*
|
||||
* @param string $plugin Export format
|
||||
* @param array $expected Array of expected strings
|
||||
*
|
||||
* @return void
|
||||
* @dataProvider exportDataProvider
|
||||
*/
|
||||
public function testServerImport($plugin, $expected)
|
||||
{
|
||||
$text = $this->_doExport('server', $plugin);
|
||||
|
||||
foreach ($expected as $str) {
|
||||
$this->assertContains($str, $text);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for db level export
|
||||
*
|
||||
* @param string $plugin Export format
|
||||
* @param array $expected Array of expected strings
|
||||
*
|
||||
* @return void
|
||||
* @dataProvider exportDataProvider
|
||||
*/
|
||||
public function testDbExport($plugin, $expected)
|
||||
{
|
||||
$this->_helper->waitForElement("byLinkText", $this->_dbname)->click();
|
||||
$this->_helper->waitForElement(
|
||||
"byXPath",
|
||||
"//a[@class='item' and contains(., 'Database: ". $this->_dbname ."')]"
|
||||
);
|
||||
|
||||
$text = $this->_doExport('db', $plugin);
|
||||
|
||||
foreach ($expected as $str) {
|
||||
$this->assertContains($str, $text);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for table level export
|
||||
*
|
||||
* @param string $plugin Export format
|
||||
* @param array $expected Array of expected strings
|
||||
*
|
||||
* @return void
|
||||
* @dataProvider exportDataProvider
|
||||
*/
|
||||
public function testTableExport($plugin, $expected)
|
||||
{
|
||||
$this->_helper->dbQuery("INSERT INTO `test_table` (val) VALUES (3);");
|
||||
|
||||
// go to database page
|
||||
$this->_helper->waitForElement("byLinkText", $this->_dbname)->click();
|
||||
|
||||
// got to table page
|
||||
$this->_helper->waitForElement("byLinkText", "test_table")->click();
|
||||
$this->_helper->waitForElement(
|
||||
"byXPath",
|
||||
"//a[@class='tabactive' and contains(., 'Browse')]"
|
||||
);
|
||||
|
||||
$text = $this->_doExport('table', $plugin);
|
||||
|
||||
foreach ($expected as $str) {
|
||||
$this->assertContains($str, $text);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Data provider for testServerExport
|
||||
*
|
||||
* @return array Test cases data
|
||||
*/
|
||||
public function exportDataProvider()
|
||||
{
|
||||
return array(
|
||||
array(
|
||||
'CSV',
|
||||
array('"1","2"')
|
||||
),
|
||||
array(
|
||||
'SQL',
|
||||
array(
|
||||
"CREATE TABLE IF NOT EXISTS `test_table`",
|
||||
"INSERT INTO `test_table` (`id`, `val`) VALUES (1, 2);"
|
||||
)
|
||||
),
|
||||
array(
|
||||
'JSON',
|
||||
array('[{"id":"1","val":"2"}]')
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function that goes to the import page, uploads a file and submit form
|
||||
*
|
||||
* @param string $type level: server, db or import
|
||||
* @param string $plugin format: csv, json, etc
|
||||
*
|
||||
* @return string export string
|
||||
*/
|
||||
private function _doExport($type, $plugin)
|
||||
{
|
||||
$this->byLinkText("Export")->click();
|
||||
|
||||
$this->_helper->waitForElement("byName", "dump");
|
||||
$this->byCssSelector("label[for=radio_custom_export]")->click();
|
||||
|
||||
if ($type == 'server') {
|
||||
$this->byLinkText('Unselect All')->click();
|
||||
$this->byCssSelector("option[value=" . $this->_dbname . "]")->click();
|
||||
}
|
||||
|
||||
if ($type == 'table') {
|
||||
$this->byCssSelector("label[for=radio_allrows_0]")->click();
|
||||
$this->byName("limit_to")->clear();
|
||||
$this->byName("limit_to")->value("1");
|
||||
}
|
||||
|
||||
$this->select($this->byId("plugins"))->selectOptionByLabel($plugin);
|
||||
$this->byCssSelector("label[for=radio_view_as_text]")->click();
|
||||
|
||||
if ($plugin == "SQL") {
|
||||
$this->byCssSelector(
|
||||
"label[for=radio_sql_structure_or_data_structure_and_data]"
|
||||
)->click();
|
||||
|
||||
if ($type != "table") {
|
||||
$this->byCssSelector(
|
||||
"label[for=checkbox_sql_create_database]"
|
||||
)->click();
|
||||
}
|
||||
}
|
||||
|
||||
$this->byId("buttonGo")->click();
|
||||
|
||||
$text = $this->_helper->waitForElement("byId", "textSQLDUMP")->text();
|
||||
|
||||
return $text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tear Down function for test cases
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function tearDown()
|
||||
{
|
||||
$this->_helper->dbQuery('DROP DATABASE IF EXISTS ' . $this->_dbname);
|
||||
}
|
||||
|
||||
}
|
||||
164
test/selenium/PmaSeleniumServerSettingsTest.php
Normal file
164
test/selenium/PmaSeleniumServerSettingsTest.php
Normal file
@ -0,0 +1,164 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* Selenium TestCase for settings related tests
|
||||
*
|
||||
* @package PhpMyAdmin-test
|
||||
* @subpackage Selenium
|
||||
*/
|
||||
require_once 'Helper.php';
|
||||
|
||||
/**
|
||||
* PmaSeleniumServerSettingsTest class
|
||||
*
|
||||
* @package PhpMyAdmin-test
|
||||
* @subpackage Selenium
|
||||
*/
|
||||
class PmaSeleniumSettingsTest extends PHPUnit_Extensions_Selenium2TestCase
|
||||
{
|
||||
/**
|
||||
* Name of database for the test
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_dbname;
|
||||
|
||||
/**
|
||||
* Helper Object
|
||||
*
|
||||
* @var Helper
|
||||
*/
|
||||
private $_helper;
|
||||
|
||||
/**
|
||||
* Setup the browser environment to run the selenium test case
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
$this->_helper = new Helper($this);
|
||||
$this->setBrowser($this->_helper->getBrowserString());
|
||||
$this->setBrowserUrl(TESTSUITE_PHPMYADMIN_HOST . TESTSUITE_PHPMYADMIN_URL);
|
||||
$this->_helper->dbConnect();
|
||||
$this->_dbname = 'pma_db_' . time();
|
||||
$this->_helper->dbQuery('CREATE DATABASE ' . $this->_dbname);
|
||||
$this->_helper->dbQuery('USE ' . $this->_dbname);
|
||||
}
|
||||
|
||||
/**
|
||||
* setUp function that can use the selenium session (called before each test)
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setUpPage()
|
||||
{
|
||||
$this->_helper->login(TESTSUITE_USER, TESTSUITE_PASSWORD);
|
||||
$more = $this->byLinkText("More");
|
||||
$this->moveto($more);
|
||||
$this->_helper->waitForElement("byLinkText", "Settings")->click();
|
||||
$this->_helper->waitForElement(
|
||||
"byXPath", "//a[@class='tabactive' and contains(., 'Settings')]"
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests whether hiding a database works or not
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testHideDatabase()
|
||||
{
|
||||
$this->byLinkText("Features")->click();
|
||||
|
||||
$this->_helper->waitForElement("byId", "Servers-1-hide_db")
|
||||
->value($this->_dbname);
|
||||
$this->byName("submit_save")->click();
|
||||
$this->_helper->waitForElement(
|
||||
"byXPath",
|
||||
"//div[@class='success' and contains(., 'Configuration has been saved')]"
|
||||
);
|
||||
$this->assertFalse(
|
||||
$this->_helper->isElementPresent("byLinkText", $this->_dbname)
|
||||
);
|
||||
|
||||
$this->byCssSelector("a[href='#Servers-1-hide_db']")->click();
|
||||
$this->byName("submit_save")->click();
|
||||
$this->_helper->waitForElement(
|
||||
"byXPath",
|
||||
"//div[@class='success' and contains(., 'Configuration has been saved')]"
|
||||
);
|
||||
$this->assertTrue(
|
||||
$this->_helper->isElementPresent("byLinkText", $this->_dbname)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests whether the various settings tabs are displayed when clicked
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testSettingsTabsAreDisplayed()
|
||||
{
|
||||
$this->byLinkText("SQL queries")->click();
|
||||
$this->_helper->waitForElement('byClassName', 'tabs');
|
||||
|
||||
$this->byLinkText("SQL Query box")->click();
|
||||
$this->assertTrue(
|
||||
$this->byId("Sql_box")->displayed()
|
||||
);
|
||||
$this->assertFalse(
|
||||
$this->byId("Sql_queries")->displayed()
|
||||
);
|
||||
|
||||
$this->byCssSelector("a[href='#Sql_queries']")->click();
|
||||
$this->assertFalse(
|
||||
$this->byId("Sql_box")->displayed()
|
||||
);
|
||||
$this->assertTrue(
|
||||
$this->byId("Sql_queries")->displayed()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if hiding the logo works or not
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testHideLogo()
|
||||
{
|
||||
$this->byLinkText("Navigation panel")->click();
|
||||
|
||||
$this->_helper->waitForElement("byName", "NavigationDisplayLogo")
|
||||
->click();
|
||||
$this->byName("submit_save")->click();
|
||||
$this->_helper->waitForElement(
|
||||
"byXPath",
|
||||
"//div[@class='success' and contains(., 'Configuration has been saved')]"
|
||||
);
|
||||
$this->assertFalse(
|
||||
$this->_helper->isElementPresent("byId", "imgpmalogo")
|
||||
);
|
||||
|
||||
$this->byCssSelector("a[href='#NavigationDisplayLogo']")->click();
|
||||
$this->byName("submit_save")->click();
|
||||
$this->_helper->waitForElement(
|
||||
"byXPath",
|
||||
"//div[@class='success' and contains(., 'Configuration has been saved')]"
|
||||
);
|
||||
$this->assertTrue(
|
||||
$this->_helper->isElementPresent("byId", "imgpmalogo")
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tear Down function for test cases
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function tearDown()
|
||||
{
|
||||
$this->_helper->dbQuery('DROP DATABASE IF EXISTS ' . $this->_dbname);
|
||||
}
|
||||
|
||||
}
|
||||
@ -171,7 +171,7 @@ class PmaSeleniumTableBrowseTest extends PHPUnit_Extensions_Selenium2TestCase
|
||||
{
|
||||
$this->byCssSelector(
|
||||
"table#table_results tbody tr:nth-child(2) td:nth-child(2) a"
|
||||
)->click();
|
||||
)->click();
|
||||
$this->_helper->waitForElement("byId", "insertForm");
|
||||
|
||||
$this->assertEquals(
|
||||
@ -253,7 +253,7 @@ class PmaSeleniumTableBrowseTest extends PHPUnit_Extensions_Selenium2TestCase
|
||||
{
|
||||
$this->byCssSelector(
|
||||
"table#table_results tbody tr:nth-child(3) td:nth-child(3) a"
|
||||
)->click();
|
||||
)->click();
|
||||
|
||||
$this->_helper->waitForElement("byId", "insertForm");
|
||||
|
||||
|
||||
@ -146,7 +146,8 @@ class PmaSeleniumTableCreateTest extends PHPUnit_Extensions_Selenium2TestCase
|
||||
$this->assertFalse(
|
||||
$this->_helper->isElementPresent(
|
||||
'byCssSelector',
|
||||
'table#tablestructure tbody tr:nth-child(1) ul.table-structure-actions li.primary a'
|
||||
'table#tablestructure tbody tr:nth-child(1) "
|
||||
. "ul.table-structure-actions li.primary a'
|
||||
)
|
||||
);
|
||||
|
||||
@ -178,7 +179,8 @@ class PmaSeleniumTableCreateTest extends PHPUnit_Extensions_Selenium2TestCase
|
||||
|
||||
$this->assertFalse(
|
||||
$this->_helper->isElementPresent(
|
||||
'byCssSelector', 'css=ul.table-structure-actions:nth-child(2) li.primary a'
|
||||
'byCssSelector',
|
||||
'css=ul.table-structure-actions:nth-child(2) li.primary a'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@ -98,7 +98,7 @@ class PmaSeleniumTableInsertTest extends PHPUnit_Extensions_Selenium2TestCase
|
||||
// post
|
||||
$this->byCssSelector(
|
||||
"input[value=Go]"
|
||||
)->click();
|
||||
)->click();
|
||||
|
||||
$this->_helper->waitForElementNotPresent("byId", "loading_parent");
|
||||
$ele = $this->_helper->waitForElement("byClassName", "success");
|
||||
@ -106,6 +106,11 @@ class PmaSeleniumTableInsertTest extends PHPUnit_Extensions_Selenium2TestCase
|
||||
$this->_assertDataPresent();
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert various data present in results table
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function _assertDataPresent()
|
||||
{
|
||||
$this->byLinkText("Browse")->click();
|
||||
|
||||
@ -116,7 +116,8 @@ class PmaSeleniumTableOperationsTest extends PHPUnit_Extensions_Selenium2TestCas
|
||||
*/
|
||||
public function testMoveTable()
|
||||
{
|
||||
$this->byCssSelector("form#moveTableForm input[name='new_name']")->value("2");
|
||||
$this->byCssSelector("form#moveTableForm input[name='new_name']")
|
||||
->value("2");
|
||||
|
||||
$this->byXPath("(//input[@value='Go'])[2]")->click();
|
||||
|
||||
|
||||
@ -89,7 +89,8 @@ class PmaSeleniumTableStructureTest extends PHPUnit_Extensions_Selenium2TestCase
|
||||
|
||||
$this->_helper->waitForElement(
|
||||
"byXPath",
|
||||
"//div[@class='success' and contains(., 'Table test_table has been altered successfully')]"
|
||||
"//div[@class='success' and contains(., "
|
||||
. "'Table test_table has been altered successfully')]"
|
||||
);
|
||||
|
||||
$this->byLinkText("Structure")->click();
|
||||
@ -124,7 +125,8 @@ class PmaSeleniumTableStructureTest extends PHPUnit_Extensions_Selenium2TestCase
|
||||
|
||||
$this->_helper->waitForElement(
|
||||
"byXPath",
|
||||
"//div[@class='success' and contains(., 'Table test_table has been altered successfully')]"
|
||||
"//div[@class='success' and contains(., "
|
||||
. "'Table test_table has been altered successfully')]"
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
@ -142,16 +144,18 @@ class PmaSeleniumTableStructureTest extends PHPUnit_Extensions_Selenium2TestCase
|
||||
{
|
||||
$this->byCssSelector('label[for=checkbox_row_2]')->click();
|
||||
$this->byCssSelector('label[for=checkbox_row_3]')->click();
|
||||
$this->byXPath("//button[@class='mult_submit' and contains(., 'Drop')]")->click();
|
||||
$this->byXPath(
|
||||
"//button[@class='mult_submit' and contains(., 'Drop')]"
|
||||
)->click();
|
||||
|
||||
$this->_helper->waitForElement(
|
||||
"byCssSelector", "input[id='buttonYes']"
|
||||
)
|
||||
->click();
|
||||
)->click();
|
||||
|
||||
$this->_helper->waitForElement(
|
||||
"byXPath",
|
||||
"//div[@class='success' and contains(., 'Your SQL query has been executed successfully')]"
|
||||
"//div[@class='success' and contains(., "
|
||||
. "'Your SQL query has been executed successfully')]"
|
||||
);
|
||||
|
||||
$this->assertFalse(
|
||||
|
||||
Loading…
Reference in New Issue
Block a user