diff options
author | William Desportes <williamdes@wdes.fr> | 2020-06-09 10:21:18 +0300 |
---|---|---|
committer | William Desportes <williamdes@wdes.fr> | 2020-06-10 02:27:22 +0300 |
commit | 016d04d4679bc4645d22570b6dfe31a3d8d3a8ef (patch) | |
tree | a7c8c8497c635cd2c765c70baa8e3ceb263d5fc1 /test/selenium | |
parent | cad508602d79a70d75582b729465a2086918728a (diff) |
Create the test database on demand
Signed-off-by: William Desportes <williamdes@wdes.fr>
Diffstat (limited to 'test/selenium')
-rw-r--r-- | test/selenium/ServerSettingsTest.php | 1 | ||||
-rw-r--r-- | test/selenium/TestBase.php | 10 |
2 files changed, 11 insertions, 0 deletions
diff --git a/test/selenium/ServerSettingsTest.php b/test/selenium/ServerSettingsTest.php index dc65fc81cc..210a7afd9b 100644 --- a/test/selenium/ServerSettingsTest.php +++ b/test/selenium/ServerSettingsTest.php @@ -70,6 +70,7 @@ class ServerSettingsTest extends TestBase */ public function testHideDatabase() { + $this->createDatabase(); $this->byPartialLinkText('Features')->click(); $this->waitAjax(); diff --git a/test/selenium/TestBase.php b/test/selenium/TestBase.php index 9ac551ad88..acbd9ae4cc 100644 --- a/test/selenium/TestBase.php +++ b/test/selenium/TestBase.php @@ -141,13 +141,23 @@ abstract class TestBase extends TestCase $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 |