1
0
Fork 0

Fixed update alias packages in dry-run mode

pull/1573/head
Martin Hasoň 2013-03-21 12:08:58 +01:00
parent 753a8345cb
commit 02f92e678f
5 changed files with 139 additions and 5 deletions

View File

@ -809,12 +809,15 @@ class Installer
*/
private function mockLocalRepositories(RepositoryManager $rm)
{
$packages = array_map(function ($p) {
return clone $p;
}, $rm->getLocalRepository()->getPackages());
$packages = array();
foreach ($rm->getLocalRepository()->getPackages() as $package) {
$packages[(string) $package] = clone $package;
}
foreach ($packages as $key => $package) {
if ($package instanceof AliasPackage) {
unset($packages[$key]);
$alias = (string) $package->getAliasOf();
$packages[$key] = new AliasPackage($packages[$alias], $package->getVersion(), $package->getPrettyVersion());
unset($packages[$alias]);
}
}
$rm->setLocalRepository(

View File

@ -0,0 +1,40 @@
--TEST--
Updates updateable packages in dry-run mode
--COMPOSER--
{
"repositories": [
{
"type": "package",
"package": [
{ "name": "a/a", "version": "1.0.0" },
{ "name": "a/a", "version": "1.0.1" },
{ "name": "a/a", "version": "1.1.0" },
{ "name": "a/b", "version": "1.0.0" },
{ "name": "a/b", "version": "1.0.1" },
{ "name": "a/b", "version": "2.0.0" },
{ "name": "a/c", "version": "1.0.0" },
{ "name": "a/c", "version": "2.0.0" }
]
}
],
"require": {
"a/a": "1.0.*",
"a/c": "1.*"
},
"require-dev": {
"a/b": "*"
}
}
--INSTALLED--
[
{ "name": "a/a", "version": "1.0.0" },
{ "name": "a/c", "version": "1.0.0" },
{ "name": "a/b", "version": "1.0.0" }
]
--RUN--
update --dev --dry-run
--EXPECT--
Updating a/a (1.0.0) to a/a (1.0.1)
Updating a/b (1.0.0) to a/b (2.0.0)

View File

@ -0,0 +1,44 @@
--TEST--
Updates installed alias packages in dry-run mode
--COMPOSER--
{
"repositories": [
{
"type": "package",
"package": [
{
"name": "a/a", "version": "dev-master",
"require": { "b/b": "2.0.*" },
"source": { "reference": "abcdef", "url": "", "type": "git" },
"extra": { "branch-alias": { "dev-master": "1.0.x-dev" } }
},
{
"name": "b/b", "version": "dev-master",
"source": { "reference": "123456", "url": "", "type": "git" },
"extra": { "branch-alias": { "dev-master": "2.0.x-dev" } }
}
]
}
],
"require": {
"a/a": "~1.0@dev",
"b/b": "@dev"
}
}
--INSTALLED--
[
{
"name": "a/a", "version": "dev-master",
"require": { "b/b": "2.0.*" },
"source": { "reference": "abcdef", "url": "", "type": "git" },
"extra": { "branch-alias": { "dev-master": "1.0.x-dev" } }
},
{
"name": "b/b", "version": "dev-master",
"source": { "reference": "123456", "url": "", "type": "git" },
"extra": { "branch-alias": { "dev-master": "2.0.x-dev" } }
}
]
--RUN--
update --dry-run
--EXPECT--

View File

@ -0,0 +1,44 @@
--TEST--
Updates installed alias packages
--COMPOSER--
{
"repositories": [
{
"type": "package",
"package": [
{
"name": "a/a", "version": "dev-master",
"require": { "b/b": "2.0.*" },
"source": { "reference": "abcdef", "url": "", "type": "git" },
"extra": { "branch-alias": { "dev-master": "1.0.x-dev" } }
},
{
"name": "b/b", "version": "dev-master",
"source": { "reference": "123456", "url": "", "type": "git" },
"extra": { "branch-alias": { "dev-master": "2.0.x-dev" } }
}
]
}
],
"require": {
"a/a": "~1.0@dev",
"b/b": "@dev"
}
}
--INSTALLED--
[
{
"name": "a/a", "version": "dev-master",
"require": { "b/b": "2.0.*" },
"source": { "reference": "abcdef", "url": "", "type": "git" },
"extra": { "branch-alias": { "dev-master": "1.0.x-dev" } }
},
{
"name": "b/b", "version": "dev-master",
"source": { "reference": "123456", "url": "", "type": "git" },
"extra": { "branch-alias": { "dev-master": "2.0.x-dev" } }
}
]
--RUN--
update
--EXPECT--

View File

@ -200,7 +200,9 @@ class InstallerTest extends TestCase
$application = new Application;
$application->get('install')->setCode(function ($input, $output) use ($installer) {
$installer->setDevMode($input->getOption('dev'));
$installer
->setDevMode($input->getOption('dev'))
->setDryRun($input->getOption('dry-run'));
return $installer->run() ? 0 : 1;
});
@ -209,6 +211,7 @@ class InstallerTest extends TestCase
$installer
->setDevMode($input->getOption('dev'))
->setUpdate(true)
->setDryRun($input->getOption('dry-run'))
->setUpdateWhitelist($input->getArgument('packages'));
return $installer->run() ? 0 : 1;