Skip to content

Commit

Permalink
Move defining envs to defineTestingGlobals
Browse files Browse the repository at this point in the history
Signed-off-by: William Desportes <williamdes@wdes.fr>
  • Loading branch information
williamdes committed May 21, 2020
1 parent fe32a35 commit 3a49cb3
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 28 deletions.
28 changes: 0 additions & 28 deletions test/bootstrap-dist.php
Expand Up @@ -41,34 +41,6 @@
}
// phpcs:enable

// Selenium tests setup
$test_defaults = [
'TESTSUITE_SERVER' => 'localhost',
'TESTSUITE_USER' => 'root',
'TESTSUITE_PASSWORD' => '',
'TESTSUITE_DATABASE' => 'test',
'TESTSUITE_PORT' => 3306,
'TESTSUITE_URL' => 'http://localhost/phpmyadmin/',
'TESTSUITE_SELENIUM_HOST' => '',
'TESTSUITE_SELENIUM_PORT' => '4444',
'TESTSUITE_SELENIUM_BROWSER' => 'firefox',
'TESTSUITE_SELENIUM_COVERAGE' => '',
'TESTSUITE_BROWSERSTACK_USER' => '',
'TESTSUITE_BROWSERSTACK_KEY' => '',
'TESTSUITE_FULL' => '',
'CI_MODE' => '',
];
if (PHP_SAPI == 'cli') {
foreach ($test_defaults as $varname => $defvalue) {
$envvar = getenv($varname);
if ($envvar) {
$GLOBALS[$varname] = $envvar;
} else {
$GLOBALS[$varname] = $defvalue;
}
}
}

require_once ROOT_PATH . 'libraries/vendor_config.php';
require_once AUTOLOAD_FILE;
Loader::loadFunctions();
Expand Down
31 changes: 31 additions & 0 deletions test/classes/AbstractTestCase.php
Expand Up @@ -137,6 +137,37 @@ protected function defineVersionConstants(): void
// phpcs:enable
}

public static function defineTestingGlobals(): void
{
// Selenium tests setup
$test_defaults = [
'TESTSUITE_SERVER' => 'localhost',
'TESTSUITE_USER' => 'root',
'TESTSUITE_PASSWORD' => '',
'TESTSUITE_DATABASE' => 'test',
'TESTSUITE_PORT' => 3306,
'TESTSUITE_URL' => 'http://localhost/phpmyadmin/',
'TESTSUITE_SELENIUM_HOST' => '',
'TESTSUITE_SELENIUM_PORT' => '4444',
'TESTSUITE_SELENIUM_BROWSER' => 'firefox',
'TESTSUITE_SELENIUM_COVERAGE' => '',
'TESTSUITE_BROWSERSTACK_USER' => '',
'TESTSUITE_BROWSERSTACK_KEY' => '',
'TESTSUITE_FULL' => '',
'CI_MODE' => '',
];
if (PHP_SAPI == 'cli') {
foreach ($test_defaults as $varname => $defvalue) {
$envvar = getenv($varname);
if ($envvar) {
$GLOBALS[$varname] = $envvar;
} else {
$GLOBALS[$varname] = $defvalue;
}
}
}
}

/**
* Desctroys the environment built for the test.
* Clean all variables
Expand Down
1 change: 1 addition & 0 deletions test/classes/EnvironmentTest.php
Expand Up @@ -39,6 +39,7 @@ public function testPhpVersion()
*/
public function testMySQL()
{
AbstractTestCase::defineTestingGlobals();
try {
$pdo = new PDO(
'mysql:host=' . $GLOBALS['TESTSUITE_SERVER'] . ';port=' . $GLOBALS['TESTSUITE_PORT'],
Expand Down
2 changes: 2 additions & 0 deletions test/selenium/TestBase.php
Expand Up @@ -21,6 +21,7 @@
use InvalidArgumentException;
use mysqli;
use mysqli_result;
use PhpMyAdmin\Tests\AbstractTestCase;
use PHPUnit\Framework\TestCase;
use Throwable;
use const CURLOPT_CUSTOMREQUEST;
Expand Down Expand Up @@ -93,6 +94,7 @@ abstract class TestBase extends TestCase
*/
protected function setUp(): void
{
AbstractTestCase::defineTestingGlobals();
/**
* Needs to be implemented
*
Expand Down

0 comments on commit 3a49cb3

Please sign in to comment.