diff --git a/src/Drall.php b/src/Drall.php index fdfb875..8fdab53 100644 --- a/src/Drall.php +++ b/src/Drall.php @@ -2,6 +2,7 @@ namespace Drall; +use Composer\InstalledVersions; use Drall\Command\ExecCommand; use Drall\Command\SiteAliasesCommand; use Drall\Command\SiteDirectoriesCommand; @@ -19,8 +20,6 @@ final class Drall extends Application { const NAME = 'Drall'; - const VERSION = '3.1.0-rc1'; - use SiteDetectorAwareTrait; /** @@ -29,7 +28,7 @@ final class Drall extends Application { public function __construct() { parent::__construct(); $this->setName(self::NAME); - $this->setVersion(self::VERSION); + $this->setVersion(InstalledVersions::getPrettyVersion('jigarius/drall') ?? 'unknown'); $this->setAutoExit(FALSE); $this->add(new SiteDirectoriesCommand()); diff --git a/test/Integration/DrallTest.php b/test/Integration/DrallTest.php index 59ced3a..f625873 100644 --- a/test/Integration/DrallTest.php +++ b/test/Integration/DrallTest.php @@ -2,6 +2,7 @@ namespace Drall\Test\Integration; +use Composer\InstalledVersions; use Drall\Drall; use Drall\IntegrationTestCase; @@ -12,7 +13,8 @@ class DrallTest extends IntegrationTestCase { public function testVersion() { $output = shell_exec('drall --version'); - $this->assertEquals(Drall::NAME . ' ' . Drall::VERSION . PHP_EOL, $output); + $version = InstalledVersions::getPrettyVersion('jigarius/drall'); + $this->assertEquals(Drall::NAME . ' ' . $version . PHP_EOL, $output); } public function testWorkingDirectory() { diff --git a/test/Unit/DrallTest.php b/test/Unit/DrallTest.php index 227589d..64dff70 100644 --- a/test/Unit/DrallTest.php +++ b/test/Unit/DrallTest.php @@ -20,15 +20,9 @@ public function testName() { public function testVersion() { $app = new Drall(); $this->assertMatchesRegularExpression( - '/^\d+\.\d+.\d+(-(alpha|beta|rc)\d+)?$/', - $app->getVersion() + '/^\d+\.\d+.\d+(-(alpha|beta|rc)\d+)?$|^\d+\.x-dev/', + $app->getVersion(), ); - - $json_path = $this->projectDir() . DIRECTORY_SEPARATOR . 'composer.json'; - $json_data = json_decode(file_get_contents($json_path)); - - $this->assertNotEmpty($json_data->version); - $this->assertEquals($json_data->version, $app->getVersion()); } public function testDefaultInputOptions() {