[Nostromo] Refactor Composer SelfUpdate

This commit is contained in:
Andrés Montañez
2017-02-11 01:53:22 -03:00
parent d8f2359d12
commit f7448e39e7
3 changed files with 37 additions and 2 deletions
@@ -104,6 +104,40 @@ 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();