Skip to content

Commit 16abbaf

Browse files
committed
Get version using InstalledVersions
1 parent 5a850f6 commit 16abbaf

File tree

3 files changed

+12
-14
lines changed

3 files changed

+12
-14
lines changed

composer.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
"name": "jigarius/phpake",
33
"description": "Phpake is a make-like utility built for PHP.",
44
"license": "GPL-3.0-only",
5-
"version": "1.0.0",
6-
"keywords": [],
5+
"keywords": ["make"],
76
"authors": [
87
{
98
"name": "Jerry Radwick",

src/Phpake.php

+7-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Phpake;
44

5+
use Composer\InstalledVersions;
56
use Symfony\Component\Console\Application;
67
use Symfony\Component\Console\Input\InputInterface;
78
use Symfony\Component\Console\Input\ArgvInput;
@@ -32,12 +33,15 @@ class Phpake extends Application {
3233
* Creates a Phpake Application instance.
3334
*/
3435
public function __construct() {
35-
parent::__construct();
36-
$this->setName(self::NAME);
37-
$this->setVersion(self::VERSION);
36+
parent::__construct(
37+
self::NAME,
38+
InstalledVersions::getPrettyVersion('jigarius/phpake'),
39+
);
3840

41+
// @todo Not required. Remove after refactoring.
3942
$this->input = new ArgvInput();
4043
$this->output = new ConsoleOutput();
44+
4145
$this->configureIO($this->input, $this->output);
4246
}
4347

test/PhpakeTest.php

+4-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
22

3+
use Composer\InstalledVersions;
34
use Phpake\Phpake;
45
use Phpake\TestCase;
56

@@ -18,16 +19,10 @@ public function testName() {
1819

1920
public function testVersion() {
2021
$app = new Phpake();
21-
$this->assertMatchesRegularExpression(
22-
'/^\d+\.\d+.\d+(-(alpha|beta|rc)\.\d+)?$/',
23-
$app->getVersion()
22+
$this->assertEquals(
23+
InstalledVersions::getPrettyVersion('jigarius/phpake'),
24+
$app->getVersion()
2425
);
25-
26-
$json_path = dirname(__DIR__) . DIRECTORY_SEPARATOR . 'composer.json';
27-
$json_data = json_decode(file_get_contents($json_path));
28-
29-
$this->assertNotEmpty($json_data->version);
30-
$this->assertEquals($json_data->version, $app->getVersion());
3126
}
3227

3328
public function testRequire() {

0 commit comments

Comments
 (0)