mirror of
https://github.com/andres-montanez/Magallanes
synced 2024-05-19 22:26:36 +02:00
[Nostromo] Refactor Composer SelfUpdate
This commit is contained in:
parent
d8f2359d12
commit
f7448e39e7
|
@ -2,6 +2,7 @@ CHANGELOG for 3.x
|
||||||
=================
|
=================
|
||||||
|
|
||||||
* 3.0.X (2017-XX-XX)
|
* 3.0.X (2017-XX-XX)
|
||||||
|
* Add new Composer task, to update phar (composer/self-update)
|
||||||
* [#344] Allow to flag Filesystem tasks
|
* [#344] Allow to flag Filesystem tasks
|
||||||
* [PR#346] Add new File System task, to change file's modes (fs/chmod)
|
* [PR#346] Add new File System task, to change file's modes (fs/chmod)
|
||||||
* [BUGFIX] [PR#342] Ignore empty exclude lines
|
* [BUGFIX] [PR#342] Ignore empty exclude lines
|
||||||
|
|
|
@ -52,7 +52,7 @@ class SelfUpdateTask extends AbstractTask
|
||||||
throw new SkipException();
|
throw new SkipException();
|
||||||
}
|
}
|
||||||
|
|
||||||
$cmdUpdate = sprintf('%s self-update %s', $options['path'], $options['release']);
|
$cmdUpdate = sprintf('%s self-update %s', $options['path'], $options['version']);
|
||||||
/** @var Process $process */
|
/** @var Process $process */
|
||||||
$process = $this->runtime->runCommand(trim($cmdUpdate));
|
$process = $this->runtime->runCommand(trim($cmdUpdate));
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ class SelfUpdateTask extends AbstractTask
|
||||||
protected function getOptions()
|
protected function getOptions()
|
||||||
{
|
{
|
||||||
$options = array_merge(
|
$options = array_merge(
|
||||||
['path' => 'composer', 'release' => '', 'days' => 60],
|
['path' => 'composer', 'version' => '', 'days' => 60],
|
||||||
$this->runtime->getMergedOption('composer'),
|
$this->runtime->getMergedOption('composer'),
|
||||||
$this->options
|
$this->options
|
||||||
);
|
);
|
||||||
|
|
|
@ -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()
|
public function testSelfUpdateWrongOutputTask()
|
||||||
{
|
{
|
||||||
$runtime = new RuntimeMockup();
|
$runtime = new RuntimeMockup();
|
||||||
|
|
Loading…
Reference in a new issue