diff --git a/tests/Composer/Test/Autoload/AutoloadGeneratorTest.php b/tests/Composer/Test/Autoload/AutoloadGeneratorTest.php index a4e8b9449..9d93ee95c 100644 --- a/tests/Composer/Test/Autoload/AutoloadGeneratorTest.php +++ b/tests/Composer/Test/Autoload/AutoloadGeneratorTest.php @@ -23,18 +23,18 @@ class AutoloadGeneratorTest extends \PHPUnit_Framework_TestCase private $im; private $repository; private $generator; + private $fs; protected function setUp() { - $fs = new Filesystem; + $this->fs = new Filesystem; $that = $this; $this->workingDir = realpath(sys_get_temp_dir()); $this->vendorDir = $this->workingDir.DIRECTORY_SEPARATOR.'composer-test-autoload'; - if (is_dir($this->vendorDir)) { - $fs->removeDirectory($this->vendorDir); + if (!is_dir($this->vendorDir)) { + mkdir($this->vendorDir); } - mkdir($this->vendorDir); $this->dir = getcwd(); chdir($this->workingDir); @@ -60,6 +60,9 @@ class AutoloadGeneratorTest extends \PHPUnit_Framework_TestCase protected function tearDown() { + if (is_dir($this->vendorDir)) { + $this->fs->removeDirectory($this->vendorDir); + } chdir($this->dir); } diff --git a/tests/Composer/Test/Installer/LibraryInstallerTest.php b/tests/Composer/Test/Installer/LibraryInstallerTest.php index ba86954e3..9df4e8893 100644 --- a/tests/Composer/Test/Installer/LibraryInstallerTest.php +++ b/tests/Composer/Test/Installer/LibraryInstallerTest.php @@ -30,16 +30,15 @@ class LibraryInstallerTest extends \PHPUnit_Framework_TestCase $this->fs = new Filesystem; $this->vendorDir = realpath(sys_get_temp_dir()).DIRECTORY_SEPARATOR.'composer-test-vendor'; - if (is_dir($this->vendorDir)) { - $this->fs->removeDirectory($this->vendorDir); + if (!is_dir($this->vendorDir)) { + mkdir($this->vendorDir); } - mkdir($this->vendorDir); + $this->binDir = realpath(sys_get_temp_dir()).DIRECTORY_SEPARATOR.'composer-test-bin'; - if (is_dir($this->binDir)) { - $this->fs->removeDirectory($this->binDir); + if (!is_dir($this->binDir)) { + mkdir($this->binDir); } - mkdir($this->binDir); $this->dm = $this->getMockBuilder('Composer\Downloader\DownloadManager') ->disableOriginalConstructor() @@ -52,6 +51,16 @@ class LibraryInstallerTest extends \PHPUnit_Framework_TestCase ->getMock(); } + protected function tearDown() { + if (is_dir($this->vendorDir)) { + $this->fs->removeDirectory($this->vendorDir); + } + + if (is_dir($this->binDir)) { + $this->fs->removeDirectory($this->binDir); + } + } + public function testInstallerCreationShouldNotCreateVendorDirectory() { $this->fs->removeDirectory($this->vendorDir);