Skip to content

Commit

Permalink
Fixed throwing of load errors
Browse files Browse the repository at this point in the history
  • Loading branch information
webmozart committed Jan 27, 2015
1 parent 20e8335 commit 002f0f3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/Package/PackageManagerImpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
17 changes: 17 additions & 0 deletions tests/Package/PackageManagerImplTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 002f0f3

Please sign in to comment.