Fix autoload generator with vendor-dir = working-dir
parent
ad92154c8f
commit
15d78e6ad1
|
@ -93,7 +93,12 @@ EOF;
|
|||
$path = strtr($path, '\\', '/');
|
||||
$baseDir = '';
|
||||
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));
|
||||
$baseDir = '$vendorDir . ';
|
||||
} else {
|
||||
|
|
|
@ -79,8 +79,17 @@ class AutoloadGeneratorTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
public function testVendorDirSameAsWorkingDir()
|
||||
{
|
||||
chdir($this->vendorDir);
|
||||
$this->testMainPackageAutoloading();
|
||||
$this->vendorDir = $this->workingDir;
|
||||
|
||||
$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()
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
// autoload_namespace.php generated by Composer
|
||||
|
||||
$vendorDir = dirname(__DIR__);
|
||||
|
||||
return array(
|
||||
'Main' => $vendorDir . '/src/',
|
||||
'Lala' => $vendorDir . '/src/',
|
||||
);
|
Loading…
Reference in New Issue