diff --git a/Tests/Unit/Task/Composer/InstallTaskTest.php b/Tests/Unit/Task/Composer/InstallTaskTest.php new file mode 100644 index 00000000..b610f71a --- /dev/null +++ b/Tests/Unit/Task/Composer/InstallTaskTest.php @@ -0,0 +1,46 @@ +application->setDeploymentPath('/home/jdoe/app'); + } + + /** + * @test + */ + public function executeUserConfiguredComposerCommand() + { + $options = array( + 'composerCommandPath' => '/my/path/to/composer.phar', + ); + + $this->task->execute($this->node, $this->application, $this->deployment, $options); + $this->assertCommandExecuted('/^\/my\/path\/to\/composer.phar install --no-ansi --no-interaction --no-dev --no-progress 2>&1$/'); + } + + /** + * @return \TYPO3\Surf\Domain\Model\Task + */ + protected function createTask() + { + return new \TYPO3\Surf\Task\Composer\InstallTask(); + } +} diff --git a/src/Task/Composer/InstallTask.php b/src/Task/Composer/InstallTask.php index 8a7cd680..1f01f2d5 100644 --- a/src/Task/Composer/InstallTask.php +++ b/src/Task/Composer/InstallTask.php @@ -22,7 +22,7 @@ class InstallTask extends \TYPO3\Surf\Domain\Model\Task implements \TYPO3\Surf\D * @param \TYPO3\Surf\Domain\Model\Application $application * @param \TYPO3\Surf\Domain\Model\Deployment $deployment * @param array $options - * @return void + * @throws \TYPO3\Surf\Exception\InvalidConfigurationException */ public function execute(Node $node, Application $application, Deployment $deployment, array $options = array()) { @@ -40,8 +40,8 @@ public function execute(Node $node, Application $application, Deployment $deploy } if ($this->composerManifestExists($composerRootPath, $node, $deployment)) { - $command = $this->buildComposerInstallCommand($composerRootPath, $options); - $this->shell->executeOrSimulate($command, $node, $deployment); + $commands = $this->buildComposerInstallCommands($composerRootPath, $options); + $this->shell->executeOrSimulate($commands, $node, $deployment); } } @@ -64,15 +64,18 @@ public function simulate(Node $node, Application $application, Deployment $deplo * * @param string $manifestPath * @param array $options - * @return string + * @return array * @throws \TYPO3\Surf\Exception\TaskExecutionException */ - protected function buildComposerInstallCommand($manifestPath, array $options) + protected function buildComposerInstallCommands($manifestPath, array $options) { if (!isset($options['composerCommandPath'])) { throw new \TYPO3\Surf\Exception\TaskExecutionException('Composer command not found. Set the composerCommandPath option.', 1349163257); } - return sprintf('cd %s && %s install --no-ansi --no-interaction --no-dev --no-progress', escapeshellarg($manifestPath), escapeshellcmd($options['composerCommandPath'])); + return array( + 'cd ' . escapeshellarg($manifestPath), + escapeshellcmd($options['composerCommandPath']) . ' install --no-ansi --no-interaction --no-dev --no-progress 2>&1', + ); } /**