1
0
Fork 0

Fix issues in new autoloader code

pull/61/head
Jordi Boggiano 2011-10-22 19:49:54 +02:00
parent c8cfa15f52
commit 8a571c05db
3 changed files with 7 additions and 23 deletions

View File

@ -90,14 +90,12 @@ EOF;
{ {
$installPaths = array(); $installPaths = array();
foreach ($this->localRepo->getPackages() as $package) { foreach ($this->localRepo->getPackages() as $package) {
$this->populateAutoloadInformation($package);
$installPaths[] = array( $installPaths[] = array(
$package, $package,
$this->installationManager->getInstallPath($package) $this->installationManager->getInstallPath($package)
); );
} }
$installPaths[] = array($package, ''); $installPaths[] = array($this->package, '');
$autoloads = array(); $autoloads = array();
foreach ($installPaths as $item) { foreach ($installPaths as $item) {
@ -108,7 +106,6 @@ EOF;
} }
foreach ($package->getAutoload() as $type => $mapping) { foreach ($package->getAutoload() as $type => $mapping) {
$autoloads[$type] = isset($autoloads[$type]) ? $autoloads[$type] : array();
$autoloads[$type][] = array( $autoloads[$type][] = array(
'mapping' => $mapping, 'mapping' => $mapping,
'path' => $installPath, 'path' => $installPath,
@ -118,19 +115,4 @@ EOF;
return $autoloads; return $autoloads;
} }
/**
* Because remote repos don't include the autoload data,
* we have to manually fetch it from the locally installed
* packages.
*/
private function populateAutoloadInformation(PackageInterface $package)
{
$path = $this->installationManager->getInstallPath($package);
$loader = new JsonLoader();
$fullPackage = $loader->load(new JsonFile($path.'/composer.json'));
$package->setAutoload($fullPackage->getAutoload());
}
} }

View File

@ -44,7 +44,9 @@ class ArrayDumper
$data = array(); $data = array();
$data['name'] = $package->getPrettyName(); $data['name'] = $package->getPrettyName();
if ($package->getTargetDir()) {
$data['target-dir'] = $package->getTargetDir(); $data['target-dir'] = $package->getTargetDir();
}
foreach ($keys as $key) { foreach ($keys as $key) {
$getter = 'get'.ucfirst($key); $getter = 'get'.ucfirst($key);
$value = $package->$getter(); $value = $package->$getter();

View File

@ -78,7 +78,7 @@ class LibraryInstallerTest extends \PHPUnit_Framework_TestCase
$this->dm $this->dm
->expects($this->once()) ->expects($this->once())
->method('download') ->method('download')
->with($package, $this->dir.DIRECTORY_SEPARATOR.'some/package'); ->with($package, $this->dir.'/some/package');
$this->repository $this->repository
->expects($this->once()) ->expects($this->once())
@ -108,7 +108,7 @@ class LibraryInstallerTest extends \PHPUnit_Framework_TestCase
$this->dm $this->dm
->expects($this->once()) ->expects($this->once())
->method('update') ->method('update')
->with($initial, $target, $this->dir.DIRECTORY_SEPARATOR.'package1'); ->with($initial, $target, $this->dir.'/package1');
$this->repository $this->repository
->expects($this->once()) ->expects($this->once())
@ -146,7 +146,7 @@ class LibraryInstallerTest extends \PHPUnit_Framework_TestCase
$this->dm $this->dm
->expects($this->once()) ->expects($this->once())
->method('remove') ->method('remove')
->with($package, $this->dir.DIRECTORY_SEPARATOR.'pkg'); ->with($package, $this->dir.'/pkg');
$this->repository $this->repository
->expects($this->once()) ->expects($this->once())