diff options
author | Kate Butler <kate@innocraft.com> | 2019-08-05 05:45:17 +0300 |
---|---|---|
committer | Thomas Steur <tsteur@users.noreply.github.com> | 2019-08-05 05:45:17 +0300 |
commit | 2aa7c822b17e62dfde9fd2cd4c608e5a6e71d439 (patch) | |
tree | c38a76f863901bb1f9855b2effe1c045b4ef9ded /plugins | |
parent | 6a6af0cb53322e93aa5f3c633aeff2a19454629b (diff) |
Prevent test fixture setup/teardown from touching non-test database (#14729)
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/TestRunner/Commands/TestsRun.php | 4 | ||||
-rw-r--r-- | plugins/TestRunner/Commands/TestsSetupFixture.php | 4 |
2 files changed, 8 insertions, 0 deletions
diff --git a/plugins/TestRunner/Commands/TestsRun.php b/plugins/TestRunner/Commands/TestsRun.php index 9e25a61174..cd04ab945c 100644 --- a/plugins/TestRunner/Commands/TestsRun.php +++ b/plugins/TestRunner/Commands/TestsRun.php @@ -9,6 +9,7 @@ namespace Piwik\Plugins\TestRunner\Commands; +use Piwik\Db; use Piwik\Plugin; use Piwik\Profiler; use Piwik\Plugin\ConsoleCommand; @@ -117,6 +118,9 @@ class TestsRun extends ConsoleCommand } } + // Tear down any DB that already exists + Db::destroyDatabaseObject(); + $this->executeTests($matomoDomain, $suite, $testFile, $groups, $options, $command, $output, $enableLogging); return $this->returnVar; diff --git a/plugins/TestRunner/Commands/TestsSetupFixture.php b/plugins/TestRunner/Commands/TestsSetupFixture.php index 4321234f93..1df6f47bb7 100644 --- a/plugins/TestRunner/Commands/TestsSetupFixture.php +++ b/plugins/TestRunner/Commands/TestsSetupFixture.php @@ -108,9 +108,13 @@ class TestsSetupFixture extends ConsoleCommand $_SERVER = json_decode($serverGlobal, true); } + // Tear down any DB that already exists + Db::destroyDatabaseObject(); + if(Config::getInstance()->database_tests['tables_prefix'] !== '') { throw new \Exception("To generate OmniFixture for the UI tests, you must set an empty tables_prefix in [database_tests]"); } + $this->requireFixtureFiles($input); $this->setIncludePathAsInTestBootstrap(); |