Skip to content
Extraits de code Groupes Projets
Valider 16f3355c rédigé par diosmosis's avatar diosmosis
Parcourir les fichiers

Move TestingEnvironment::arrayMergeRecursiveDistinct() to TestConfig since that's where it is used.

parent 5e8641bd
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -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');
......
......@@ -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
......@@ -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
*/
......
......@@ -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));
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter