From b1c4eed57f0012160f02b0aab41415e816a2cdba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Haso=C5=88?= Date: Wed, 7 Aug 2013 10:50:12 +0200 Subject: [PATCH] Throw exception if the local repository does not contain a package to uninstall --- src/Composer/Installer/LibraryInstaller.php | 2 -- src/Composer/Installer/MetapackageInstaller.php | 2 -- src/Composer/Installer/NoopInstaller.php | 2 -- tests/Composer/Test/Installer/LibraryInstallerTest.php | 3 +-- tests/Composer/Test/Installer/MetapackageInstallerTest.php | 3 +-- 5 files changed, 2 insertions(+), 10 deletions(-) diff --git a/src/Composer/Installer/LibraryInstaller.php b/src/Composer/Installer/LibraryInstaller.php index 6984ad918..df7f0d6aa 100644 --- a/src/Composer/Installer/LibraryInstaller.php +++ b/src/Composer/Installer/LibraryInstaller.php @@ -116,8 +116,6 @@ class LibraryInstaller implements InstallerInterface public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package) { if (!$repo->hasPackage($package)) { - // TODO throw exception again here, when update is fixed and we don't have to remove+install (see #125) - return; throw new \InvalidArgumentException('Package is not installed: '.$package); } diff --git a/src/Composer/Installer/MetapackageInstaller.php b/src/Composer/Installer/MetapackageInstaller.php index e0d19ab6e..3f99ec03c 100644 --- a/src/Composer/Installer/MetapackageInstaller.php +++ b/src/Composer/Installer/MetapackageInstaller.php @@ -65,8 +65,6 @@ class MetapackageInstaller implements InstallerInterface public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package) { if (!$repo->hasPackage($package)) { - // TODO throw exception again here, when update is fixed and we don't have to remove+install (see #125) - return; throw new \InvalidArgumentException('Package is not installed: '.$package); } diff --git a/src/Composer/Installer/NoopInstaller.php b/src/Composer/Installer/NoopInstaller.php index 1f006ee82..72cf17d22 100644 --- a/src/Composer/Installer/NoopInstaller.php +++ b/src/Composer/Installer/NoopInstaller.php @@ -71,8 +71,6 @@ class NoopInstaller implements InstallerInterface public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package) { if (!$repo->hasPackage($package)) { - // TODO throw exception again here, when update is fixed and we don't have to remove+install (see #125) - return; throw new \InvalidArgumentException('Package is not installed: '.$package); } $repo->removePackage($package); diff --git a/tests/Composer/Test/Installer/LibraryInstallerTest.php b/tests/Composer/Test/Installer/LibraryInstallerTest.php index 1f6d4cbe8..dd36e6184 100644 --- a/tests/Composer/Test/Installer/LibraryInstallerTest.php +++ b/tests/Composer/Test/Installer/LibraryInstallerTest.php @@ -197,8 +197,7 @@ class LibraryInstallerTest extends TestCase $library->uninstall($this->repository, $package); - // TODO re-enable once #125 is fixed and we throw exceptions again -// $this->setExpectedException('InvalidArgumentException'); + $this->setExpectedException('InvalidArgumentException'); $library->uninstall($this->repository, $package); } diff --git a/tests/Composer/Test/Installer/MetapackageInstallerTest.php b/tests/Composer/Test/Installer/MetapackageInstallerTest.php index 64316300d..204e05265 100644 --- a/tests/Composer/Test/Installer/MetapackageInstallerTest.php +++ b/tests/Composer/Test/Installer/MetapackageInstallerTest.php @@ -86,8 +86,7 @@ class MetapackageInstallerTest extends \PHPUnit_Framework_TestCase $this->installer->uninstall($this->repository, $package); - // TODO re-enable once #125 is fixed and we throw exceptions again -// $this->setExpectedException('InvalidArgumentException'); + $this->setExpectedException('InvalidArgumentException'); $this->installer->uninstall($this->repository, $package); }