diff --git a/config/environment/test.php b/config/environment/test.php index 6ff1e10982e69db8dc8a39f63f8d3a0ee1794b7e..205945db674eb53056b9d192224e1e5e7945e590 100644 --- a/config/environment/test.php +++ b/config/environment/test.php @@ -19,8 +19,14 @@ return array( 'cache.eager.cache_id' => 'eagercache-test-', // Disable loading core translations - 'Piwik\Translation\Translator' => DI\object() - ->constructorParameter('directories', array()), + 'Piwik\Translation\Translator' => DI\decorate(function ($previous, ContainerInterface $c) { + $testingEnvironment = $c->get('Piwik\Tests\Framework\TestingEnvironment'); + if (!$testingEnvironment->loadRealTranslations) { + return new \Piwik\Translation\Translator($c->get('Piwik\Translation\Loader\LoaderInterface'), $directories = array()); + } else { + return $previous; + } + }), 'Piwik\Config' => DI\decorate(function ($previous, ContainerInterface $c) { $testingEnvironment = $c->get('Piwik\Tests\Framework\TestingEnvironment'); diff --git a/tests/PHPUnit/Framework/Mock/TestConfig.php b/tests/PHPUnit/Framework/Mock/TestConfig.php index 49e252dedcc8e85dca11ce772066cc4c3e06231a..7509100c55d1abdcbe4f18619755a8d5560595ca 100644 --- a/tests/PHPUnit/Framework/Mock/TestConfig.php +++ b/tests/PHPUnit/Framework/Mock/TestConfig.php @@ -108,7 +108,24 @@ class TestConfig extends Config if ($testingEnvironment->configOverride) { $cache =& $chain->getAll(); - $cache = $testingEnvironment->arrayMergeRecursiveDistinct($cache, $testingEnvironment->configOverride); + $cache = $this->arrayMergeRecursiveDistinct($cache, $testingEnvironment->configOverride); } } + + private function arrayMergeRecursiveDistinct(array $array1, array $array2) + { + $result = $array1; + + foreach ($array2 as $key => $value) { + if (is_array($value)) { + $result[$key] = isset($result[$key]) && is_array($result[$key]) + ? $this->arrayMergeRecursiveDistinct($result[$key], $value) + : $value; + } else { + $result[$key] = $value; + } + } + + return $result; + } } \ No newline at end of file diff --git a/tests/PHPUnit/Framework/TestingEnvironment.php b/tests/PHPUnit/Framework/TestingEnvironment.php index c176d49607d22bbdad6cb5858c9a8963ebec81eb..ff4a3b88421661ac9762e1df013828a4a9970403 100644 --- a/tests/PHPUnit/Framework/TestingEnvironment.php +++ b/tests/PHPUnit/Framework/TestingEnvironment.php @@ -184,23 +184,6 @@ class TestingEnvironment StaticContainer::addDefinitions($diConfig); } - public function arrayMergeRecursiveDistinct(array $array1, array $array2) - { - $result = $array1; - - foreach ($array2 as $key => $value) { - if (is_array($value)) { - $result[$key] = isset($result[$key]) && is_array($result[$key]) - ? $this->arrayMergeRecursiveDistinct($result[$key], $value) - : $value; - } else { - $result[$key] = $value; - } - } - - return $result; - } - /** * for plugins that need to inject special testing logic */ diff --git a/tests/lib/screenshot-testing/support/test-environment.js b/tests/lib/screenshot-testing/support/test-environment.js index 4eb8319fc993456b9f5888ca915b040f2527877c..2753db3cbe3eb7fde5930edb6dc435c168aef17f 100644 --- a/tests/lib/screenshot-testing/support/test-environment.js +++ b/tests/lib/screenshot-testing/support/test-environment.js @@ -21,6 +21,7 @@ TestingEnvironment.prototype.reload = function () { this['useOverrideCss'] = true; this['useOverrideJs'] = true; + this['loadRealTranslations'] = true; // UI tests should test w/ real translations, not translation keys if (fs.exists(testingEnvironmentOverridePath)) { var data = JSON.parse(fs.read(testingEnvironmentOverridePath));