diff --git a/src/Package/PackageManagerImpl.php b/src/Package/PackageManagerImpl.php index 4f8c5d3..5bec305 100644 --- a/src/Package/PackageManagerImpl.php +++ b/src/Package/PackageManagerImpl.php @@ -360,11 +360,11 @@ private function assertPackagesLoaded() private function assertNoLoadErrors(Package $package) { - $loadError = $package->getLoadErrors(); + $loadErrors = $package->getLoadErrors(); - if ($loadError) { - // Rethrow error - throw $loadError; + if (count($loadErrors) > 0) { + // Rethrow first error + throw reset($loadErrors); } } } diff --git a/tests/Package/PackageManagerImplTest.php b/tests/Package/PackageManagerImplTest.php index c37d4e4..9389ba5 100644 --- a/tests/Package/PackageManagerImplTest.php +++ b/tests/Package/PackageManagerImplTest.php @@ -530,6 +530,23 @@ public function testInstallPackageFailsIfNoNameFound() $this->manager->installPackage($this->packageDir3); } + /** + * @expectedException \Puli\RepositoryManager\Api\Package\UnsupportedVersionException + * @expectedExceptionMessage The exception text + */ + public function testInstallPackageFailsIfPackageNotLoadableAndCustomNameSet() + { + $manager = new PackageManagerImpl($this->environment, $this->packageFileStorage); + $e = new UnsupportedVersionException('The exception text.'); + + $this->packageFileStorage->expects($this->once()) + ->method('loadPackageFile') + ->with(__DIR__.'/Fixtures/version-too-high/puli.json') + ->willThrowException($e); + + $manager->installPackage(__DIR__.'/Fixtures/version-too-high', 'vendor/my-package'); + } + public function testInstallPackageRevertsIfSavingNotPossible() { $this->initDefaultManager();