1
0
Fork 0

Fix autoload generator with vendor-dir = working-dir

pull/274/merge
Jordi Boggiano 2012-02-02 16:38:48 +01:00
parent ad92154c8f
commit 15d78e6ad1
3 changed files with 27 additions and 3 deletions

View File

@ -93,7 +93,12 @@ EOF;
$path = strtr($path, '\\', '/'); $path = strtr($path, '\\', '/');
$baseDir = ''; $baseDir = '';
if (!$filesystem->isAbsolutePath($path)) { if (!$filesystem->isAbsolutePath($path)) {
if (strpos($path, $relVendorPath) === 0) { // vendor dir == working dir
if (preg_match('{^(\./?)?$}', $relVendorPath)) {
$path = '/'.$path;
$baseDir = '$vendorDir . ';
} elseif (strpos($path, $relVendorPath) === 0) {
// path starts with vendor dir
$path = substr($path, strlen($relVendorPath)); $path = substr($path, strlen($relVendorPath));
$baseDir = '$vendorDir . '; $baseDir = '$vendorDir . ';
} else { } else {

View File

@ -79,8 +79,17 @@ class AutoloadGeneratorTest extends \PHPUnit_Framework_TestCase
public function testVendorDirSameAsWorkingDir() public function testVendorDirSameAsWorkingDir()
{ {
chdir($this->vendorDir); $this->vendorDir = $this->workingDir;
$this->testMainPackageAutoloading();
$package = new MemoryPackage('a', '1.0', '1.0');
$package->setAutoload(array('psr-0' => array('Main' => 'src/', 'Lala' => 'src/')));
$this->repo->expects($this->once())
->method('getPackages')
->will($this->returnValue(array()));
$this->generator->dump($this->repo, $package, $this->im, $this->vendorDir.'/.composer');
$this->assertAutoloadFiles('main3', $this->vendorDir.'/.composer');
} }
public function testMainPackageAutoloadingAlternativeVendorDir() public function testMainPackageAutoloadingAlternativeVendorDir()

View File

@ -0,0 +1,10 @@
<?php
// autoload_namespace.php generated by Composer
$vendorDir = dirname(__DIR__);
return array(
'Main' => $vendorDir . '/src/',
'Lala' => $vendorDir . '/src/',
);