diff --git a/src/Composer/DependencyResolver/Operation/MarkAliasInstalledOperation.php b/src/Composer/DependencyResolver/Operation/MarkAliasInstalledOperation.php index 4638709ed..072ac702a 100644 --- a/src/Composer/DependencyResolver/Operation/MarkAliasInstalledOperation.php +++ b/src/Composer/DependencyResolver/Operation/MarkAliasInstalledOperation.php @@ -61,6 +61,6 @@ class MarkAliasInstalledOperation extends SolverOperation */ public function __toString() { - return 'Marking '.$this->package->getPrettyName().' ('.$this->package->getPrettyVersion().') as installed, alias of '.$this->package->getAliasOf()->getPrettyName().' ('.$this->package->getAliasOf()->getPrettyVersion().')'; + return 'Marking '.$this->package->getPrettyName().' ('.$this->formatVersion($this->package).') as installed, alias of '.$this->package->getAliasOf()->getPrettyName().' ('.$this->formatVersion($this->package->getAliasOf()).')'; } } diff --git a/src/Composer/DependencyResolver/Operation/MarkAliasUninstalledOperation.php b/src/Composer/DependencyResolver/Operation/MarkAliasUninstalledOperation.php index 648356df5..f1cd6c040 100644 --- a/src/Composer/DependencyResolver/Operation/MarkAliasUninstalledOperation.php +++ b/src/Composer/DependencyResolver/Operation/MarkAliasUninstalledOperation.php @@ -61,6 +61,6 @@ class MarkAliasUninstalledOperation extends SolverOperation */ public function __toString() { - return 'Marking '.$this->package->getPrettyName().' ('.$this->package->getPrettyVersion().') as uninstalled, alias of '.$this->package->getAliasOf()->getPrettyName().' ('.$this->package->getAliasOf()->getPrettyVersion().')'; + return 'Marking '.$this->package->getPrettyName().' ('.$this->formatVersion($this->package).') as uninstalled, alias of '.$this->package->getAliasOf()->getPrettyName().' ('.$this->formatVersion($this->package->getAliasOf()).')'; } } diff --git a/tests/Composer/Test/Fixtures/installer/aliased-priority.test b/tests/Composer/Test/Fixtures/installer/aliased-priority.test new file mode 100644 index 000000000..1b5226fad --- /dev/null +++ b/tests/Composer/Test/Fixtures/installer/aliased-priority.test @@ -0,0 +1,53 @@ +--TEST-- +Aliases take precedence over default package +--COMPOSER-- +{ + "repositories": [ + { + "type": "package", + "package": [ + { + "name": "a/c", "version": "dev-feature-foo", + "source": { "reference": "feat.f", "type": "git", "url": "" } + }, + { + "name": "a/b", "version": "dev-master", + "extra": { "branch-alias": { "dev-master": "1.0.x-dev" } }, + "source": { "reference": "forked", "type": "git", "url": "" } + } + ] + }, + { + "type": "package", + "package": [ + { + "name": "a/a", "version": "dev-master", + "extra": { "branch-alias": { "dev-master": "1.0.x-dev" } }, + "source": { "reference": "master", "type": "git", "url": "" }, + "require": { + "a/b": "dev-master", + "a/c": "dev-master" + } + }, + { + "name": "a/b", "version": "dev-master", + "extra": { "branch-alias": { "dev-master": "1.0.x-dev" } }, + "source": { "reference": "master", "type": "git", "url": "" } + }, + { "name": "a/c", "version": "dev-master" } + ] + } + ], + "require": { + "a/a": "1.*", + "a/b": "1.*", + "a/c": "dev-feature-foo as dev-master" + } +} +--EXPECT-- +Installing a/c (dev-feature-foo feat.f) +Marking a/c (dev-master feat.f) as installed, alias of a/c (dev-feature-foo feat.f) +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/a (dev-master master) +Marking a/a (1.0.x-dev master) as installed, alias of a/a (dev-master master) diff --git a/tests/Composer/Test/InstallerTest.php b/tests/Composer/Test/InstallerTest.php index b6a809dc1..20a8c14cf 100644 --- a/tests/Composer/Test/InstallerTest.php +++ b/tests/Composer/Test/InstallerTest.php @@ -196,13 +196,14 @@ class InstallerTest extends TestCase $test = file_get_contents($file->getRealpath()); + $content = '(?:.(?!--[A-Z]))+'; $pattern = '{^ --TEST--\s*(?P.*?)\s* - (?:--CONDITION--\s*(?P.*?))?\s* - --COMPOSER--\s*(?P.*?)\s* - (?:--LOCK--\s*(?P.*?))?\s* - (?:--INSTALLED--\s*(?P.*?))?\s* - (?:--INSTALLED:DEV--\s*(?P.*?))?\s* + (?:--CONDITION--\s*(?P'.$content.'))?\s* + --COMPOSER--\s*(?P'.$content.')\s* + (?:--LOCK--\s*(?P'.$content.'))?\s* + (?:--INSTALLED--\s*(?P'.$content.'))?\s* + (?:--INSTALLED:DEV--\s*(?P'.$content.'))?\s* --EXPECT(?P:UPDATE)?(?P:DEV)?--\s*(?P.*?)\s* $}xs'; diff --git a/tests/Composer/Test/Mock/InstallationManagerMock.php b/tests/Composer/Test/Mock/InstallationManagerMock.php index 6474d1637..88724a7a5 100644 --- a/tests/Composer/Test/Mock/InstallationManagerMock.php +++ b/tests/Composer/Test/Mock/InstallationManagerMock.php @@ -17,6 +17,8 @@ use Composer\DependencyResolver\Operation\OperationInterface; use Composer\DependencyResolver\Operation\InstallOperation; use Composer\DependencyResolver\Operation\UpdateOperation; use Composer\DependencyResolver\Operation\UninstallOperation; +use Composer\DependencyResolver\Operation\MarkAliasInstalledOperation; +use Composer\DependencyResolver\Operation\MarkAliasUninstalledOperation; class InstallationManagerMock extends InstallationManager { @@ -47,6 +49,20 @@ class InstallationManagerMock extends InstallationManager $repo->removePackage($operation->getPackage()); } + public function markAliasInstalled(RepositoryInterface $repo, MarkAliasInstalledOperation $operation) + { + $this->installed[] = $operation->getPackage(); + $this->trace[] = (string) $operation; + $repo->addPackage(clone $operation->getPackage()); + } + + public function markAliasUninstalled(RepositoryInterface $repo, MarkAliasUninstalledOperation $operation) + { + $this->uninstalled[] = $operation->getPackage(); + $this->trace[] = (string) $operation; + $repo->removePackage($operation->getPackage()); + } + public function getTrace() { return $this->trace;