1
0
Fork 0

Install every package in its own directory, fixes #73

pull/77/merge
Jordi Boggiano 2011-10-30 19:10:37 +01:00
parent 56fab04c93
commit 4904e76185
2 changed files with 28 additions and 5 deletions

View File

@ -123,10 +123,7 @@ class LibraryInstaller implements InstallerInterface
*/ */
public function getInstallPath(PackageInterface $package) public function getInstallPath(PackageInterface $package)
{ {
if (null === $package->getTargetDir()) { $targetDir = $package->getTargetDir();
return ($this->directory ? $this->directory.'/' : '').$package->getName(); return ($this->directory ? $this->directory.'/' : '') . $package->getName() . ($targetDir ? '/'.$targetDir : '');
}
return ($this->directory ? $this->directory.'/' : '').$package->getTargetDir();
} }
} }

View File

@ -160,6 +160,32 @@ class LibraryInstallerTest extends \PHPUnit_Framework_TestCase
$library->uninstall($package); $library->uninstall($package);
} }
public function testGetInstallPath()
{
$library = new LibraryInstaller($this->dir, $this->dm, $this->repository);
$package = $this->createPackageMock();
$package
->expects($this->once())
->method('getTargetDir')
->will($this->returnValue(null));
$this->assertEquals($this->dir.'/'.$package->getName(), $library->getInstallPath($package));
}
public function testGetInstallPathWithTargetDir()
{
$library = new LibraryInstaller($this->dir, $this->dm, $this->repository);
$package = $this->createPackageMock();
$package
->expects($this->once())
->method('getTargetDir')
->will($this->returnValue('Some/Namespace'));
$this->assertEquals($this->dir.'/'.$package->getName().'/Some/Namespace', $library->getInstallPath($package));
}
private function createPackageMock() private function createPackageMock()
{ {
return $this->getMockBuilder('Composer\Package\MemoryPackage') return $this->getMockBuilder('Composer\Package\MemoryPackage')