Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
d5fa103b19
11
test/README
11
test/README
@ -1,11 +0,0 @@
|
||||
PhpMyAdmin test suite
|
||||
=====================
|
||||
|
||||
This directory is protected from web visitors by a .htaccess file.
|
||||
|
||||
For more information on allowing http access to this directory see:
|
||||
http://httpd.apache.org/docs/current/mod/mod_authz_host.html#allow
|
||||
|
||||
Please visit the wiki for more information on unit testing:
|
||||
https://wiki.phpmyadmin.net/pma/UnitTesting
|
||||
|
||||
47
test/README.rst
Normal file
47
test/README.rst
Normal file
@ -0,0 +1,47 @@
|
||||
PhpMyAdmin test suite
|
||||
=====================
|
||||
|
||||
This directory is protected from web visitors by a .htaccess file.
|
||||
|
||||
For more information on allowing http access to this directory see:
|
||||
http://httpd.apache.org/docs/current/mod/mod_authz_host.html#allow
|
||||
|
||||
Please visit the wiki for more information on unit testing:
|
||||
https://wiki.phpmyadmin.net/pma/UnitTesting
|
||||
|
||||
Selenium tests
|
||||
--------------
|
||||
|
||||
To be able to run Selenium tests, you need to have webserver, database
|
||||
and Selenium running. Following environment variables configure where
|
||||
testsuite connects:
|
||||
|
||||
TESTSUITE_SERVER
|
||||
Database server to use.
|
||||
TESTSUITE_USER
|
||||
Username for connecting to database.
|
||||
TESTSUITE_PASSWORD
|
||||
Password for connecting to database.
|
||||
TESTSUITE_DATABASE
|
||||
Database to use for testing.
|
||||
TESTSUITE_URL
|
||||
URL where tested phpMyAdmin is available.
|
||||
|
||||
Additionally you need to configure link to Selenium and browsers. You
|
||||
can either setup Selenium locally or use BrowserStack automated testing.
|
||||
|
||||
For local setup, define following:
|
||||
|
||||
TESTSUITE_SELENIUM_HOST
|
||||
Host where Selenium is running.
|
||||
TESTSUITE_SELENIUM_PORT
|
||||
Port where to connect.
|
||||
TESTSUITE_SELENIUM_BROWSER
|
||||
Browser to use for testing inside Selenium.
|
||||
|
||||
With BrowserStack, set following:
|
||||
|
||||
TESTSUITE_BROWSERSTACK_UNAME
|
||||
BrowserStack username.
|
||||
TESTSUITE_BROWSERSTACK_KEY
|
||||
BrowserStack access key.
|
||||
@ -19,24 +19,19 @@ define('PHPMYADMIN', 1);
|
||||
define('TESTSUITE', 1);
|
||||
define('PMA_MYSQL_INT_VERSION', 55000);
|
||||
|
||||
// BrowserStack integration
|
||||
$bs_uname = getenv('BS_UNAME');
|
||||
$bs_key = getenv('BS_KEY');
|
||||
|
||||
if ($bs_uname && $bs_key) {
|
||||
define('PHPUNIT_HOST', $bs_uname . ":" . $bs_key . "@hub.browserstack.com:80");
|
||||
} else {
|
||||
define('PHPUNIT_HOST', "127.0.0.1");
|
||||
}
|
||||
|
||||
// Selenium tests setup
|
||||
$test_defaults = array(
|
||||
'TESTSUITE_SERVER' => 'localhost',
|
||||
'TESTSUITE_USER' => 'root',
|
||||
'TESTSUITE_PASSWORD' => '',
|
||||
'TESTSUITE_DATABASE' => 'test',
|
||||
'TESTSUITE_PHPMYADMIN_HOST' => 'http://localhost',
|
||||
'TESTSUITE_PHPMYADMIN_URL' => '/phpmyadmin',
|
||||
'TESTSUITE_URL' => 'http://localhost/phpmyadmin/',
|
||||
'TESTSUITE_SELENIUM_HOST' => '',
|
||||
'TESTSUITE_SELENIUM_PORT' => '4444',
|
||||
'TESTSUITE_SELENIUM_BROWSER' => 'firefox',
|
||||
'TESTSUITE_BROWSERSTACK_USER' => '',
|
||||
'TESTSUITE_BROWSERSTACK_KEY' => '',
|
||||
'TESTSUITE_FULL' => '',
|
||||
);
|
||||
foreach ($test_defaults as $varname => $defvalue) {
|
||||
$envvar = getenv($varname);
|
||||
|
||||
@ -1,18 +0,0 @@
|
||||
Guide to run the AllSeleniumTests.php (Yasitha Pandithawatta)
|
||||
=============================================================
|
||||
|
||||
1. Tested with version 4.0
|
||||
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"/>
|
||||
<const name="TESTSUITE_PASSWORD" value="root"/>
|
||||
<const name="TESTSUITE_DATABASE" value="test"/>
|
||||
<const name="TESTSUITE_PHPMYADMIN_HOST" value="http://localhost" />
|
||||
<const name="TESTSUITE_PHPMYADMIN_URL" value="/phpmyadmin-dev" />
|
||||
</php>
|
||||
3. Start the selenium server
|
||||
4. Run $ phpunit test/AllSeleniumTests.php
|
||||
|
||||
Note: Only PmaSeleniumLoginTest.php is fixed and added to the test suit.
|
||||
@ -31,6 +31,14 @@ abstract class PMA_SeleniumBase extends PHPUnit_Extensions_Selenium2TestCase
|
||||
*/
|
||||
public $database_name;
|
||||
|
||||
/**
|
||||
* Whether Selenium testing should be enabled.
|
||||
*
|
||||
* @access private
|
||||
* @var boolean
|
||||
*/
|
||||
private $_selenium_enabled = False;
|
||||
|
||||
/**
|
||||
* Lists browsers to test
|
||||
*
|
||||
@ -38,75 +46,87 @@ abstract class PMA_SeleniumBase extends PHPUnit_Extensions_Selenium2TestCase
|
||||
*/
|
||||
public static function browsers()
|
||||
{
|
||||
$username = getenv('BS_UNAME');
|
||||
$key = getenv('BS_KEY');
|
||||
if (! $username || ! $key) {
|
||||
if (! empty(TESTSUITE_BROWSERSTACK_USER)
|
||||
&& ! empty(TESTSUITE_BROWSERSTACK_KEY)
|
||||
) {
|
||||
/* BrowserStack integration */
|
||||
self::$_selenium_enabled = True;
|
||||
|
||||
$build_id = 'Manual';
|
||||
if (getenv('BUILD_TAG')) {
|
||||
$build_id = getenv('BUILD_TAG');
|
||||
} elseif (getenv('TRAVIS_JOB_NUMBER')) {
|
||||
$build_id = 'travis-' . getenv('TRAVIS_JOB_NUMBER');
|
||||
}
|
||||
|
||||
$result = array();
|
||||
$result[] = array(
|
||||
'browserName' => 'chrome',
|
||||
'host' => 'hub.browserstack.com',
|
||||
'port' => 80,
|
||||
'timeout' => 30000,
|
||||
'desiredCapabilities' => array(
|
||||
'browserstack.user' => TESTSUITE_BROWSERSTACK_USER,
|
||||
'browserstack.key' => TESTSUITE_BROWSERSTACK_KEY,
|
||||
'project' => 'phpMyAdmin',
|
||||
'build' => $build_id,
|
||||
)
|
||||
);
|
||||
if (!empty(TESTSUITE_FULL)) {
|
||||
$result[] = array(
|
||||
'browserName' => 'firefox',
|
||||
'host' => 'hub.browserstack.com',
|
||||
'port' => 80,
|
||||
'timeout' => 30000,
|
||||
'desiredCapabilities' => array(
|
||||
'browserstack.user' => TESTSUITE_BROWSERSTACK_USER,
|
||||
'browserstack.key' => TESTSUITE_BROWSERSTACK_KEY,
|
||||
'project' => 'phpMyAdmin',
|
||||
'build' => $build_id,
|
||||
)
|
||||
);
|
||||
$result[] = array(
|
||||
'browserName' => 'internet explorer',
|
||||
'host' => 'hub.browserstack.com',
|
||||
'port' => 80,
|
||||
'timeout' => 30000,
|
||||
'desiredCapabilities' => array(
|
||||
'browserstack.user' => TESTSUITE_BROWSERSTACK_USER,
|
||||
'browserstack.key' => TESTSUITE_BROWSERSTACK_KEY,
|
||||
'project' => 'phpMyAdmin',
|
||||
'build' => $build_id,
|
||||
'os' => 'windows',
|
||||
'os_version' => '7',
|
||||
)
|
||||
);
|
||||
$result[] = array(
|
||||
'browserName' => 'Safari',
|
||||
'host' => 'hub.browserstack.com',
|
||||
'port' => 80,
|
||||
'timeout' => 30000,
|
||||
'desiredCapabilities' => array(
|
||||
'browserstack.user' => TESTSUITE_BROWSERSTACK_USER,
|
||||
'browserstack.key' => TESTSUITE_BROWSERSTACK_KEY,
|
||||
'project' => 'phpMyAdmin',
|
||||
'build' => $build_id,
|
||||
'os' => 'OS X',
|
||||
'os_version' => 'Mavericks',
|
||||
)
|
||||
);
|
||||
}
|
||||
return $result;
|
||||
} elseif (! empty(TESTSUITE_SELENIUM_HOST)) {
|
||||
self::$_selenium_enabled = True;
|
||||
return array(
|
||||
array(
|
||||
'browserName' => TESTSUITE_SELENIUM_BROWSER,
|
||||
'host' => TESTSUITE_SELENIUM_HOST,
|
||||
'port' => TESTSUITE_SELENIUM_PORT,
|
||||
)
|
||||
);
|
||||
} else {
|
||||
return array();
|
||||
}
|
||||
|
||||
$build_id = 'Manual';
|
||||
if (getenv('BUILD_TAG')) {
|
||||
$build_id = getenv('BUILD_TAG');
|
||||
} elseif (getenv('TRAVIS_JOB_NUMBER')) {
|
||||
$build_id = 'travis-' . getenv('TRAVIS_JOB_NUMBER');
|
||||
}
|
||||
|
||||
$result = array();
|
||||
$result[] = array(
|
||||
'browserName' => 'chrome',
|
||||
'host' => 'hub.browserstack.com',
|
||||
'port' => 80,
|
||||
'timeout' => 30000,
|
||||
'desiredCapabilities' => array(
|
||||
'browserstack.user' => BS_UNAME,
|
||||
'browserstack.key' => BS_KEY,
|
||||
'project' => 'phpMyAdmin',
|
||||
'build' => $build_id,
|
||||
)
|
||||
);
|
||||
if (getenv('TESTSUITE_FULL')) {
|
||||
$result[] = array(
|
||||
'browserName' => 'firefox',
|
||||
'host' => 'hub.browserstack.com',
|
||||
'port' => 80,
|
||||
'timeout' => 30000,
|
||||
'desiredCapabilities' => array(
|
||||
'browserstack.user' => BS_UNAME,
|
||||
'browserstack.key' => BS_KEY,
|
||||
'project' => 'phpMyAdmin',
|
||||
'build' => $build_id,
|
||||
)
|
||||
);
|
||||
$result[] = array(
|
||||
'browserName' => 'internet explorer',
|
||||
'host' => 'hub.browserstack.com',
|
||||
'port' => 80,
|
||||
'timeout' => 30000,
|
||||
'desiredCapabilities' => array(
|
||||
'browserstack.user' => BS_UNAME,
|
||||
'browserstack.key' => BS_KEY,
|
||||
'project' => 'phpMyAdmin',
|
||||
'build' => $build_id,
|
||||
'os' => 'windows',
|
||||
'os_version' => '7',
|
||||
)
|
||||
);
|
||||
$result[] = array(
|
||||
'browserName' => 'Safari',
|
||||
'host' => 'hub.browserstack.com',
|
||||
'port' => 80,
|
||||
'timeout' => 30000,
|
||||
'desiredCapabilities' => array(
|
||||
'browserstack.user' => BS_UNAME,
|
||||
'browserstack.key' => BS_KEY,
|
||||
'project' => 'phpMyAdmin',
|
||||
'build' => $build_id,
|
||||
'os' => 'OS X',
|
||||
'os_version' => 'Mavericks',
|
||||
)
|
||||
);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -116,10 +136,14 @@ abstract class PMA_SeleniumBase extends PHPUnit_Extensions_Selenium2TestCase
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
if (! $this->_selenium_enabled) {
|
||||
$this->markTestSkipped('Selenium testing not configured.');
|
||||
}
|
||||
|
||||
parent::setUp();
|
||||
$this->setBrowserUrl(TESTSUITE_PHPMYADMIN_HOST . TESTSUITE_PHPMYADMIN_URL);
|
||||
$this->setBrowserUrl(TESTSUITE_URL);
|
||||
$this->_mysqli = new mysqli(
|
||||
"localhost",
|
||||
TESTSUITE_SERVER,
|
||||
TESTSUITE_USER,
|
||||
TESTSUITE_PASSWORD
|
||||
);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user