Skip to content

Commit

Permalink
Add test building phar and run functional tests with the phar, refs #…
Browse files Browse the repository at this point in the history
  • Loading branch information
Seldaek committed Nov 11, 2012
1 parent 5a763cf commit 5f3814b
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion tests/Composer/Test/AllFunctionalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class AllFunctionalTest extends \PHPUnit_Framework_TestCase
protected $oldcwd;
protected $oldenv;
protected $testDir;
private static $pharPath;

public function setUp()
{
Expand All @@ -34,11 +35,36 @@ public function tearDown()
putenv('COMPOSER_HOME='.$this->oldenv);
$this->oldenv = null;
}
}

public static function setUpBeforeClass()
{
self::$pharPath = sys_get_temp_dir().'/composer-phar-test/composer.phar';
}

public static function tearDownAfterClass()
{
$fs = new Filesystem;
$fs->removeDirectory(dirname(self::$pharPath));
}

public function testBuildPhar()
{
$fs = new Filesystem;
$fs->removeDirectory(dirname(self::$pharPath));
$fs->ensureDirectoryExists(dirname(self::$pharPath));
chdir(dirname(self::$pharPath));

$proc = new Process('php '.escapeshellarg(__DIR__.'/../../../bin/compile'));
$exitcode = $proc->run();

$this->assertSame(0, $exitcode);
$this->assertTrue(file_exists(self::$pharPath));
}

/**
* @dataProvider getTestFiles
* @depends testBuildPhar
*/
public function testIntegration(\SplFileInfo $testFile)
{
Expand All @@ -47,7 +73,7 @@ public function testIntegration(\SplFileInfo $testFile)
$this->oldenv = getenv('COMPOSER_HOME');
putenv('COMPOSER_HOME='.$this->testDir.'home');

$cmd = 'php '.__DIR__.'/../../../bin/composer --no-ansi '.$testData['RUN'];
$cmd = 'php '.escapeshellarg(self::$pharPath).' --no-ansi '.$testData['RUN'];
$proc = new Process($cmd);
$exitcode = $proc->run();

Expand Down

0 comments on commit 5f3814b

Please sign in to comment.