Fix autoload generator with vendor-dir = working-dir
parent
ad92154c8f
commit
15d78e6ad1
|
@ -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 {
|
||||||
|
|
|
@ -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()
|
||||||
|
|
|
@ -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