Merge Helper and PmaSeleniumTestCase classes
This commit is contained in:
parent
fc7e7e6cbc
commit
0c0538b99d
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* Selenium Helper class for selenium test cases
|
||||
* Selenium helper class for TestCases
|
||||
*
|
||||
* @package PhpMyAdmin-test
|
||||
* @subpackage Selenium
|
||||
@ -9,7 +9,7 @@
|
||||
require_once 'TestConfig.php';
|
||||
|
||||
/**
|
||||
* Selenium Helper Class
|
||||
* Helper class
|
||||
*
|
||||
* @package PhpMyAdmin-test
|
||||
* @subpackage Selenium
|
||||
@ -17,43 +17,193 @@ require_once 'TestConfig.php';
|
||||
class Helper
|
||||
{
|
||||
/**
|
||||
* SeleniumTestSuite instance
|
||||
* Username of the user
|
||||
*
|
||||
* @var object
|
||||
* @access private
|
||||
* @var string
|
||||
*/
|
||||
public static $selenium;
|
||||
private $_txtUsername;
|
||||
|
||||
/**
|
||||
* TestConfig instance
|
||||
* Password for the user
|
||||
*
|
||||
* @var object TestConfig
|
||||
* @access private
|
||||
* @var string
|
||||
*/
|
||||
public static $config;
|
||||
private $_txtPassword;
|
||||
|
||||
/**
|
||||
* id of the login button
|
||||
*
|
||||
* @access private
|
||||
* @var string
|
||||
*/
|
||||
private $_btnLogin;
|
||||
|
||||
/**
|
||||
* Selenium Context
|
||||
*
|
||||
* @access private
|
||||
* @var object
|
||||
*/
|
||||
private $_selenium;
|
||||
|
||||
/**
|
||||
* Configuration Instance
|
||||
*
|
||||
* @access private
|
||||
* @var object
|
||||
*/
|
||||
private $_config;
|
||||
|
||||
/**
|
||||
* mysqli object
|
||||
*
|
||||
* @access private
|
||||
* @var object
|
||||
*/
|
||||
private $_mysqli;
|
||||
|
||||
/**
|
||||
* constructor
|
||||
*
|
||||
* @param object $selenium Selenium Context
|
||||
*/
|
||||
function __construct()
|
||||
public function __construct($selenium)
|
||||
{
|
||||
self::$config = new TestConfig();
|
||||
$this->_txtUsername = 'input_username';
|
||||
$this->_txtPassword = 'input_password';
|
||||
$this->_btnLogin = 'input_go';
|
||||
$this->_config = new TestConfig();
|
||||
$this->_selenium = $selenium;
|
||||
$this->_mysqli = null;
|
||||
}
|
||||
|
||||
public static function isLoggedIn($selenium)
|
||||
/**
|
||||
* perform a login
|
||||
*
|
||||
* @param string $username Username
|
||||
* @param string $password Password
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function login($username, $password)
|
||||
{
|
||||
return $selenium->isElementPresent('//*[@id="serverinfo"]/a[1]');
|
||||
$this->_selenium->open($this->_config->getLoginURL());
|
||||
$this->_selenium->type($this->_txtUsername, $username);
|
||||
$this->_selenium->type($this->_txtPassword, $password);
|
||||
$this->_selenium->clickAndWait($this->_btnLogin);
|
||||
//$this->_selenium->waitForPageToLoad($this->_config->getTimeoutValue());
|
||||
}
|
||||
|
||||
public static function logOutIfLoggedIn($selenium)
|
||||
/**
|
||||
* Checks whether the login is successful
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isSuccessLogin()
|
||||
{
|
||||
if (self::isLoggedIn($selenium)) {
|
||||
$selenium->clickAndWait("css=img.icon.ic_s_loggoff");
|
||||
if ($this->_selenium->isElementPresent("//*[@id=\"serverinfo\"]")) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static function getBrowserString()
|
||||
/**
|
||||
* Checks whether the login is unsuccessful
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isUnsuccessLogin()
|
||||
{
|
||||
$browserString = self::$config->getCurrentBrowser();
|
||||
if ($this->_selenium->isElementPresent("css=div.error")) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to go to the homepage
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function gotoHomepage()
|
||||
{
|
||||
$this->_selenium->click("css=div#serverinfo a:contains('Server:')");
|
||||
$this->_selenium->waitForElementNotPresent('css=div#loading_parent');
|
||||
}
|
||||
|
||||
/**
|
||||
* Establishes a connection with the local database
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function dbConnect()
|
||||
{
|
||||
if ($this->_mysqli === null) {
|
||||
list($user, $pass) = $this->_config->getDBCredentials();
|
||||
|
||||
$this->_mysqli = new mysqli(
|
||||
"localhost", $user, $pass
|
||||
);
|
||||
|
||||
if ($this->_mysqli->connect_errno) {
|
||||
throw new Exception(
|
||||
'Failed to connect to MySQL (' . $this->_mysqli->error . ')'
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes a database query
|
||||
*
|
||||
* @param string $query SQL Query to be executed
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function dbQuery($query)
|
||||
{
|
||||
if ($this->_mysqli === null) {
|
||||
throw new Exception(
|
||||
'MySQL not connected'
|
||||
);
|
||||
}
|
||||
$this->_mysqli->query($query);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if user is logged in to phpmyadmin
|
||||
*
|
||||
* @return boolean Where or not user is logged in
|
||||
*/
|
||||
public function isLoggedIn()
|
||||
{
|
||||
return $this->_selenium->isElementPresent('//*[@id="serverinfo"]/a[1]');
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform a logout, if logged in
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function logOutIfLoggedIn()
|
||||
{
|
||||
if ($this->isLoggedIn()) {
|
||||
$this->_selenium->clickAndWait("css=img.icon.ic_s_loggoff");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current browser string
|
||||
*
|
||||
* @return string Browser String
|
||||
*/
|
||||
public function getBrowserString()
|
||||
{
|
||||
$browserString = $this->_config->getCurrentBrowser();
|
||||
return $browserString;
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,7 +6,6 @@
|
||||
* @package PhpMyAdmin-test
|
||||
* @subpackage Selenium
|
||||
*/
|
||||
require_once 'PmaSeleniumTestCase.php';
|
||||
require_once 'Helper.php';
|
||||
|
||||
/**
|
||||
@ -25,11 +24,11 @@ class PmaSeleniumCreateDropDatabaseTest extends PHPUnit_Extensions_SeleniumTestC
|
||||
private $_dbname;
|
||||
|
||||
/**
|
||||
* PmaSeleniumTestCase Object
|
||||
* Helper Object
|
||||
*
|
||||
* @var obj
|
||||
*/
|
||||
private $_seleniumTasks;
|
||||
private $_helper;
|
||||
|
||||
/**
|
||||
* Setup the browser environment to run the selenium test case
|
||||
@ -38,10 +37,10 @@ class PmaSeleniumCreateDropDatabaseTest extends PHPUnit_Extensions_SeleniumTestC
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
$helper = new Helper();
|
||||
$this->setBrowser(Helper::getBrowserString());
|
||||
$this->_helper = new Helper($this);
|
||||
$this->setBrowser($this->_helper->getBrowserString());
|
||||
$this->setBrowserUrl(TESTSUITE_PHPMYADMIN_HOST . TESTSUITE_PHPMYADMIN_URL);
|
||||
$this->_seleniumTasks = new PmaSeleniumTestCase($this);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -52,7 +51,7 @@ class PmaSeleniumCreateDropDatabaseTest extends PHPUnit_Extensions_SeleniumTestC
|
||||
public function testCreateDropDatabase()
|
||||
{
|
||||
$this->_dbname = 'pma_testdb' . time();
|
||||
$this->_seleniumTasks->login(TESTSUITE_USER, TESTSUITE_PASSWORD);
|
||||
$this->_helper->login(TESTSUITE_USER, TESTSUITE_PASSWORD);
|
||||
$this->click("link=Databases");
|
||||
$this->waitForElementPresent("id=text_create_db");
|
||||
$this->type("id=text_create_db", $this->_dbname);
|
||||
@ -69,7 +68,7 @@ class PmaSeleniumCreateDropDatabaseTest extends PHPUnit_Extensions_SeleniumTestC
|
||||
*/
|
||||
private function _dropDatabase()
|
||||
{
|
||||
$this->_seleniumTasks->gotoHomepage();
|
||||
$this->_helper->gotoHomepage();
|
||||
$this->click("css=ul#topmenu a:contains('Databases')");
|
||||
$this->waitForElementNotPresent('css=div#loading_parent');
|
||||
$this->click(
|
||||
|
||||
@ -6,7 +6,6 @@
|
||||
* @package PhpMyAdmin-test
|
||||
* @subpackage Selenium
|
||||
*/
|
||||
require_once 'PmaSeleniumTestCase.php';
|
||||
require_once 'Helper.php';
|
||||
|
||||
/**
|
||||
@ -17,6 +16,13 @@ require_once 'Helper.php';
|
||||
*/
|
||||
class PmaSeleniumLoginTest extends PHPUnit_Extensions_SeleniumTestCase
|
||||
{
|
||||
/**
|
||||
* Helper Object
|
||||
*
|
||||
* @var obj
|
||||
*/
|
||||
private $_helper;
|
||||
|
||||
/**
|
||||
* Setup the browser environment to run the selenium test case
|
||||
*
|
||||
@ -24,8 +30,8 @@ class PmaSeleniumLoginTest extends PHPUnit_Extensions_SeleniumTestCase
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
$helper = new Helper();
|
||||
$this->setBrowser(Helper::getBrowserString());
|
||||
$this->_helper = new Helper($this);
|
||||
$this->setBrowser($this->_helper->getBrowserString());
|
||||
$this->setBrowserUrl(TESTSUITE_PHPMYADMIN_HOST . TESTSUITE_PHPMYADMIN_URL);
|
||||
}
|
||||
|
||||
@ -36,10 +42,9 @@ class PmaSeleniumLoginTest extends PHPUnit_Extensions_SeleniumTestCase
|
||||
*/
|
||||
public function testSuccessfulLogin()
|
||||
{
|
||||
$log = new PmaSeleniumTestCase($this);
|
||||
$log->login(TESTSUITE_USER, TESTSUITE_PASSWORD);
|
||||
$this->assertTrue($log->isSuccessLogin());
|
||||
Helper::logOutIfLoggedIn($this);
|
||||
$this->_helper->login(TESTSUITE_USER, TESTSUITE_PASSWORD);
|
||||
$this->assertTrue($this->_helper->isSuccessLogin());
|
||||
$this->_helper->logOutIfLoggedIn();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -49,10 +54,9 @@ class PmaSeleniumLoginTest extends PHPUnit_Extensions_SeleniumTestCase
|
||||
*/
|
||||
public function testLoginWithWrongPassword()
|
||||
{
|
||||
$log = new PmaSeleniumTestCase($this);
|
||||
$log->login("Admin", "Admin");
|
||||
$this->assertTrue($log->isUnsuccessLogin());
|
||||
Helper::logOutIfLoggedIn($this);
|
||||
$this->_helper->login("Admin", "Admin");
|
||||
$this->assertTrue($this->_helper->isUnsuccessLogin());
|
||||
$this->_helper->logOutIfLoggedIn();
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
@ -7,7 +7,6 @@
|
||||
* @subpackage Selenium
|
||||
*/
|
||||
|
||||
require_once 'PmaSeleniumTestCase.php';
|
||||
require_once 'Helper.php';
|
||||
|
||||
/**
|
||||
@ -18,6 +17,13 @@ require_once 'Helper.php';
|
||||
*/
|
||||
class PmaSeleniumPrivilegesTest extends PHPUnit_Extensions_SeleniumTestCase
|
||||
{
|
||||
/**
|
||||
* Helper Object
|
||||
*
|
||||
* @var obj
|
||||
*/
|
||||
private $_helper;
|
||||
|
||||
/**
|
||||
* Setup the browser environment to run the selenium test case
|
||||
*
|
||||
@ -25,8 +31,8 @@ class PmaSeleniumPrivilegesTest extends PHPUnit_Extensions_SeleniumTestCase
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
$helper = new Helper();
|
||||
$this->setBrowser(Helper::getBrowserString());
|
||||
$this->_helper = new Helper($this);
|
||||
$this->setBrowser($this->_helper->getBrowserString());
|
||||
$this->setBrowserUrl(TESTSUITE_PHPMYADMIN_HOST . TESTSUITE_PHPMYADMIN_URL);
|
||||
}
|
||||
|
||||
@ -37,8 +43,7 @@ class PmaSeleniumPrivilegesTest extends PHPUnit_Extensions_SeleniumTestCase
|
||||
*/
|
||||
public function testChangePassword()
|
||||
{
|
||||
$log = new PmaSeleniumTestCase($this);
|
||||
$log->login(TESTSUITE_USER, TESTSUITE_PASSWORD);
|
||||
$this->_helper->login(TESTSUITE_USER, TESTSUITE_PASSWORD);
|
||||
$this->click("link=Change password");
|
||||
$this->waitForElementPresent("id=change_password_anchor");
|
||||
try {
|
||||
|
||||
@ -6,7 +6,6 @@
|
||||
* @package PhpMyAdmin-test
|
||||
* @subpackage Selenium
|
||||
*/
|
||||
require_once 'PmaSeleniumTestCase.php';
|
||||
require_once 'Helper.php';
|
||||
|
||||
/**
|
||||
@ -25,11 +24,11 @@ class PmaSeleniumTablesInsertDataTest extends PHPUnit_Extensions_SeleniumTestCas
|
||||
private $_dbname;
|
||||
|
||||
/**
|
||||
* PmaSeleniumTestCase Object
|
||||
* Helper Object
|
||||
*
|
||||
* @var obj
|
||||
*/
|
||||
private $_seleniumTasks;
|
||||
private $_helper;
|
||||
|
||||
/**
|
||||
* Setup the browser environment to run the selenium test case
|
||||
@ -38,16 +37,15 @@ class PmaSeleniumTablesInsertDataTest extends PHPUnit_Extensions_SeleniumTestCas
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
$helper = new Helper();
|
||||
$this->setBrowser(Helper::getBrowserString());
|
||||
$this->_helper = new Helper($this);
|
||||
$this->setBrowser($this->_helper->getBrowserString());
|
||||
$this->setBrowserUrl(TESTSUITE_PHPMYADMIN_HOST . TESTSUITE_PHPMYADMIN_URL);
|
||||
$this->start();
|
||||
$this->_seleniumTasks = new PmaSeleniumTestCase($this);
|
||||
$this->_seleniumTasks->dbConnect();
|
||||
$this->_helper->dbConnect();
|
||||
$this->_dbname = 'pma_db_' . time();
|
||||
$this->_seleniumTasks->dbQuery('CREATE DATABASE ' . $this->_dbname);
|
||||
$this->_seleniumTasks->dbQuery('USE ' . $this->_dbname);
|
||||
$this->_seleniumTasks->dbQuery(
|
||||
$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,"
|
||||
. " `name` varchar(20) NOT NULL,"
|
||||
@ -55,7 +53,7 @@ class PmaSeleniumTablesInsertDataTest extends PHPUnit_Extensions_SeleniumTestCas
|
||||
. " PRIMARY KEY (`id`)"
|
||||
. ")"
|
||||
);
|
||||
$this->_seleniumTasks->login(TESTSUITE_USER, TESTSUITE_PASSWORD);
|
||||
$this->_helper->login(TESTSUITE_USER, TESTSUITE_PASSWORD);
|
||||
$this->click('link='. $this->_dbname.'');
|
||||
$this->waitForElementPresent("link=test_table");
|
||||
}
|
||||
@ -142,8 +140,14 @@ class PmaSeleniumTablesInsertDataTest extends PHPUnit_Extensions_SeleniumTestCas
|
||||
$this->getTable("table_results.3.6")
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tear Down function for test cases
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function tearDown()
|
||||
{
|
||||
$this->_seleniumTasks->dbQuery('DROP DATABASE ' . $this->_dbname);
|
||||
$this->_helper->dbQuery('DROP DATABASE ' . $this->_dbname);
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,7 +6,6 @@
|
||||
* @package PhpMyAdmin-test
|
||||
* @subpackage Selenium
|
||||
*/
|
||||
require_once 'PmaSeleniumTestCase.php';
|
||||
require_once 'Helper.php';
|
||||
|
||||
/**
|
||||
@ -25,11 +24,11 @@ class PmaSeleniumTablesTest extends PHPUnit_Extensions_SeleniumTestCase
|
||||
private $_dbname;
|
||||
|
||||
/**
|
||||
* PmaSeleniumTestCase Object
|
||||
* Helper Object
|
||||
*
|
||||
* @var obj
|
||||
*/
|
||||
private $_seleniumTasks;
|
||||
private $_helper;
|
||||
|
||||
/**
|
||||
* Setup the browser environment to run the selenium test case
|
||||
@ -38,13 +37,12 @@ class PmaSeleniumTablesTest extends PHPUnit_Extensions_SeleniumTestCase
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
$helper = new Helper();
|
||||
$this->setBrowser(Helper::getBrowserString());
|
||||
$this->_helper = new Helper($this);
|
||||
$this->setBrowser($this->_helper->getBrowserString());
|
||||
$this->setBrowserUrl(TESTSUITE_PHPMYADMIN_HOST . TESTSUITE_PHPMYADMIN_URL);
|
||||
$this->_seleniumTasks = new PmaSeleniumTestCase($this);
|
||||
$this->_seleniumTasks->dbConnect();
|
||||
$this->_helper->dbConnect();
|
||||
$this->_dbname = 'pma_db_' . time();
|
||||
$this->_seleniumTasks->dbQuery('CREATE DATABASE ' . $this->_dbname);
|
||||
$this->_helper->dbQuery('CREATE DATABASE ' . $this->_dbname);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -54,7 +52,7 @@ class PmaSeleniumTablesTest extends PHPUnit_Extensions_SeleniumTestCase
|
||||
*/
|
||||
public function testCreateTable()
|
||||
{
|
||||
$this->_seleniumTasks->login(TESTSUITE_USER, TESTSUITE_PASSWORD);
|
||||
$this->_helper->login(TESTSUITE_USER, TESTSUITE_PASSWORD);
|
||||
$this->click('link='. $this->_dbname.'');
|
||||
$this->waitForElementPresent('id=create_table_form_minimal');
|
||||
$this->type(
|
||||
@ -179,8 +177,13 @@ class PmaSeleniumTablesTest extends PHPUnit_Extensions_SeleniumTestCase
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tear down functions for test cases
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function tearDown()
|
||||
{
|
||||
$this->_seleniumTasks->dbQuery('DROP DATABASE ' . $this->_dbname);
|
||||
$this->_helper->dbQuery('DROP DATABASE ' . $this->_dbname);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,176 +0,0 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* Selenium parent class for TestCases
|
||||
*
|
||||
* @package PhpMyAdmin-test
|
||||
* @subpackage Selenium
|
||||
*/
|
||||
|
||||
/**
|
||||
* PmaSeleniumTestCase class
|
||||
*
|
||||
* @package PhpMyAdmin-test
|
||||
* @subpackage Selenium
|
||||
*/
|
||||
class PmaSeleniumTestCase
|
||||
{
|
||||
/**
|
||||
* Username of the user
|
||||
*
|
||||
* @access private
|
||||
* @var string
|
||||
*/
|
||||
private $_txtUsername;
|
||||
|
||||
/**
|
||||
* Password for the user
|
||||
*
|
||||
* @access private
|
||||
* @var string
|
||||
*/
|
||||
private $_txtPassword;
|
||||
|
||||
/**
|
||||
* id of the login button
|
||||
*
|
||||
* @access private
|
||||
* @var string
|
||||
*/
|
||||
private $_btnLogin;
|
||||
|
||||
/**
|
||||
* Selenium Context
|
||||
*
|
||||
* @access private
|
||||
* @var object
|
||||
*/
|
||||
private $_selenium;
|
||||
|
||||
/**
|
||||
* Configuration Instance
|
||||
*
|
||||
* @access private
|
||||
* @var object
|
||||
*/
|
||||
private $_config;
|
||||
|
||||
/**
|
||||
* mysqli object
|
||||
*
|
||||
* @access private
|
||||
* @var object
|
||||
*/
|
||||
private $_mysqli;
|
||||
|
||||
/**
|
||||
* constructor
|
||||
*
|
||||
* @param object $selenium Selenium Context
|
||||
*/
|
||||
public function __construct($selenium)
|
||||
{
|
||||
$this->_txtUsername = 'input_username';
|
||||
$this->_txtPassword = 'input_password';
|
||||
$this->_btnLogin = 'input_go';
|
||||
$this->_config = new TestConfig();
|
||||
$this->_selenium = $selenium;
|
||||
$this->_mysqli = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* perform a login
|
||||
*
|
||||
* @param string $username Username
|
||||
* @param string $password Password
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
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->clickAndWait($this->_btnLogin);
|
||||
//$this->_selenium->waitForPageToLoad($this->_config->getTimeoutValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the login is successful
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isSuccessLogin()
|
||||
{
|
||||
if ($this->_selenium->isElementPresent("//*[@id=\"serverinfo\"]")) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the login is unsuccessful
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isUnsuccessLogin()
|
||||
{
|
||||
if ($this->_selenium->isElementPresent("css=div.error")) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to go to the homepage
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function gotoHomepage()
|
||||
{
|
||||
$this->_selenium->click("css=div#serverinfo a:contains('Server:')");
|
||||
$this->_selenium->waitForElementNotPresent('css=div#loading_parent');
|
||||
}
|
||||
|
||||
/**
|
||||
* Establishes a connection with the local database
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function dbConnect()
|
||||
{
|
||||
if ($this->_mysqli === null) {
|
||||
list($user, $pass) = $this->_config->getDBCredentials();
|
||||
|
||||
$this->_mysqli = new mysqli(
|
||||
"localhost", $user, $pass
|
||||
);
|
||||
|
||||
if ($this->_mysqli->connect_errno) {
|
||||
throw new Exception(
|
||||
'Failed to connect to MySQL (' . $this->_mysqli->error . ')'
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes a database query
|
||||
*
|
||||
* @param string $query SQL Query to be executed
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function dbQuery($query)
|
||||
{
|
||||
if ($this->_mysqli === null) {
|
||||
throw new Exception(
|
||||
'MySQL not connected'
|
||||
);
|
||||
}
|
||||
$this->_mysqli->query($query);
|
||||
}
|
||||
}
|
||||
?>
|
||||
@ -7,7 +7,6 @@
|
||||
* @subpackage Selenium
|
||||
*/
|
||||
|
||||
require_once 'PmaSeleniumTestCase.php';
|
||||
require_once 'Helper.php';
|
||||
|
||||
/**
|
||||
@ -18,6 +17,13 @@ require_once 'Helper.php';
|
||||
*/
|
||||
class PmaSeleniumXSSTest extends PHPUnit_Extensions_SeleniumTestCase
|
||||
{
|
||||
/**
|
||||
* Helper Object
|
||||
*
|
||||
* @var obj
|
||||
*/
|
||||
private $_helper;
|
||||
|
||||
/**
|
||||
* Setup the browser environment to run the selenium test case
|
||||
*
|
||||
@ -25,8 +31,8 @@ class PmaSeleniumXSSTest extends PHPUnit_Extensions_SeleniumTestCase
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
$helper = new Helper();
|
||||
$this->setBrowser(Helper::getBrowserString());
|
||||
$this->_helper = new Helper($this);
|
||||
$this->setBrowser($this->_helper->getBrowserString());
|
||||
$this->setBrowserUrl(
|
||||
TESTSUITE_PHPMYADMIN_HOST . TESTSUITE_PHPMYADMIN_URL
|
||||
);
|
||||
@ -39,8 +45,7 @@ class PmaSeleniumXSSTest extends PHPUnit_Extensions_SeleniumTestCase
|
||||
*/
|
||||
public function testQueryTabWithNullValue()
|
||||
{
|
||||
$log = new PmaSeleniumTestCase($this);
|
||||
$log->login(TESTSUITE_USER, TESTSUITE_PASSWORD);
|
||||
$this->_helper->login(TESTSUITE_USER, TESTSUITE_PASSWORD);
|
||||
$this->click("link=SQL");
|
||||
$this->waitForElementPresent("id=queryboxf");
|
||||
$this->click("button_submit_query");
|
||||
|
||||
Loading…
Reference in New Issue
Block a user