Skip to content

Commit

Permalink
Dev: Default to database username/password root/empty in installation…
Browse files Browse the repository at this point in the history
… test
  • Loading branch information
olleharstedt committed Dec 12, 2017
1 parent 26139a4 commit 8266c46
Showing 1 changed file with 24 additions and 20 deletions.
44 changes: 24 additions & 20 deletions tests/controllers/InstallationControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,8 @@ class InstallationControllerTest extends TestBaseClassWeb
public static function setupBeforeClass()
{
parent::setUpBeforeClass();

if (empty(getenv('DBPASSWORD'))) {
self::assertTrue(
false,
'Must specify DBPASSWORD environment variable to run this test'
);
}

if (empty(getenv('DBUSER'))) {
self::assertTrue(
false,
'Must specify DBUSER environment variable to run this test'
);
}
}

/**
*
*/
Expand All @@ -55,6 +42,17 @@ public function testBasic()
$password = 'password';
}

$dbuser = getenv('DBUSER');
if (!$dbuser) {
$dbuser = 'root';
echo 'Default to database user "root".' . PHP_EOL;
}
$dbpwd = getenv('DBPASSWORD');
if (!$dbpwd) {
$dbpwd = '';
echo 'Default to empty database password.' . PHP_EOL;
}

if (file_exists($configFile)) {
// Delete possible previous database.
try {
Expand Down Expand Up @@ -95,12 +93,12 @@ public function testBasic()
$next->click();

// Fill in database form.
$dbuser = self::$webDriver->findElement(WebDriverBy::cssSelector('input[name="InstallerConfigForm[dbuser]"]'));
$dbpwd = self::$webDriver->findElement(WebDriverBy::cssSelector('input[name="InstallerConfigForm[dbpwd]"]'));
$dbname = self::$webDriver->findElement(WebDriverBy::cssSelector('input[name="InstallerConfigForm[dbname]"]'));
$dbuser->sendKeys(getenv('DBUSER'));
$dbpwd->sendKeys(getenv('DBPASSWORD'));
$dbname->sendKeys($databaseName);
$dbuserInput = self::$webDriver->findElement(WebDriverBy::cssSelector('input[name="InstallerConfigForm[dbuser]"]'));
$dbpwdInput = self::$webDriver->findElement(WebDriverBy::cssSelector('input[name="InstallerConfigForm[dbpwd]"]'));
$dbnameInput = self::$webDriver->findElement(WebDriverBy::cssSelector('input[name="InstallerConfigForm[dbname]"]'));
$dbuserInput->clear()->sendKeys($dbuser);
$dbpwdInput->clear()->sendKeys($dbpwd);
$dbnameInput->sendKeys($databaseName);

// Click next.
$next = self::$webDriver->findElement(WebDriverBy::id('ls-next'));
Expand Down Expand Up @@ -130,6 +128,12 @@ public function testBasic()
$button = self::$webDriver->findElement(WebDriverBy::id('ls-administration'));
$button->click();

// Reset urlManager to adapt to latest config.
$configFile = \Yii::app()->getBasePath() . '/config/config.php';
$config = require($configFile);
$urlMan = \Yii::app()->urlManager;
$urlMan->setUrlFormat($config['components']['urlManager']['urlFormat']);

// Login.
self::adminLogin($username, $password);

Expand Down

0 comments on commit 8266c46

Please sign in to comment.