diff options
author | diosmosis <benaka@piwik.pro> | 2015-06-02 01:42:01 +0300 |
---|---|---|
committer | diosmosis <benaka@piwik.pro> | 2015-06-05 23:37:08 +0300 |
commit | 65d4c301d922c77039de3533778678acbd4eaabb (patch) | |
tree | 83433c37ad5be34729989ff15fce82d3f66b6fa0 /tests/PHPUnit/Framework/TestingEnvironmentManipulator.php | |
parent | 52bed8ed6fd9240f476a7bf8c739b4d7eabfc9ff (diff) |
Move Environment.bootstrapped event observer in test.php DI config file to TestingEnvironmentManipulator.
Diffstat (limited to 'tests/PHPUnit/Framework/TestingEnvironmentManipulator.php')
-rw-r--r-- | tests/PHPUnit/Framework/TestingEnvironmentManipulator.php | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/tests/PHPUnit/Framework/TestingEnvironmentManipulator.php b/tests/PHPUnit/Framework/TestingEnvironmentManipulator.php index c94f6bc06d..22c940b0a7 100644 --- a/tests/PHPUnit/Framework/TestingEnvironmentManipulator.php +++ b/tests/PHPUnit/Framework/TestingEnvironmentManipulator.php @@ -10,6 +10,8 @@ namespace Piwik\Tests\Framework; use Piwik\Application\EnvironmentManipulator; use Piwik\Application\Kernel\GlobalSettingsProvider; +use Piwik\DbHelper; +use Piwik\Option; /** * Manipulates an environment for tests. @@ -59,6 +61,40 @@ class TestingEnvironmentManipulator implements EnvironmentManipulator \Piwik\Cache\Backend\File::$invalidateOpCacheBeforeRead = true; } + public function onEnvironmentBootstrapped() + { + $this->vars->executeSetupTestEnvHook(); + + if (empty($_GET['ignoreClearAllViewDataTableParameters'])) { // TODO: should use testingEnvironment variable, not query param + try { + \Piwik\ViewDataTable\Manager::clearAllViewDataTableParameters(); + } catch (\Exception $ex) { + // ignore (in case DB is not setup) + } + } + + if ($this->vars->optionsOverride) { + try { + foreach ($this->vars->optionsOverride as $name => $value) { + Option::set($name, $value); + } + } catch (\Exception $ex) { + // ignore (in case DB is not setup) + } + } + + \Piwik\Plugins\CoreVisualizations\Visualizations\Cloud::$debugDisableShuffle = true; + \Piwik\Visualization\Sparkline::$enableSparklineImages = false; + \Piwik\Plugins\ExampleUI\API::$disableRandomness = true; + + if ($this->vars->deleteArchiveTables + && !$this->vars->_archivingTablesDeleted + ) { + $this->vars->_archivingTablesDeleted = true; + DbHelper::deleteArchiveTables(); + } + } + public function getExtraDefinitions() { // Apply DI config from the fixture @@ -89,7 +125,7 @@ class TestingEnvironmentManipulator implements EnvironmentManipulator return array( $diConfig, - array('observers.global' => \DI\add($this->globalObservers)) + array('observers.global' => \DI\add($this->globalObservers)), ); } }
\ No newline at end of file |