Unverified Commit e19f578f authored by Marco Pivetta's avatar Marco Pivetta Committed by GitHub
Browse files

Merge pull request #150 from Ocramius/fix/#148-retrieve-root-package-name-version

#148 retrieve root package version also when package is installed with `--no-scripts`
Showing with 14 additions and 0 deletions
+14 -0
......@@ -39,6 +39,13 @@ final class Versions
*/
public static function getVersion(string $packageName) : string
{
/** @psalm-suppress DeprecatedConstant */
if ($packageName === self::ROOT_PACKAGE_NAME) {
$rootPackage = InstalledVersions::getRootPackage();
return $rootPackage['pretty_version'] . '@' . $rootPackage['reference'];
}
return InstalledVersions::getPrettyVersion($packageName)
. '@' . InstalledVersions::getReference($packageName);
}
......
......@@ -36,6 +36,13 @@ final class VersionsTest extends TestCase
}
}
/** @group #148 */
public function testCanRetrieveRootPackageVersion(): void
{
/** @psalm-suppress DeprecatedConstant */
self::assertMatchesRegularExpression('/^.+\@[0-9a-f]+$/', Versions::getVersion(Versions::ROOT_PACKAGE_NAME));
}
public function testInvalidVersionsAreRejected(): void
{
$this->expectException(OutOfBoundsException::class);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment