From 5f3814bd05983d364f373cd9c077cd14fec9291c Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Sun, 11 Nov 2012 17:09:57 +0100 Subject: [PATCH] Add test building phar and run functional tests with the phar, refs #1155 --- tests/Composer/Test/AllFunctionalTest.php | 28 ++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/tests/Composer/Test/AllFunctionalTest.php b/tests/Composer/Test/AllFunctionalTest.php index 3778896b5..1bd1ed6b9 100644 --- a/tests/Composer/Test/AllFunctionalTest.php +++ b/tests/Composer/Test/AllFunctionalTest.php @@ -14,6 +14,7 @@ class AllFunctionalTest extends \PHPUnit_Framework_TestCase protected $oldcwd; protected $oldenv; protected $testDir; + private static $pharPath; public function setUp() { @@ -34,11 +35,36 @@ class AllFunctionalTest extends \PHPUnit_Framework_TestCase 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) { @@ -47,7 +73,7 @@ class AllFunctionalTest extends \PHPUnit_Framework_TestCase $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();