diff --git a/src/Composer/Command/Command.php b/src/Composer/Command/Command.php index 946d775b8..c5f83998d 100644 --- a/src/Composer/Command/Command.php +++ b/src/Composer/Command/Command.php @@ -13,17 +13,12 @@ namespace Composer\Command; use Symfony\Component\Console\Command\Command as BaseCommand; -use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Output\OutputInterface; -use Composer\DependencyResolver\Request; -use Composer\DependencyResolver\Solver; -use Composer\Installer\Operation; /** * Base class for Composer commands * * @author Ryan Weaver - * @authro Konstantin Kudryashov + * @author Konstantin Kudryashov */ abstract class Command extends BaseCommand { diff --git a/src/Composer/Command/InstallCommand.php b/src/Composer/Command/InstallCommand.php index 3e63318df..8250ba23f 100644 --- a/src/Composer/Command/InstallCommand.php +++ b/src/Composer/Command/InstallCommand.php @@ -85,6 +85,7 @@ EOT $installationManager->execute($operation); } + // TODO implement lock if (false) { $composer->getPackageLock()->lock($localRepo->getPackages()); $output->writeln('> Locked'); diff --git a/src/Composer/Composer.php b/src/Composer/Composer.php index 421b4be9f..9040043c3 100644 --- a/src/Composer/Composer.php +++ b/src/Composer/Composer.php @@ -29,9 +29,9 @@ class Composer private $package; private $lock; - private $rm; - private $dm; - private $im; + private $repositoryManager; + private $downloadManager; + private $installationManager; public function setPackage(PackageInterface $package) { @@ -55,31 +55,31 @@ class Composer public function setRepositoryManager(RepositoryManager $manager) { - $this->rm = $manager; + $this->repositoryManager = $manager; } public function getRepositoryManager() { - return $this->rm; + return $this->repositoryManager; } public function setDownloadManager(DownloadManager $manager) { - $this->dm = $manager; + $this->downloadManager = $manager; } public function getDownloadManager() { - return $this->dm; + return $this->downloadManager; } public function setInstallationManager(InstallationManager $manager) { - $this->im = $manager; + $this->installationManager = $manager; } public function getInstallationManager() { - return $this->im; + return $this->installationManager; } } diff --git a/src/Composer/Console/Application.php b/src/Composer/Console/Application.php index c792cdd5a..5730add3e 100644 --- a/src/Composer/Console/Application.php +++ b/src/Composer/Console/Application.php @@ -18,8 +18,6 @@ use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Finder\Finder; use Composer\Command\InstallCommand; use Composer\Composer; -use Composer\Package\PackageInterface; -use Composer\Package\PackageLock; /** * The console application that handles the commands @@ -61,7 +59,7 @@ class Application extends BaseApplication } /** - * Looks for all *Command files in Composer's Command directory + * Initializes all the composer commands */ protected function registerCommands() { diff --git a/src/Composer/Downloader/DownloadManager.php b/src/Composer/Downloader/DownloadManager.php index 8f40fdff0..c2e5ee358 100644 --- a/src/Composer/Downloader/DownloadManager.php +++ b/src/Composer/Downloader/DownloadManager.php @@ -68,7 +68,7 @@ class DownloadManager public function getDownloader($type) { if (!isset($this->downloaders[$type])) { - throw new \UnexpectedValueException('Unknown source type: '.$type); + throw new \InvalidArgumentException('Unknown source type: '.$type); } return $this->downloaders[$type]; diff --git a/src/Composer/Installer/LibraryInstaller.php b/src/Composer/Installer/LibraryInstaller.php index 59d546da2..338c15910 100644 --- a/src/Composer/Installer/LibraryInstaller.php +++ b/src/Composer/Installer/LibraryInstaller.php @@ -25,8 +25,8 @@ use Composer\Package\PackageInterface; */ class LibraryInstaller implements InstallerInterface { - private $dir; - private $dm; + private $directory; + private $downloadManager; private $repository; /** @@ -36,20 +36,20 @@ class LibraryInstaller implements InstallerInterface * @param DownloadManager $dm download manager * @param WritableRepositoryInterface $repository repository controller */ - public function __construct($dir, DownloadManager $dm, WritableRepositoryInterface $repository) + public function __construct($directory, DownloadManager $dm, WritableRepositoryInterface $repository) { - $this->dir = $dir; - $this->dm = $dm; + $this->directory = $directory; + $this->downloadManager = $dm; - if (!is_dir($this->dir)) { - if (file_exists($this->dir)) { + if (!is_dir($this->directory)) { + if (file_exists($this->directory)) { throw new \UnexpectedValueException( - $this->dir.' exists and is not a directory.' + $this->directory.' exists and is not a directory.' ); } - if (!mkdir($this->dir, 0777, true)) { + if (!mkdir($this->directory, 0777, true)) { throw new \UnexpectedValueException( - $this->dir.' does not exist and could not be created.' + $this->directory.' does not exist and could not be created.' ); } } @@ -78,9 +78,9 @@ class LibraryInstaller implements InstallerInterface */ public function install(PackageInterface $package) { - $downloadPath = $this->dir.DIRECTORY_SEPARATOR.$package->getName(); + $downloadPath = $this->directory.DIRECTORY_SEPARATOR.$package->getName(); - $this->dm->download($package, $downloadPath); + $this->downloadManager->download($package, $downloadPath); $this->repository->addPackage($package); } @@ -98,9 +98,9 @@ class LibraryInstaller implements InstallerInterface throw new \InvalidArgumentException('Package is not installed: '.$initial); } - $downloadPath = $this->dir.DIRECTORY_SEPARATOR.$initial->getName(); + $downloadPath = $this->directory.DIRECTORY_SEPARATOR.$initial->getName(); - $this->dm->update($initial, $target, $downloadPath); + $this->downloadManager->update($initial, $target, $downloadPath); $this->repository->removePackage($initial); $this->repository->addPackage($target); } @@ -118,9 +118,9 @@ class LibraryInstaller implements InstallerInterface throw new \InvalidArgumentException('Package is not installed: '.$package); } - $downloadPath = $this->dir.DIRECTORY_SEPARATOR.$package->getName(); + $downloadPath = $this->directory.DIRECTORY_SEPARATOR.$package->getName(); - $this->dm->remove($package, $downloadPath); + $this->downloadManager->remove($package, $downloadPath); $this->repository->removePackage($package); } } diff --git a/tests/Composer/Test/Downloader/DownloadManagerTest.php b/tests/Composer/Test/Downloader/DownloadManagerTest.php index cc48bf4d1..16131a180 100644 --- a/tests/Composer/Test/Downloader/DownloadManagerTest.php +++ b/tests/Composer/Test/Downloader/DownloadManagerTest.php @@ -24,7 +24,7 @@ class DownloadManagerTest extends \PHPUnit_Framework_TestCase $manager->setDownloader('test', $downloader); $this->assertSame($downloader, $manager->getDownloader('test')); - $this->setExpectedException('UnexpectedValueException'); + $this->setExpectedException('InvalidArgumentException'); $manager->getDownloader('unregistered'); } @@ -475,13 +475,14 @@ class DownloadManagerTest extends \PHPUnit_Framework_TestCase $manager->remove($package, 'vendor/pkg'); } + /** + * @expectedException InvalidArgumentException + */ public function testRemoveBadlyInstalledPackage() { $package = $this->createPackageMock(); $manager = new DownloadManager(); - $this->setExpectedException('InvalidArgumentException'); - $manager->remove($package, 'vendor/pkg'); }