Skip to content

Commit 60108ff

Browse files
author
Ivan Gavryshko
committed
MAGETWO-38838: Create composer management library and reuse it in both updater and setup wizard
- added test
1 parent d5b2a73 commit 60108ff

File tree

5 files changed

+71
-2
lines changed

5 files changed

+71
-2
lines changed

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/vendor
2+
/.cache
3+
/.metadata
4+
/.project
5+
/.settings
6+
atlassian*
7+
/.idea
8+
/.gitattributes

app/code/Magento/Composer/MagentoComposerApplication.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public function setConfig($pathToComposerHome, $pathToComposerJson)
8787
public function getComposer()
8888
{
8989
if (!$this->configIsSet) {
90-
throw new \Exception('Please call setConfig method to set config');
90+
throw new \Exception('Please call setConfig method to configure composer');
9191
}
9292

9393
return ComposerFactory::create(new BufferIO(), $this->composerJson);
@@ -99,10 +99,15 @@ public function getComposer()
9999
*
100100
* @param array $commandParams
101101
* @return bool
102+
* @throws \Exception
102103
* @throws \RuntimeException
103104
*/
104105
public function runComposerCommand(array $commandParams)
105106
{
107+
if (!$this->configIsSet) {
108+
throw new \Exception('Please call setConfig method to configure composer');
109+
}
110+
106111
$input = $this->consoleArrayInputFactory->create($commandParams);
107112
$this->consoleApplication->setAutoExit(false);
108113

@@ -116,6 +121,6 @@ public function runComposerCommand(array $commandParams)
116121

117122
//TODO: parse output based on command
118123

119-
return true;
124+
return $this->consoleOutput->fetch();
120125
}
121126
}

composer.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
"composer/composer": "1.0.*",
1313
"symfony/console": "~2.3 <2.7"
1414
},
15+
"require-dev": {
16+
"phpunit/phpunit": "4.1.0"
17+
},
1518
"autoload": {
1619
"psr-4": {
1720
"Magento\\": "app/code/Magento/"
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
use Magento\Composer\ConsoleArrayInputFactory;
8+
9+
class ConsoleArrayInputFactoryTest extends PHPUnit_Framework_TestCase {
10+
11+
/**
12+
* @var ConsoleArrayInputFactory
13+
*/
14+
protected $factory;
15+
16+
protected function setUp()
17+
{
18+
$this->factory = new ConsoleArrayInputFactory();
19+
}
20+
21+
public function testCreate()
22+
{
23+
$this->assertInstanceOf('\Symfony\Component\Console\Input\ArrayInput', $this->factory->create([]));
24+
}
25+
}
26+

phpunit.xml.dist

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd"
5+
backupGlobals="false"
6+
colors="true"
7+
bootstrap="vendor/autoload.php"
8+
>
9+
<php>
10+
<ini name="error_reporting" value="-1" />
11+
</php>
12+
13+
<testsuites>
14+
<testsuite name="Magento Composer Library Test">
15+
<directory>./dev/tests/unit/</directory>
16+
</testsuite>
17+
</testsuites>
18+
19+
<filter>
20+
<whitelist>
21+
<directory>./</directory>
22+
<exclude>
23+
<directory>./dev/tests/unit</directory>
24+
</exclude>
25+
</whitelist>
26+
</filter>
27+
</phpunit>

0 commit comments

Comments
 (0)