From 03995d6caaa34f46cabf628ea99d6654f7216317 Mon Sep 17 00:00:00 2001 From: Vyacheslav Pavlov Date: Wed, 20 Jul 2016 23:33:37 +0300 Subject: [PATCH 1/2] Added test for 'dump' method of ClassMapGenerator class --- .../Test/Autoload/ClassMapGeneratorTest.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/Composer/Test/Autoload/ClassMapGeneratorTest.php b/tests/Composer/Test/Autoload/ClassMapGeneratorTest.php index 4af707160..f8af32333 100644 --- a/tests/Composer/Test/Autoload/ClassMapGeneratorTest.php +++ b/tests/Composer/Test/Autoload/ClassMapGeneratorTest.php @@ -218,6 +218,20 @@ class ClassMapGeneratorTest extends TestCase ClassMapGenerator::createMap(__DIR__.'/no-file.no-foler'); } + public function testDump() + { + $dir = self::getUniqueTmpDirectory(); + + $resultFile = 'result.txt'; + $fileInDirectory = $dir . '/TestClass.php'; + + file_put_contents($fileInDirectory, ""); + + ClassMapGenerator::dump(array($dir), $resultFile); + + $this->assertEquals(" '$fileInDirectory',\n);", file_get_contents($resultFile)); + } + protected function assertEqualsNormalized($expected, $actual, $message = null) { foreach ($expected as $ns => $path) { From 108560b9c4114026ef14ecf22afe22bebe20e50b Mon Sep 17 00:00:00 2001 From: Vyacheslav Pavlov Date: Thu, 21 Jul 2016 16:37:26 +0300 Subject: [PATCH 2/2] Clean up temp files after a test. --- .../Composer/Test/Autoload/ClassMapGeneratorTest.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tests/Composer/Test/Autoload/ClassMapGeneratorTest.php b/tests/Composer/Test/Autoload/ClassMapGeneratorTest.php index f8af32333..36f3bcfd5 100644 --- a/tests/Composer/Test/Autoload/ClassMapGeneratorTest.php +++ b/tests/Composer/Test/Autoload/ClassMapGeneratorTest.php @@ -220,16 +220,19 @@ class ClassMapGeneratorTest extends TestCase public function testDump() { - $dir = self::getUniqueTmpDirectory(); + $tempDir = self::getUniqueTmpDirectory(); - $resultFile = 'result.txt'; - $fileInDirectory = $dir . '/TestClass.php'; + $resultFile = $tempDir . '/result.txt'; + $fileInDirectory = $tempDir . '/TestClass.php'; file_put_contents($fileInDirectory, ""); - ClassMapGenerator::dump(array($dir), $resultFile); + ClassMapGenerator::dump(array($tempDir), $resultFile); $this->assertEquals(" '$fileInDirectory',\n);", file_get_contents($resultFile)); + + $fs = new Filesystem(); + $fs->removeDirectory($tempDir); } protected function assertEqualsNormalized($expected, $actual, $message = null)