Skip to content

Commit 4bb1b8c

Browse files
committed
- uses the current working directory for VERSION file
1 parent a44ae74 commit 4bb1b8c

2 files changed

Lines changed: 19 additions & 9 deletions

File tree

Tests/VersionTest.php

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,61 +6,72 @@
66

77
class VersionTest extends TestCase
88
{
9+
public function test_get_complete_version_for_version_file()
10+
{
11+
$this->assertSame(
12+
file_get_contents(__DIR__ . '/../VERSION'),
13+
get_complete_version([])[0],
14+
'Should read from VERSION file in the project root'
15+
);
16+
}
17+
918
/**
1019
* Converts the version array to string.
1120
*
1221
* @dataProvider versions
1322
*/
14-
public function testVersionString($index, $version, $result)
23+
public function test_version_string($index, $version, $result)
1524
{
1625
$this->assertSame($version, get_version($result), '(array -> string) #' . $index);
1726
}
1827

1928
/**
2029
* Get the version array from VERSION file.
2130
*/
22-
public function testVersionFile()
31+
public function test_version_file()
2332
{
2433
$version = get_complete_version([]);
2534
$this->assertCount(3, $version);
2635
}
2736

28-
public function testMajorVerison()
37+
public function test_major_verison()
2938
{
3039
$major = get_major_version([1, 0, 0]);
3140
$this->assertSame(1, $major);
3241
}
42+
3343
/**
3444
* Converts the string to array version.
3545
*
3646
* @dataProvider versions
3747
*/
38-
public function testVersionArray($index, $version, $result)
48+
public function test_version_array($index, $version, $result)
3949
{
4050
$this->assertSame($result, get_version_array($version), '(string -> array) #' . $index);
4151
}
52+
4253
/**
4354
* Converts the string to array version.
4455
*
4556
* @dataProvider moreVersions
4657
*/
47-
public function testMoreVersionArray($index, $version, $result)
58+
public function test_more_version_array($index, $version, $result)
4859
{
4960
$this->assertSame($result, get_version_array($version), '(string -> array) #' . $index);
5061
}
5162

5263
/**
5364
* @dataProvider invalidVersions
5465
*/
55-
public function testInvalidVersions($index, $version)
66+
public function test_invalid_versions($index, $version)
5667
{
5768
$this->assertSame(INVALID_VERSION_ARRAY, get_version_array($version), 'Data row #' . $index);
5869
}
5970

6071
/**
6172
* Special case: if pre-build is alpha with no meta, git's latest CHANGESET is appended as metadata
6273
*/
63-
public function testAlphaPreReleaseWithZeroBuild()
74+
public function test_alpha_pre_release_with_zero_build()
6475
{
6576
if (!file_exists(__DIR__ . '/../VERSION')) {
6677
$this->markTestSkipped('The VERSION file is not provided, test is skipped');

semver.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,10 @@ function get_complete_version(array $version): array
6767
assert('' !== $version[2], 'build-metadata is empty, should be zero or valid identifier');
6868
return $version;
6969
}
70-
// if ('VERSION' !== VERSION && is_array(VERSION)) {
7170
if (defined('VERSION') && is_array(VERSION)) {
7271
return get_version_array(join('-', array_filter(VERSION)));
7372
}
74-
if ($version = @file_get_contents(__DIR__ . '/../../VERSION')) {
73+
if ($version = @file_get_contents(getcwd() . '/VERSION')) {
7574
return get_version_array($version);
7675
}
7776
return INVALID_VERSION_ARRAY;

0 commit comments

Comments
 (0)