[Nostromo] Refactor Composer SelfUpdate

This commit is contained in:
Andrés Montañez 2017-02-11 02:01:49 -03:00
parent f7448e39e7
commit 67c3a23bbb
2 changed files with 2 additions and 36 deletions

View file

@ -52,7 +52,7 @@ class SelfUpdateTask extends AbstractTask
throw new SkipException();
}
$cmdUpdate = sprintf('%s self-update %s', $options['path'], $options['version']);
$cmdUpdate = sprintf('%s self-update', $options['path']);
/** @var Process $process */
$process = $this->runtime->runCommand(trim($cmdUpdate));
@ -83,7 +83,7 @@ class SelfUpdateTask extends AbstractTask
protected function getOptions()
{
$options = array_merge(
['path' => 'composer', 'version' => '', 'days' => 60],
['path' => 'composer', 'days' => 60],
$this->runtime->getMergedOption('composer'),
$this->options
);

View file

@ -104,40 +104,6 @@ class SelfUpdateTaskTest extends TestCase
}
}
public function testSelfUpdateMustUpdateToVersionTask()
{
$runtime = new RuntimeMockup();
$runtime->setConfiguration(['environments' => ['test' => []]]);
$runtime->setEnvironment('test');
$task = new SelfUpdateTask();
$task->setOptions(['path' => 'composer.phar', 'version' => '1.2.0']);
$task->setRuntime($runtime);
try {
$result = $task->execute();
$this->assertTrue($result, 'Result should be successful');
} catch (Exception $exception) {
if ($exception instanceof SkipException) {
$this->assertTrue(false, 'Update should not have been skipped');
}
}
$ranCommands = $runtime->getRanCommands();
$testCase = array(
0 => 'composer.phar --version',
1 => 'composer.phar self-update 1.2.0',
);
// Check total of Executed Commands
$this->assertEquals(count($testCase), count($ranCommands));
// Check Generated Commands
foreach ($testCase as $index => $command) {
$this->assertEquals($command, $ranCommands[$index]);
}
}
public function testSelfUpdateWrongOutputTask()
{
$runtime = new RuntimeMockup();