Tests should remove created directories after testing process

main
Wookieb 13 years ago
parent 773338a688
commit 8d3b40ff8e

@ -23,18 +23,18 @@ class AutoloadGeneratorTest extends \PHPUnit_Framework_TestCase
private $im; private $im;
private $repository; private $repository;
private $generator; private $generator;
private $fs;
protected function setUp() protected function setUp()
{ {
$fs = new Filesystem; $this->fs = new Filesystem;
$that = $this; $that = $this;
$this->workingDir = realpath(sys_get_temp_dir()); $this->workingDir = realpath(sys_get_temp_dir());
$this->vendorDir = $this->workingDir.DIRECTORY_SEPARATOR.'composer-test-autoload'; $this->vendorDir = $this->workingDir.DIRECTORY_SEPARATOR.'composer-test-autoload';
if (is_dir($this->vendorDir)) { if (!is_dir($this->vendorDir)) {
$fs->removeDirectory($this->vendorDir); mkdir($this->vendorDir);
} }
mkdir($this->vendorDir);
$this->dir = getcwd(); $this->dir = getcwd();
chdir($this->workingDir); chdir($this->workingDir);
@ -60,6 +60,9 @@ class AutoloadGeneratorTest extends \PHPUnit_Framework_TestCase
protected function tearDown() protected function tearDown()
{ {
if (is_dir($this->vendorDir)) {
$this->fs->removeDirectory($this->vendorDir);
}
chdir($this->dir); chdir($this->dir);
} }

@ -30,16 +30,15 @@ class LibraryInstallerTest extends \PHPUnit_Framework_TestCase
$this->fs = new Filesystem; $this->fs = new Filesystem;
$this->vendorDir = realpath(sys_get_temp_dir()).DIRECTORY_SEPARATOR.'composer-test-vendor'; $this->vendorDir = realpath(sys_get_temp_dir()).DIRECTORY_SEPARATOR.'composer-test-vendor';
if (is_dir($this->vendorDir)) { if (!is_dir($this->vendorDir)) {
$this->fs->removeDirectory($this->vendorDir); mkdir($this->vendorDir);
} }
mkdir($this->vendorDir);
$this->binDir = realpath(sys_get_temp_dir()).DIRECTORY_SEPARATOR.'composer-test-bin'; $this->binDir = realpath(sys_get_temp_dir()).DIRECTORY_SEPARATOR.'composer-test-bin';
if (is_dir($this->binDir)) { if (!is_dir($this->binDir)) {
$this->fs->removeDirectory($this->binDir); mkdir($this->binDir);
} }
mkdir($this->binDir);
$this->dm = $this->getMockBuilder('Composer\Downloader\DownloadManager') $this->dm = $this->getMockBuilder('Composer\Downloader\DownloadManager')
->disableOriginalConstructor() ->disableOriginalConstructor()
@ -52,6 +51,16 @@ class LibraryInstallerTest extends \PHPUnit_Framework_TestCase
->getMock(); ->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() public function testInstallerCreationShouldNotCreateVendorDirectory()
{ {
$this->fs->removeDirectory($this->vendorDir); $this->fs->removeDirectory($this->vendorDir);

Loading…
Cancel
Save