Show that no version was found in composer show/license if root package is auto-versioned, fixes #4158
parent
c8eca6f198
commit
a943827371
|
@ -50,6 +50,7 @@ class RootPackageLoader extends ArrayLoader
|
|||
if (!isset($config['name'])) {
|
||||
$config['name'] = '__root__';
|
||||
}
|
||||
$autoVersioned = false;
|
||||
if (!isset($config['version'])) {
|
||||
// override with env var if available
|
||||
if (getenv('COMPOSER_ROOT_VERSION')) {
|
||||
|
@ -60,17 +61,21 @@ class RootPackageLoader extends ArrayLoader
|
|||
|
||||
if (!$version) {
|
||||
$version = '1.0.0';
|
||||
$autoVersioned = true;
|
||||
}
|
||||
|
||||
$config['version'] = $version;
|
||||
}
|
||||
|
||||
$realPackage = $package = parent::load($config, $class);
|
||||
|
||||
if ($realPackage instanceof AliasPackage) {
|
||||
$realPackage = $package->getAliasOf();
|
||||
}
|
||||
|
||||
if ($autoVersioned) {
|
||||
$realPackage->replaceVersion($realPackage->getVersion(), 'No version set (parsed as 1.0.0)');
|
||||
}
|
||||
|
||||
if (isset($config['minimum-stability'])) {
|
||||
$realPackage->setMinimumStability(VersionParser::normalizeStability($config['minimum-stability']));
|
||||
}
|
||||
|
|
|
@ -118,6 +118,31 @@ class RootPackageLoaderTest extends \PHPUnit_Framework_TestCase
|
|||
$this->assertEquals("dev-foo", $package->getVersion());
|
||||
}
|
||||
|
||||
public function testNoVersionIsVisibleInPrettyVersion()
|
||||
{
|
||||
$manager = $this->getMockBuilder('\\Composer\\Repository\\RepositoryManager')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$self = $this;
|
||||
|
||||
/* Can do away with this mock object when https://github.com/sebastianbergmann/phpunit-mock-objects/issues/81 is fixed */
|
||||
$processExecutor = $this->getMockBuilder('Composer\Util\ProcessExecutor')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$processExecutor->expects($this->any())
|
||||
->method('execute')
|
||||
->willReturn(null);
|
||||
|
||||
$config = new Config;
|
||||
$config->merge(array('repositories' => array('packagist' => false)));
|
||||
$loader = new RootPackageLoader($manager, $config, null, $processExecutor);
|
||||
$package = $loader->load(array());
|
||||
|
||||
$this->assertEquals("1.0.0.0", $package->getVersion());
|
||||
$this->assertEquals("No version set (parsed as 1.0.0)", $package->getPrettyVersion());
|
||||
}
|
||||
|
||||
protected function loadPackage($data)
|
||||
{
|
||||
$manager = $this->getMockBuilder('\\Composer\\Repository\\RepositoryManager')
|
||||
|
|
Loading…
Reference in New Issue