From 8d3b40ff8ee5b8f550e187b141df4d00626aefed Mon Sep 17 00:00:00 2001 From: Wookieb Date: Fri, 24 Feb 2012 10:40:47 +0100 Subject: [PATCH] Tests should remove created directories after testing process --- .../Test/Autoload/AutoloadGeneratorTest.php | 11 ++++++---- .../Test/Installer/LibraryInstallerTest.php | 21 +++++++++++++------ 2 files changed, 22 insertions(+), 10 deletions(-) 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);