diff --git a/core/Console.php b/core/Console.php
index 5a3ff2f54150e0fdd93eb15912a1f4728ddef4a1..6b0c59297f3d69e8b13e6bc2e0b5c3b5b1c840e7 100644
--- a/core/Console.php
+++ b/core/Console.php
@@ -26,12 +26,14 @@ class Console extends Application
      */
     private $environment;
 
-    public function __construct()
+    public function __construct(Environment $environment = null)
     {
         $this->setServerArgsIfPhpCgi();
 
         parent::__construct();
 
+        $this->environment = $environment;
+
         $option = new InputOption('piwik-domain',
             null,
             InputOption::VALUE_OPTIONAL,
@@ -169,8 +171,10 @@ class Console extends Application
     protected function initEnvironment(OutputInterface $output)
     {
         try {
-            $this->environment = new Environment('cli');
-            $this->environment->init();
+            if ($this->environment === null) {
+                $this->environment = new Environment('cli');
+                $this->environment->init();
+            }
 
             $config = Config::getInstance();
             return $config;
diff --git a/tests/PHPUnit/Framework/TestCase/ConsoleCommandTestCase.php b/tests/PHPUnit/Framework/TestCase/ConsoleCommandTestCase.php
index 31452e46519ac4e67614e076d70fa61d6564a3bf..4c63a0c0c0aafd73576dd8d388b2fc22c6dbbccb 100644
--- a/tests/PHPUnit/Framework/TestCase/ConsoleCommandTestCase.php
+++ b/tests/PHPUnit/Framework/TestCase/ConsoleCommandTestCase.php
@@ -75,7 +75,7 @@ class ConsoleCommandTestCase extends SystemTestCase
     {
         parent::setUp();
 
-        $this->application = new TestConsole();
+        $this->application = new TestConsole(self::$fixture->piwikEnvironment);
         $this->application->setAutoExit(false);
 
         $this->applicationTester = new ApplicationTester($this->application);