From d2e9f96ab3cc6bae461fc2ed309a060f243cea8c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Diego=20Ba=C3=B1os=20Fari=C3=B1as?=
 <diegobanosfarinas@gmail.com>
Date: Wed, 26 Apr 2017 17:55:02 -0400
Subject: [PATCH] Bugfix: Fix console -V and --version not showing the version.
 Fixes #10640 (#11639)

---
 core/Console.php                   |  3 ++-
 tests/PHPUnit/Unit/ConsoleTest.php | 25 +++++++++++++++++++++++++
 2 files changed, 27 insertions(+), 1 deletion(-)
 create mode 100644 tests/PHPUnit/Unit/ConsoleTest.php

diff --git a/core/Console.php b/core/Console.php
index 7a7629443f..bb6f4f7eff 100644
--- a/core/Console.php
+++ b/core/Console.php
@@ -12,6 +12,7 @@ use Piwik\Application\Environment;
 use Piwik\Config\ConfigNotFoundException;
 use Piwik\Container\StaticContainer;
 use Piwik\Plugin\Manager as PluginManager;
+use Piwik\Version;
 use Symfony\Bridge\Monolog\Handler\ConsoleHandler;
 use Symfony\Component\Console\Application;
 use Symfony\Component\Console\Command\Command;
@@ -30,7 +31,7 @@ class Console extends Application
     {
         $this->setServerArgsIfPhpCgi();
 
-        parent::__construct();
+        parent::__construct('Piwik', Version::VERSION);
 
         $this->environment = $environment;
 
diff --git a/tests/PHPUnit/Unit/ConsoleTest.php b/tests/PHPUnit/Unit/ConsoleTest.php
new file mode 100644
index 0000000000..f13f825f32
--- /dev/null
+++ b/tests/PHPUnit/Unit/ConsoleTest.php
@@ -0,0 +1,25 @@
+<?php
+/**
+ * Piwik - free/libre analytics platform
+ *
+ * @link http://piwik.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
+ */
+namespace Piwik\Tests\Unit;
+
+use Piwik\Console;
+use Piwik\Version;
+
+/**
+ * @group Console
+ */
+class ConsoleTest extends \PHPUnit_Framework_TestCase
+{
+    public function testIsApplicationNameAndVersionCorrect()
+    {
+        $console = new Console();
+
+        $this->assertEquals('Piwik', $console->getName());
+        $this->assertEquals(Version::VERSION, $console->getVersion());
+    }
+}
-- 
GitLab