diff options
author | William Desportes <williamdes@wdes.fr> | 2020-06-09 01:46:13 +0300 |
---|---|---|
committer | William Desportes <williamdes@wdes.fr> | 2020-06-10 02:27:22 +0300 |
commit | b52e878bbb6542ffe770ae0454ed6feea13ce2f2 (patch) | |
tree | 9e07e0bb6d1302e230fae6d1f91c3d604e9f8ba7 /test/selenium | |
parent | b41d94b73cd62fe1af6698fd137b0dba1be55e8f (diff) |
Make database creation optional for some selenium tests
Signed-off-by: William Desportes <williamdes@wdes.fr>
Diffstat (limited to 'test/selenium')
-rw-r--r-- | test/selenium/TestBase.php | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/test/selenium/TestBase.php b/test/selenium/TestBase.php index 679f13f726..9ac551ad88 100644 --- a/test/selenium/TestBase.php +++ b/test/selenium/TestBase.php @@ -90,6 +90,13 @@ abstract class TestBase extends TestCase private const SESSION_REST_URL = 'https://api.browserstack.com/automate/sessions/'; /** + * Create a test database for this test class + * + * @var bool + */ + protected static $createDatabase = true; + + /** * Configures the selenium and database link. * * @throws Exception @@ -130,10 +137,14 @@ abstract class TestBase extends TestCase $this->sessionId = $this->webDriver->getSessionId(); - $this->database_name = $this->getDbPrefix() . mb_substr(sha1((string) rand()), 0, 7); - $this->navigateTo(''); $this->webDriver->manage()->window()->maximize(); + + if (! static::$createDatabase) { + return; + } + + $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 . '`;' ); @@ -1089,7 +1100,9 @@ abstract class TestBase extends TestCase */ protected function tearDown(): void { - $this->dbQuery('DROP DATABASE IF EXISTS `' . $this->database_name . '`;'); + if (static::$createDatabase) { + $this->dbQuery('DROP DATABASE IF EXISTS `' . $this->database_name . '`;'); + } if (! $this->hasFailed()) { $this->markTestAs('passed', ''); } |