Skip to content

Commit

Permalink
Merge 108e6de into ad8a245
Browse files Browse the repository at this point in the history
  • Loading branch information
ostrolucky committed Jan 19, 2018
2 parents ad8a245 + 108e6de commit 5d1d803
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/PackageVersions/Installer.php
Expand Up @@ -177,6 +177,12 @@ private static function getVersions(Locker $locker, RootPackageInterface $rootPa
);
}

yield $rootPackage->getName() => $rootPackage->getPrettyVersion() . '@' . $rootPackage->getSourceReference();
$rootVersion = $rootPackage->getPrettyVersion() . '@' . $rootPackage->getSourceReference();

foreach ($rootPackage->getReplaces() as $replace) {
yield $replace->getTarget() => $rootVersion;
}

yield $rootPackage->getName() => $rootVersion;
}
}
14 changes: 13 additions & 1 deletion test/PackageVersionsTest/InstallerTest.php
Expand Up @@ -7,8 +7,8 @@
use Composer\EventDispatcher\EventDispatcher;
use Composer\Installer\InstallationManager;
use Composer\IO\IOInterface;
use Composer\Package\Link;
use Composer\Package\Locker;
use Composer\Package\Package;
use Composer\Package\RootAliasPackage;
use Composer\Package\RootPackage;
use Composer\Package\RootPackageInterface;
Expand Down Expand Up @@ -162,6 +162,7 @@ final class Versions
'foo/bar' => '1.2.3@abc123',
'baz/tab' => '4.5.6@def456',
'tar/taz' => '7.8.9@ghi789',
'some-replaced/package' => '1.3.5@aaabbbcccddd',
'root/package' => '1.3.5@aaabbbcccddd',
);
Expand Down Expand Up @@ -265,6 +266,7 @@ final class Versions
'ocramius/package-versions' => '1.0.0@',
'foo/bar' => '1.2.3@abc123',
'baz/tab' => '4.5.6@def456',
'some-replaced/package' => '1.3.5@aaabbbcccddd',
'root/package' => '1.3.5@aaabbbcccddd',
);
Expand Down Expand Up @@ -370,6 +372,7 @@ final class Versions
'ocramius/package-versions' => '1.0.0@',
'foo/bar' => '1.2.3@abc123',
'baz/tab' => '4.5.6@',
'some-replaced/package' => '1.3.5@aaabbbcccddd',
'root/package' => '1.3.5@aaabbbcccddd',
);
Expand Down Expand Up @@ -556,6 +559,7 @@ public function testVersionsAreNotDumpedIfPackageVersionsNotExplicitlyRequired()
$package->expects(self::any())->method('getName')->willReturn('root/package');
$package->expects(self::any())->method('getVersion')->willReturn('1.3.5');
$package->expects(self::any())->method('getSourceReference')->willReturn('aaabbbcccddd');
$package->expects(self::any())->method('getReplaces')->willReturn([]);

$config->expects(self::any())->method('get')->with('vendor-dir')->willReturn($vendorDir);

Expand All @@ -579,6 +583,7 @@ public function testVersionsAreNotDumpedIfPackageIsScheduledForRemoval()
$config = $this->getMockBuilder(Config::class)->disableOriginalConstructor()->getMock();
$locker = $this->getMockBuilder(Locker::class)->disableOriginalConstructor()->getMock();
$package = $this->createMock(RootPackageInterface::class);
$package->expects(self::any())->method('getReplaces')->willReturn([]);
$vendorDir = sys_get_temp_dir() . '/' . uniqid('InstallerTest', true);
$expectedPath = $vendorDir . '/ocramius/package-versions/src/PackageVersions';

Expand Down Expand Up @@ -622,6 +627,7 @@ public function testGeneratedVersionFileAccessRights()
$installManager = $this->getMockBuilder(InstallationManager::class)->disableOriginalConstructor()->getMock();
$repository = $this->createMock(InstalledRepositoryInterface::class);
$package = $this->createMock(RootPackageInterface::class);
$package->expects(self::any())->method('getReplaces')->willReturn([]);

$vendorDir = sys_get_temp_dir() . '/' . uniqid('InstallerTest', true);

Expand Down Expand Up @@ -770,6 +776,7 @@ final class Versions
{
const VERSIONS = array (
'ocramius/package-versions' => '1.0.0@',
'some-replaced/package' => '1.3.5@aaabbbcccddd',
'root/package' => '1.3.5@aaabbbcccddd',
);
Expand Down Expand Up @@ -806,6 +813,11 @@ private function getRootPackageMock(): RootPackageInterface
$package->expects(self::any())->method('getPrettyVersion')->willReturn('1.3.5');
$package->expects(self::any())->method('getSourceReference')->willReturn('aaabbbcccddd');

$link = $this->createMock(Link::class);
$link->expects(self::any())->method('getTarget')->willReturn('some-replaced/package');

$package->expects(self::any())->method('getReplaces')->willReturn([$link]);

return $package;
}
}

0 comments on commit 5d1d803

Please sign in to comment.