1
0
Fork 0

Circumvent cache in functional tests

pull/1311/merge
Jordi Boggiano 2012-11-11 15:52:37 +01:00
parent 374e16beec
commit 62d0ea7656
1 changed files with 11 additions and 7 deletions

View File

@ -12,6 +12,7 @@ use Symfony\Component\Finder\Finder;
class AllFunctionalTest extends \PHPUnit_Framework_TestCase class AllFunctionalTest extends \PHPUnit_Framework_TestCase
{ {
protected $oldcwd; protected $oldcwd;
protected $oldenv;
protected $testDir; protected $testDir;
public function setUp() public function setUp()
@ -23,11 +24,17 @@ class AllFunctionalTest extends \PHPUnit_Framework_TestCase
public function tearDown() public function tearDown()
{ {
chdir($this->oldcwd); chdir($this->oldcwd);
$fs = new Filesystem;
if ($this->testDir) { if ($this->testDir) {
$fs = new Filesystem;
$fs->removeDirectory($this->testDir); $fs->removeDirectory($this->testDir);
$this->testDir = null; $this->testDir = null;
} }
if ($this->oldenv) {
$fs->removeDirectory(getenv('COMPOSER_HOME'));
putenv('COMPOSER_HOME='.$this->oldenv);
$this->oldenv = null;
}
} }
/** /**
@ -37,6 +44,9 @@ class AllFunctionalTest extends \PHPUnit_Framework_TestCase
{ {
$testData = $this->parseTestFile($testFile); $testData = $this->parseTestFile($testFile);
$this->oldenv = getenv('COMPOSER_HOME');
putenv('COMPOSER_HOME='.$this->testDir.'home');
$cmd = 'php '.__DIR__.'/../../../bin/composer --no-ansi '.$testData['RUN']; $cmd = 'php '.__DIR__.'/../../../bin/composer --no-ansi '.$testData['RUN'];
$proc = new Process($cmd); $proc = new Process($cmd);
$exitcode = $proc->run(); $exitcode = $proc->run();
@ -56,12 +66,6 @@ class AllFunctionalTest extends \PHPUnit_Framework_TestCase
if (isset($testData['EXPECT-EXIT-CODE'])) { if (isset($testData['EXPECT-EXIT-CODE'])) {
$this->assertSame($testData['EXPECT-EXIT-CODE'], $exitcode); $this->assertSame($testData['EXPECT-EXIT-CODE'], $exitcode);
} }
// Clean up.
$fs = new Filesystem();
if (isset($testData['test_dir']) && is_dir($testData['test_dir'])) {
$fs->removeDirectory($testData['test_dir']);
}
} }
public function getTestFiles() public function getTestFiles()