Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
weblate committed Feb 18, 2014
2 parents 8b33f4a + 528fba0 commit d5fa103
Show file tree
Hide file tree
Showing 5 changed files with 135 additions and 98 deletions.
11 changes: 0 additions & 11 deletions test/README

This file was deleted.

47 changes: 47 additions & 0 deletions test/README.rst
@@ -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 changes: 7 additions & 12 deletions test/bootstrap-dist.php
Expand Up @@ -19,24 +19,19 @@
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);
Expand Down
18 changes: 0 additions & 18 deletions test/selenium/README

This file was deleted.

138 changes: 81 additions & 57 deletions test/selenium/TestBase.php
Expand Up @@ -31,82 +31,102 @@ 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
*
* @return Array of browsers to test
*/
public static function browsers()
{
$username = getenv('BS_UNAME');
$key = getenv('BS_KEY');
if (! $username || ! $key) {
return array();
}
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');
}
$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();
$result[] = array(
'browserName' => 'firefox',
'browserName' => 'chrome',
'host' => 'hub.browserstack.com',
'port' => 80,
'timeout' => 30000,
'desiredCapabilities' => array(
'browserstack.user' => BS_UNAME,
'browserstack.key' => BS_KEY,
'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' => 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',
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();
}
return $result;
}

/**
Expand All @@ -116,10 +136,14 @@ public static function browsers()
*/
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
);
Expand Down

0 comments on commit d5fa103

Please sign in to comment.