diff --git a/src/Composer/Autoload/AutoloadGenerator.php b/src/Composer/Autoload/AutoloadGenerator.php index c6f5325d3..4d1517f74 100644 --- a/src/Composer/Autoload/AutoloadGenerator.php +++ b/src/Composer/Autoload/AutoloadGenerator.php @@ -200,8 +200,10 @@ EOF; { $psr0 = $this->parseAutoloadsType($packageMap, 'psr-0'); krsort($psr0); - $classmap = $this->parseAutoloadsType($packageMap, 'classmap'); - $files = $this->parseAutoloadsType($this->sortPackageMap($packageMap), 'files'); + + $sortedPackageMap = $this->sortPackageMap($packageMap); + $classmap = $this->parseAutoloadsType($sortedPackageMap, 'classmap'); + $files = $this->parseAutoloadsType($sortedPackageMap, 'files'); return array('psr-0' => $psr0, 'classmap' => $classmap, 'files' => $files); } diff --git a/tests/Composer/Test/Autoload/AutoloadGeneratorTest.php b/tests/Composer/Test/Autoload/AutoloadGeneratorTest.php index c93f2f378..af318f4c7 100644 --- a/tests/Composer/Test/Autoload/AutoloadGeneratorTest.php +++ b/tests/Composer/Test/Autoload/AutoloadGeneratorTest.php @@ -367,13 +367,13 @@ class AutoloadGeneratorTest extends TestCase public function testOverrideVendorsAutoloading() { $package = new Package('z', '1.0', '1.0'); - $package->setAutoload(array('psr-0' => array('A\\B' => $this->workingDir.'/lib'))); + $package->setAutoload(array('psr-0' => array('A\\B' => $this->workingDir.'/lib'), 'classmap' => array($this->workingDir.'/src'))); $package->setRequires(array(new Link('z', 'a/a'))); $packages = array(); $packages[] = $a = new Package('a/a', '1.0', '1.0'); $packages[] = $b = new Package('b/b', '1.0', '1.0'); - $a->setAutoload(array('psr-0' => array('A' => 'src/', 'A\\B' => 'lib/'))); + $a->setAutoload(array('psr-0' => array('A' => 'src/', 'A\\B' => 'lib/'), 'classmap' => array('classmap'))); $b->setAutoload(array('psr-0' => array('B\\Sub\\Name' => 'src/'))); $this->repository->expects($this->once()) @@ -381,12 +381,16 @@ class AutoloadGeneratorTest extends TestCase ->will($this->returnValue($packages)); $this->fs->ensureDirectoryExists($this->workingDir.'/lib/A/B'); + $this->fs->ensureDirectoryExists($this->workingDir.'/src/'); $this->fs->ensureDirectoryExists($this->vendorDir.'/composer'); + $this->fs->ensureDirectoryExists($this->vendorDir.'/a/a/classmap'); $this->fs->ensureDirectoryExists($this->vendorDir.'/a/a/src'); $this->fs->ensureDirectoryExists($this->vendorDir.'/a/a/lib/A/B'); $this->fs->ensureDirectoryExists($this->vendorDir.'/b/b/src'); file_put_contents($this->workingDir.'/lib/A/B/C.php', 'workingDir.'/src/classes.php', 'vendorDir.'/a/a/lib/A/B/C.php', 'vendorDir.'/a/a/classmap/classes.php', 'workingDir, '\\', '/'); $expectedNamespace = << \$baseDir . '/lib/A/B/C.php', + 'Foo\\\\Bar' => \$baseDir . '/src/classes.php', ); EOF;