Skip to content
Browse files

Display the version number when using PHPUnit from a Composer install…

… or Git checkout. Closes #654.
  • Loading branch information...
1 parent 47cb3be commit 25fbf631f944be48722dfcb1454080dfe10fd400 @sebastianbergmann committed Sep 19, 2012
Showing with 25 additions and 2 deletions.
  1. +5 −0 ChangeLog.md
  2. +20 −2 PHPUnit/Runner/Version.php
View
5 ChangeLog.md
@@ -3,6 +3,11 @@ PHPUnit 3.7
This is the list of changes for the PHPUnit 3.7 release series.
+PHPUnit 3.7.1
+-------------
+
+* The version number is now displayed when using PHPUnit from a Composer install or Git checkout.
+
PHPUnit 3.7.0
-------------
View
22 PHPUnit/Runner/Version.php
@@ -57,21 +57,39 @@
*/
class PHPUnit_Runner_Version
{
+ const VERSION = '@package_version@';
+ protected static $version;
+
/**
* Returns the current version of PHPUnit.
*
* @return string
*/
public static function id()
{
- return '@package_version@';
+ if (self::$version === NULL) {
+ if (strpos(self::VERSION, '@package_version') === 0) {
+ $dir = getcwd();
+ chdir(__DIR__);
+ $version = exec('git describe --tags');
+ chdir($dir);
+
+ if ($version) {
+ self::$version = $version;
+ }
+ } else {
+ self::$version = self::VERSION;
+ }
+ }
+
+ return self::$version;
}
/**
* @return string
*/
public static function getVersionString()
{
- return 'PHPUnit @package_version@ by Sebastian Bergmann.';
+ return 'PHPUnit ' . self::id() . ' by Sebastian Bergmann.';
}
}

0 comments on commit 25fbf63

Please sign in to comment.
Something went wrong with that request. Please try again.