diff --git a/src/Composer/Autoload/ClassMapGenerator.php b/src/Composer/Autoload/ClassMapGenerator.php index 2cdb920a8..e7547cb04 100644 --- a/src/Composer/Autoload/ClassMapGenerator.php +++ b/src/Composer/Autoload/ClassMapGenerator.php @@ -84,7 +84,7 @@ class ClassMapGenerator foreach ($classes as $class) { if (!isset($map[$class])) { $map[$class] = $filePath; - } elseif ($io && $map[$class] !== $filePath && !preg_match('{/(test|fixture)s?/}i', strtr($map[$class].' '.$filePath, '\\', '/'))) { + } elseif ($io && $map[$class] !== $filePath && !preg_match('{/(test|fixture|example)s?/}i', strtr($map[$class].' '.$filePath, '\\', '/'))) { $io->write( 'Warning: Ambiguous class resolution, "'.$class.'"'. ' was found in both "'.$map[$class].'" and "'.$filePath.'", the first will be used.' diff --git a/tests/Composer/Test/Autoload/ClassMapGeneratorTest.php b/tests/Composer/Test/Autoload/ClassMapGeneratorTest.php index 570eeab10..1ef68d459 100644 --- a/tests/Composer/Test/Autoload/ClassMapGeneratorTest.php +++ b/tests/Composer/Test/Autoload/ClassMapGeneratorTest.php @@ -152,10 +152,30 @@ class ClassMapGeneratorTest extends \PHPUnit_Framework_TestCase */ public function testUnambiguousReference() { - $this->checkIfFinderIsAvailable(); + $tempDir = sys_get_temp_dir().'/ComposerTestUnambiguousRefs'; + if (!is_dir($tempDir)) { + mkdir($tempDir, 0777, true); + } - $finder = new Finder(); - $finder->files()->in(__DIR__ . '/Fixtures/Unambiguous'); + file_put_contents($tempDir.'/A.php', "getMockBuilder('Composer\IO\ConsoleIO') ->disableOriginalConstructor() @@ -164,7 +184,10 @@ class ClassMapGeneratorTest extends \PHPUnit_Framework_TestCase $io->expects($this->never()) ->method('write'); - ClassMapGenerator::createMap($finder, null, $io); + ClassMapGenerator::createMap($tempDir, null, $io); + + $fs = new Filesystem(); + $fs->removeDirectory($tempDir); } /** diff --git a/tests/Composer/Test/Autoload/Fixtures/Unambiguous/A.php b/tests/Composer/Test/Autoload/Fixtures/Unambiguous/A.php deleted file mode 100644 index d88eba6e8..000000000 --- a/tests/Composer/Test/Autoload/Fixtures/Unambiguous/A.php +++ /dev/null @@ -1,6 +0,0 @@ -