Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorMatthieu Napoli <matthieu@mnapoli.fr>2015-06-03 12:01:16 +0300
committerMatthieu Napoli <matthieu@mnapoli.fr>2015-06-03 12:01:16 +0300
commit9ae767cdebe17f5e5400724e11f8a96e472434db (patch)
tree94937b1f20bda5c31d6a7f93ceb2af113de4df43 /core
parent7e2a7293235d05e58c636d8c390dced81ec595e8 (diff)
parent02381cbd5c4ec8cf9e7e911258101e3395edacdd (diff)
Merge pull request #8008 from piwik/test_env_di_5
Injection Inception, Change #4: Using DI as primary mechanism in setting up Test environment
Diffstat (limited to 'core')
-rw-r--r--core/Application/Environment.php2
-rw-r--r--core/CliMulti.php2
-rw-r--r--core/Container/ContainerFactory.php22
-rw-r--r--core/Container/StaticContainer.php4
4 files changed, 18 insertions, 12 deletions
diff --git a/core/Application/Environment.php b/core/Application/Environment.php
index 854410df8c..edd60180d5 100644
--- a/core/Application/Environment.php
+++ b/core/Application/Environment.php
@@ -112,7 +112,7 @@ class Environment
{
$pluginList = $this->getPluginListCached();
$settings = $this->getGlobalSettingsCached();
- $definitions = array_merge(StaticContainer::getDefinitions(), $this->definitions);
+ $definitions = array_merge(StaticContainer::getDefinitions(), array($this->definitions));
$containerFactory = new ContainerFactory($pluginList, $settings, $this->environment, $definitions);
return $containerFactory->create();
diff --git a/core/CliMulti.php b/core/CliMulti.php
index bd310dcddc..790fd6c67b 100644
--- a/core/CliMulti.php
+++ b/core/CliMulti.php
@@ -307,7 +307,7 @@ class CliMulti
private function appendTestmodeParamToUrlIfNeeded($url)
{
- $isTestMode = class_exists('Piwik_TestingEnvironment');
+ $isTestMode = class_exists('Piwik\Tests\Framework\TestingEnvironment');
if ($isTestMode && false === strpos($url, '?')) {
$url .= "?testmode=1";
diff --git a/core/Container/ContainerFactory.php b/core/Container/ContainerFactory.php
index 0c36e3ba82..7b6cb7f506 100644
--- a/core/Container/ContainerFactory.php
+++ b/core/Container/ContainerFactory.php
@@ -13,7 +13,6 @@ use DI\ContainerBuilder;
use Doctrine\Common\Cache\ArrayCache;
use Piwik\Application\Kernel\GlobalSettingsProvider;
use Piwik\Application\Kernel\PluginList;
-use Piwik\Development;
use Piwik\Plugin\Manager;
/**
@@ -39,7 +38,7 @@ class ContainerFactory
private $environment;
/**
- * @var array
+ * @var array[]
*/
private $definitions;
@@ -47,7 +46,7 @@ class ContainerFactory
* @param PluginList $pluginList
* @param GlobalSettingsProvider $settings
* @param string|null $environment Optional environment config to load.
- * @param array $definitions
+ * @param array[] $definitions
*/
public function __construct(PluginList $pluginList, GlobalSettingsProvider $settings, $environment = null, array $definitions = array())
{
@@ -89,10 +88,17 @@ class ContainerFactory
}
// Environment config
- $this->addEnvironmentConfig($builder);
+ $this->addEnvironmentConfig($builder, $this->environment);
+
+ // Test config
+ if (defined('PIWIK_TEST_MODE')) {
+ $this->addEnvironmentConfig($builder, 'test');
+ }
if (!empty($this->definitions)) {
- $builder->addDefinitions($this->definitions);
+ foreach ($this->definitions as $definitionArray) {
+ $builder->addDefinitions($definitionArray);
+ }
}
$container = $builder->build();
@@ -102,13 +108,13 @@ class ContainerFactory
return $container;
}
- private function addEnvironmentConfig(ContainerBuilder $builder)
+ private function addEnvironmentConfig(ContainerBuilder $builder, $environment)
{
- if (!$this->environment) {
+ if (!$environment) {
return;
}
- $file = sprintf('%s/config/environment/%s.php', PIWIK_USER_PATH, $this->environment);
+ $file = sprintf('%s/config/environment/%s.php', PIWIK_USER_PATH, $environment);
if (file_exists($file)) {
$builder->addDefinitions($file);
diff --git a/core/Container/StaticContainer.php b/core/Container/StaticContainer.php
index fca87c04b7..ce3cd2bdc5 100644
--- a/core/Container/StaticContainer.php
+++ b/core/Container/StaticContainer.php
@@ -27,7 +27,7 @@ class StaticContainer
/**
* Definitions to register in the container.
*
- * @var array
+ * @var array[]
*/
private static $definitions = array();
@@ -60,7 +60,7 @@ class StaticContainer
public static function addDefinitions(array $definitions)
{
- self::$definitions = $definitions;
+ self::$definitions[] = $definitions;
}
/**