Permalink
Browse files

Root requires are not taken into account in locked installs, fixes #669

  • Loading branch information...
1 parent d56c996 commit 5bfbff867c48eb40f685db9a306afc236e98f8e0 @Seldaek Seldaek committed May 28, 2012
@@ -141,10 +141,14 @@ public function run()
}
// create installed repo, this contains all local packages + platform packages (php & extensions)
+ $installedRootPackage = clone $this->package;
+ $installedRootPackage->setRequires(array());
+ $installedRootPackage->setDevRequires(array());
+
$repos = array_merge(
$this->repositoryManager->getLocalRepositories(),
array(
- new InstalledArrayRepository(array($this->package)),
+ new InstalledArrayRepository(array($installedRootPackage)),
new PlatformRepository(),
)
);
@@ -47,8 +47,8 @@ Aliases take precedence over default package
--RUN--
install
--EXPECT--
-Installing a/b (dev-master forked)
Marking a/b (1.0.x-dev forked) as installed, alias of a/b (dev-master forked)
+Installing a/b (dev-master forked)
Marking a/c (dev-master feat.f) as installed, alias of a/c (dev-feature-foo feat.f)
Installing a/a (dev-master master)
Installing a/c (dev-feature-foo feat.f)
@@ -0,0 +1,32 @@
+--TEST--
+Requirements from the composer file are not installed if the lock file is present
+--COMPOSER--
+{
+ "repositories": [
+ {
+ "type": "package",
+ "package": [
+ { "name": "required", "version": "1.0.0" },
+ { "name": "newly-required", "version": "1.0.0" }
+ ]
+ }
+ ],
+ "require": {
+ "required": "1.0.0",
+ "newly-required": "1.0.0"
+ }
+}
+--LOCK--
+{
+ "packages": [
+ { "package": "required", "version": "1.0.0" }
+ ],
+ "packages-dev": null,
+ "aliases": [],
+ "minimum-stability": "stable",
+ "stability-flags": []
+}
+--RUN--
+install
+--EXPECT--
+Installing required (1.0.0)
@@ -124,7 +124,7 @@ public function provideInstaller()
/**
* @dataProvider getIntegrationTests
*/
- public function testIntegration($file, $message, $condition, $composer, $lock, $installed, $installedDev, $run, $expect)
+ public function testIntegration($file, $message, $condition, $composerConfig, $lock, $installed, $installedDev, $run, $expect)
{
if ($condition) {
eval('$res = '.$condition.';');
@@ -141,7 +141,7 @@ public function testIntegration($file, $message, $condition, $composer, $lock, $
$output .= $text . ($newline ? "\n":"");
}));
- $composer = FactoryMock::create($io, $composer);
+ $composer = FactoryMock::create($io, $composerConfig);
$jsonMock = $this->getMockBuilder('Composer\Json\JsonFile')->disableOriginalConstructor()->getMock();
$jsonMock->expects($this->any())
@@ -167,8 +167,11 @@ public function testIntegration($file, $message, $condition, $composer, $lock, $
$lockJsonMock->expects($this->any())
->method('read')
->will($this->returnValue($lock));
+ $lockJsonMock->expects($this->any())
+ ->method('exists')
+ ->will($this->returnValue(true));
- $locker = new Locker($lockJsonMock, $repositoryManager, isset($lock['hash']) ? $lock['hash'] : '');
+ $locker = new Locker($lockJsonMock, $repositoryManager, md5(json_encode($composerConfig)));
$composer->setLocker($locker);
$autoloadGenerator = $this->getMock('Composer\Autoload\AutoloadGenerator');
@@ -245,6 +248,9 @@ public function getIntegrationTests()
$composer = JsonFile::parseJson($match['composer']);
if (!empty($match['lock'])) {
$lock = JsonFile::parseJson($match['lock']);
+ if (!isset($lock['hash'])) {
+ $lock['hash'] = md5(json_encode($composer));
+ }
}
if (!empty($match['installed'])) {
$installed = JsonFile::parseJson($match['installed']);

0 comments on commit 5bfbff8

Please sign in to comment.