diff --git a/src/Composer/Downloader/FileDownloader.php b/src/Composer/Downloader/FileDownloader.php index 6596d9c8b..e63df021a 100644 --- a/src/Composer/Downloader/FileDownloader.php +++ b/src/Composer/Downloader/FileDownloader.php @@ -215,8 +215,8 @@ class FileDownloader implements DownloaderInterface, ChangeReportInterface public function update(PackageInterface $initial, PackageInterface $target, $path) { $name = $target->getName(); - $from = $initial->getPrettyVersion(); - $to = $target->getPrettyVersion(); + $from = $initial->getFullPrettyVersion(); + $to = $target->getFullPrettyVersion(); $actionName = VersionParser::isUpgrade($initial->getVersion(), $target->getVersion()) ? 'Updating' : 'Downgrading'; $this->io->writeError(" - " . $actionName . " " . $name . " (" . $from . " => " . $to . "): ", false); diff --git a/src/Composer/Factory.php b/src/Composer/Factory.php index 6df73ceb3..7e9fd1bd1 100644 --- a/src/Composer/Factory.php +++ b/src/Composer/Factory.php @@ -546,7 +546,7 @@ class Factory $im->addInstaller(new Installer\LibraryInstaller($io, $composer, null)); $im->addInstaller(new Installer\PearInstaller($io, $composer, 'pear-library')); $im->addInstaller(new Installer\PluginInstaller($io, $composer)); - $im->addInstaller(new Installer\MetapackageInstaller()); + $im->addInstaller(new Installer\MetapackageInstaller($io)); } /** diff --git a/src/Composer/Installer/MetapackageInstaller.php b/src/Composer/Installer/MetapackageInstaller.php index 3f99ec03c..e1f31c1bf 100644 --- a/src/Composer/Installer/MetapackageInstaller.php +++ b/src/Composer/Installer/MetapackageInstaller.php @@ -14,6 +14,8 @@ namespace Composer\Installer; use Composer\Repository\InstalledRepositoryInterface; use Composer\Package\PackageInterface; +use Composer\Package\Version\VersionParser; +use Composer\IO\IOInterface; /** * Metapackage installation manager. @@ -22,6 +24,13 @@ use Composer\Package\PackageInterface; */ class MetapackageInstaller implements InstallerInterface { + private $io; + + public function __construct(IOInterface $io) + { + $this->io = $io; + } + /** * {@inheritDoc} */ @@ -43,6 +52,8 @@ class MetapackageInstaller implements InstallerInterface */ public function install(InstalledRepositoryInterface $repo, PackageInterface $package) { + $this->io->writeError(" - Installing " . $package->getName() . " (" . $package->getFullPrettyVersion() . ")"); + $repo->addPackage(clone $package); } @@ -55,6 +66,12 @@ class MetapackageInstaller implements InstallerInterface throw new \InvalidArgumentException('Package is not installed: '.$initial); } + $name = $target->getName(); + $from = $initial->getFullPrettyVersion(); + $to = $target->getFullPrettyVersion(); + $actionName = VersionParser::isUpgrade($initial->getVersion(), $target->getVersion()) ? 'Updating' : 'Downgrading'; + $this->io->writeError(" - " . $actionName . " " . $name . " (" . $from . " => " . $to . ")"); + $repo->removePackage($initial); $repo->addPackage(clone $target); } @@ -68,6 +85,8 @@ class MetapackageInstaller implements InstallerInterface throw new \InvalidArgumentException('Package is not installed: '.$package); } + $this->io->writeError(" - Removing " . $package->getName() . " (" . $package->getFullPrettyVersion() . ")"); + $repo->removePackage($package); } diff --git a/tests/Composer/Test/Downloader/FileDownloaderTest.php b/tests/Composer/Test/Downloader/FileDownloaderTest.php index 476b9a8f7..b09065f85 100644 --- a/tests/Composer/Test/Downloader/FileDownloaderTest.php +++ b/tests/Composer/Test/Downloader/FileDownloaderTest.php @@ -210,7 +210,7 @@ class FileDownloaderTest extends TestCase { $oldPackage = $this->getMock('Composer\Package\PackageInterface'); $oldPackage->expects($this->once()) - ->method('getPrettyVersion') + ->method('getFullPrettyVersion') ->will($this->returnValue('1.2.0')); $oldPackage->expects($this->once()) ->method('getVersion') @@ -218,7 +218,7 @@ class FileDownloaderTest extends TestCase $newPackage = $this->getMock('Composer\Package\PackageInterface'); $newPackage->expects($this->once()) - ->method('getPrettyVersion') + ->method('getFullPrettyVersion') ->will($this->returnValue('1.0.0')); $newPackage->expects($this->once()) ->method('getVersion') diff --git a/tests/Composer/Test/Installer/MetapackageInstallerTest.php b/tests/Composer/Test/Installer/MetapackageInstallerTest.php index 1a6b7a264..171773579 100644 --- a/tests/Composer/Test/Installer/MetapackageInstallerTest.php +++ b/tests/Composer/Test/Installer/MetapackageInstallerTest.php @@ -27,7 +27,7 @@ class MetapackageInstallerTest extends TestCase $this->io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock(); - $this->installer = new MetapackageInstaller(); + $this->installer = new MetapackageInstaller($this->io); } public function testInstall() @@ -45,7 +45,13 @@ class MetapackageInstallerTest extends TestCase public function testUpdate() { $initial = $this->createPackageMock(); + $initial->expects($this->once()) + ->method('getVersion') + ->will($this->returnValue('1.0.0')); $target = $this->createPackageMock(); + $target->expects($this->once()) + ->method('getVersion') + ->will($this->returnValue('1.0.1')); $this->repository ->expects($this->exactly(2))