diff options
author | Thomas Steur <thomas.steur@gmail.com> | 2014-06-18 04:04:56 +0400 |
---|---|---|
committer | Thomas Steur <thomas.steur@gmail.com> | 2014-06-18 04:04:56 +0400 |
commit | 69b4a70048ea681bc62bca79abe7c763f2233a60 (patch) | |
tree | 070b876a73f9402664f624e73de74ed4165518f5 /tests/PHPUnit/Fixture.php | |
parent | 031a2de96a2a3ec3f5f395977ee6c0c822b119b3 (diff) | |
parent | 02ffeeb228f88d6053edf777d094b34c47b086b4 (diff) |
Merge remote-tracking branch 'origin/master' into report_and_dimension_refactoring
Conflicts:
core/Tracker/Settings.php
core/Tracker/Visit.php
plugins/Actions/Widgets.php
plugins/CustomVariables/Widgets.php
plugins/DevicesDetection/DevicesDetection.php
plugins/DevicesDetection/Widgets.php
plugins/Events/Widgets.php
plugins/Provider/Widgets.php
plugins/UserCountry/Widgets.php
plugins/UserSettings/Widgets.php
plugins/VisitTime/Widgets.php
plugins/VisitorInterest/Widgets.php
Diffstat (limited to 'tests/PHPUnit/Fixture.php')
-rw-r--r-- | tests/PHPUnit/Fixture.php | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/tests/PHPUnit/Fixture.php b/tests/PHPUnit/Fixture.php index 3c1651757b..f651dd1d75 100644 --- a/tests/PHPUnit/Fixture.php +++ b/tests/PHPUnit/Fixture.php @@ -67,6 +67,8 @@ class Fixture extends PHPUnit_Framework_Assert public $resetPersistedFixture = false; public $printToScreen = false; + public $testCaseClass = false; + public $testEnvironment = null; /** @@ -173,7 +175,7 @@ class Fixture extends PHPUnit_Framework_Assert Cache::deleteTrackerCache(); - static::loadAllPlugins(); + static::loadAllPlugins($this->getTestEnvironment(), $this->testCaseClass); $_GET = $_REQUEST = array(); $_SERVER['HTTP_REFERER'] = ''; @@ -265,11 +267,31 @@ class Fixture extends PHPUnit_Framework_Assert Translate::unloadEnglishTranslation(); } - public static function loadAllPlugins() + public static function loadAllPlugins($testEnvironment = null, $testCaseClass = false) { DbHelper::createTables(); $pluginsManager = \Piwik\Plugin\Manager::getInstance(); + $plugins = $pluginsManager->getPluginsToLoadDuringTests(); + + // make sure the plugin that executed this method is included in the plugins to load + $extraPlugins = array( + \Piwik\Plugin::getPluginNameFromBacktrace(debug_backtrace()), + \Piwik\Plugin::getPluginNameFromNamespace($testCaseClass) + ); + foreach ($extraPlugins as $pluginName) { + if (empty($pluginName)) { + continue; + } + + $plugins[] = $pluginName; + if ($testEnvironment) { + $testEnvironment->pluginsToLoad = array_merge($testEnvironment->pluginsToLoad ?: array(), array($pluginName)); + } + } + + Log::info("Plugins to load during tests: " . implode(', ', $plugins)); + $pluginsManager->loadPlugins($plugins); // Install plugins @@ -722,7 +744,7 @@ class Fixture extends PHPUnit_Framework_Assert public function dropDatabase($dbName = null) { - $dbName = $dbName ?: $this->dbName; + $dbName = $dbName ?: $this->dbName ?: Config::getInstance()->database_tests['dbname']; $this->log("Dropping database '$dbName'..."); |