From 65b9cca7b56b65185deac82bd64711753a3eece9 Mon Sep 17 00:00:00 2001 From: Denis Sokolov Date: Thu, 10 Apr 2014 13:11:48 +0200 Subject: [PATCH] Fix ClassMapGenerator unambiguousReference test coverage Without this fix the test only covers having files in "test", the "fixture" portion it is not covered at all, because all fixtures in phpunit tests are already in "test" directory --- .../Test/Autoload/ClassMapGeneratorTest.php | 31 ++++++++++++++++--- .../Test/Autoload/Fixtures/Unambiguous/A.php | 6 ---- .../Fixtures/Unambiguous/tests/FixtureA.php | 3 -- .../Fixtures/Unambiguous/tests/FixtureA2.php | 3 -- 4 files changed, 27 insertions(+), 16 deletions(-) delete mode 100644 tests/Composer/Test/Autoload/Fixtures/Unambiguous/A.php delete mode 100644 tests/Composer/Test/Autoload/Fixtures/Unambiguous/tests/FixtureA.php delete mode 100644 tests/Composer/Test/Autoload/Fixtures/Unambiguous/tests/FixtureA2.php diff --git a/tests/Composer/Test/Autoload/ClassMapGeneratorTest.php b/tests/Composer/Test/Autoload/ClassMapGeneratorTest.php index 570eeab10..5ca42880e 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 @@ -