diff --git a/plugins/CoreConsole/Commands/SetupFixture.php b/plugins/CoreConsole/Commands/SetupFixture.php index 91f79d0d1bdd96305ee671df1afb50b000a086f8..9ff1f8967663ebd3b8ccef22b553920bfe773b1e 100644 --- a/plugins/CoreConsole/Commands/SetupFixture.php +++ b/plugins/CoreConsole/Commands/SetupFixture.php @@ -53,6 +53,8 @@ class SetupFixture extends ConsoleCommand "Used by UI tests. Creates symlinks to root directory in tests/PHPUnit/proxy."); $this->addOption('server-global', null, InputOption::VALUE_REQUIRED, "Used by UI tests. Sets the \$_SERVER global variable from a JSON string."); + $this->addOption('plugins', null, InputOption::VALUE_REQUIRED, + "Used by UI tests. Comma separated list of plugin names to activate and install when setting up a fixture."); } protected function execute(InputInterface $input, OutputInterface $output) @@ -108,6 +110,11 @@ class SetupFixture extends ConsoleCommand $fixture->resetPersistedFixture = true; } + $extraPluginsToLoad = $input->getOption('plugins'); + if ($extraPluginsToLoad) { + $fixture->extraPluginsToLoad = explode(',', $extraPluginsToLoad); + } + if($fixture->createConfig) { Config::getInstance()->setTestEnvironment(); } diff --git a/tests/PHPUnit/Fixture.php b/tests/PHPUnit/Fixture.php index f651dd1d75797e6b154fa534e404b7d264b31110..a2fa0258e27dcdc0f3aaca9846a975d112ba74bf 100644 --- a/tests/PHPUnit/Fixture.php +++ b/tests/PHPUnit/Fixture.php @@ -68,6 +68,7 @@ class Fixture extends PHPUnit_Framework_Assert public $printToScreen = false; public $testCaseClass = false; + public $extraPluginsToLoad = array(); public $testEnvironment = null; @@ -175,7 +176,7 @@ class Fixture extends PHPUnit_Framework_Assert Cache::deleteTrackerCache(); - static::loadAllPlugins($this->getTestEnvironment(), $this->testCaseClass); + static::loadAllPlugins($this->getTestEnvironment(), $this->testCaseClass, $this->extraPluginsToLoad); $_GET = $_REQUEST = array(); $_SERVER['HTTP_REFERER'] = ''; @@ -267,7 +268,7 @@ class Fixture extends PHPUnit_Framework_Assert Translate::unloadEnglishTranslation(); } - public static function loadAllPlugins($testEnvironment = null, $testCaseClass = false) + public static function loadAllPlugins($testEnvironment = null, $testCaseClass = false, $extraPluginsToLoad = array()) { DbHelper::createTables(); $pluginsManager = \Piwik\Plugin\Manager::getInstance(); @@ -275,10 +276,10 @@ class Fixture extends PHPUnit_Framework_Assert $plugins = $pluginsManager->getPluginsToLoadDuringTests(); // make sure the plugin that executed this method is included in the plugins to load - $extraPlugins = array( + $extraPlugins = array_merge($extraPluginsToLoad, array( \Piwik\Plugin::getPluginNameFromBacktrace(debug_backtrace()), \Piwik\Plugin::getPluginNameFromNamespace($testCaseClass) - ); + )); foreach ($extraPlugins as $pluginName) { if (empty($pluginName)) { continue; diff --git a/tests/lib/screenshot-testing/support/test-environment.js b/tests/lib/screenshot-testing/support/test-environment.js index 4527b868d44c11b99d8fe7a5e3406cd89dc7bf67..36807dac8908059f97547f56e611af4541fa14c0 100644 --- a/tests/lib/screenshot-testing/support/test-environment.js +++ b/tests/lib/screenshot-testing/support/test-environment.js @@ -144,6 +144,10 @@ TestingEnvironment.prototype.setupFixture = function (fixtureClass, done) { droppedOnce = true; } + if (options['plugin']) { + args.push('--plugins=' + options['plugin']); + } + var self = this; this.executeConsoleCommand('tests:setup-fixture', args, function (code) { self.reload();