Skip to content

Commit

Permalink
Create the test database on demand
Browse files Browse the repository at this point in the history
Signed-off-by: William Desportes <williamdes@wdes.fr>
  • Loading branch information
williamdes committed Jun 9, 2020
1 parent cad5086 commit 016d04d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions test/selenium/ServerSettingsTest.php
Expand Up @@ -70,6 +70,7 @@ private function saveConfig()
*/
public function testHideDatabase()
{
$this->createDatabase();
$this->byPartialLinkText('Features')->click();
$this->waitAjax();

Expand Down
10 changes: 10 additions & 0 deletions test/selenium/TestBase.php
Expand Up @@ -141,13 +141,23 @@ protected function setUp(): void
$this->webDriver->manage()->window()->maximize();

if (! static::$createDatabase) {
// Stop here, we where not asked to create a database
return;
}

$this->createDatabase();
}

/**
* Create a test database
*/
protected function createDatabase(): void
{
$this->database_name = $this->getDbPrefix() . mb_substr(sha1((string) rand()), 0, 7);
$this->dbQuery(
'CREATE DATABASE IF NOT EXISTS `' . $this->database_name . '`; USE `' . $this->database_name . '`;'
);
static::$createDatabase = true;
}

public function getDbPrefix(): string
Expand Down

0 comments on commit 016d04d

Please sign in to comment.