Skip to content

Commit 097dff1

Browse files
MAGETWO-56873: B2B does not supports in Web Setup Wizard
1 parent 9671f02 commit 097dff1

File tree

2 files changed

+87
-54
lines changed

2 files changed

+87
-54
lines changed

setup/src/Magento/Setup/Model/SystemPackage.php

Lines changed: 34 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -134,34 +134,16 @@ public function getAllowedEnterpriseVersions($currentCE)
134134
/**
135135
* Retrieve allowed B2B versions
136136
*
137-
* @param $currentEE
137+
* @param string $currentEE
138138
* @return array
139139
*/
140140
public function getAllowedB2BVersions($currentEE)
141141
{
142142
$result = [];
143-
$versions = $this->infoCommand->run('magento/product-b2b-edition');
143+
$versions = $this->fetchInfoVersions('magento/product-b2b-edition');
144144
$versionsPrepared = [];
145145
$maxVersion = '';
146146

147-
if (!is_array($versions) ) {
148-
return $result;
149-
}
150-
151-
$versions[InfoCommand::CURRENT_VERSION] = isset($versions[InfoCommand::CURRENT_VERSION])
152-
? $versions[InfoCommand::CURRENT_VERSION]
153-
: null;
154-
$versions[InfoCommand::AVAILABLE_VERSIONS] = isset($versions[InfoCommand::AVAILABLE_VERSIONS])
155-
? $versions[InfoCommand::AVAILABLE_VERSIONS]
156-
: [];
157-
158-
$versions[InfoCommand::AVAILABLE_VERSIONS] = array_unique(
159-
array_merge(
160-
(array)$versions[InfoCommand::CURRENT_VERSION],
161-
(array)$versions[InfoCommand::AVAILABLE_VERSIONS]
162-
)
163-
);
164-
165147
if ($versions[InfoCommand::AVAILABLE_VERSIONS]) {
166148
$versions = $this->sortVersions($versions);
167149
if (isset($versions[InfoCommand::AVAILABLE_VERSIONS][0])) {
@@ -180,6 +162,30 @@ public function getAllowedB2BVersions($currentEE)
180162
return $result;
181163
}
182164

165+
/**
166+
* Fetching info command response to
167+
* display all correct versions
168+
*
169+
* @param string $command
170+
* @return array
171+
*/
172+
private function fetchInfoVersions($command)
173+
{
174+
$versions = (array)$this->infoCommand->run($command);
175+
176+
$versions[InfoCommand::CURRENT_VERSION] = isset($versions[InfoCommand::CURRENT_VERSION])
177+
? $versions[InfoCommand::CURRENT_VERSION]
178+
: null;
179+
$versions[InfoCommand::AVAILABLE_VERSIONS] = array_unique(
180+
array_merge(
181+
(array)$versions[InfoCommand::CURRENT_VERSION],
182+
(array)$versions[InfoCommand::AVAILABLE_VERSIONS]
183+
)
184+
);
185+
186+
return $versions;
187+
}
188+
183189
/**
184190
* Retrieve package versions
185191
*
@@ -331,6 +337,14 @@ public function filterEeVersions($currentCE, $enterpriseVersions, $maxVersion)
331337
return $eeVersions;
332338
}
333339

340+
/**
341+
* Filtering B2B versions
342+
*
343+
* @param string $currentEE
344+
* @param array $b2bVersions
345+
* @param string $maxVersion
346+
* @return array
347+
*/
334348
public function filterB2bVersions($currentEE, $b2bVersions, $maxVersion)
335349
{
336350
$b2bVersionsPrepared = [];

setup/src/Magento/Setup/Test/Unit/Model/SystemPackageTest.php

Lines changed: 53 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -176,43 +176,62 @@ public function testGetPackageVersions()
176176

177177
$this->systemPackage = new SystemPackage($this->composerAppFactory, $this->composerInformation);
178178

179-
$this->infoCommand->expects($this->at(0))
179+
$this->infoCommand->expects($this->any())
180180
->method('run')
181-
->with('magento/product-community-edition')
182-
->willReturn(
181+
->willReturnMap([
183182
[
184-
'name' => 'magento/product-community-edition',
185-
'description' => 'eCommerce Platform for Growth (Enterprise Edition)',
186-
'keywords' => '',
187-
'versions' => '1.2.0, 1.1.0, 1.1.0-RC1, * 1.0.0',
188-
'type' => 'metapackage',
189-
'license' => 'OSL-3.0, AFL-3.0',
190-
'source' => '[]',
191-
'names' => 'magento/product-community-edition',
192-
'current_version' => '1.0.0',
193-
'available_versions' => [1 => '1.2.0', 2 => '1.1.0', 3 => '1.1.0-RC1', 4 => '1.0.0'],
194-
'new_versions' => ['1.2.0', '1.1.0', '1.1.0-RC1'],
195-
]
196-
);
197-
198-
$this->infoCommand->expects($this->at(1))
199-
->method('run')
200-
->with('magento/product-enterprise-edition')
201-
->willReturn(
183+
'magento/product-community-edition',
184+
false,
185+
[
186+
'name' => 'magento/product-community-edition',
187+
'description' => 'eCommerce Platform for Growth (Enterprise Edition)',
188+
'keywords' => '',
189+
'versions' => '1.2.0, 1.1.0, 1.1.0-RC1, * 1.0.0',
190+
'type' => 'metapackage',
191+
'license' => 'OSL-3.0, AFL-3.0',
192+
'source' => '[]',
193+
'names' => 'magento/product-community-edition',
194+
'current_version' => '1.0.0',
195+
'available_versions' => [1 => '1.2.0', 2 => '1.1.0', 3 => '1.1.0-RC1', 4 => '1.0.0'],
196+
'new_versions' => ['1.2.0', '1.1.0', '1.1.0-RC1'],
197+
],
198+
],
202199
[
203-
'name' => 'magento/product-enterprise-edition',
204-
'description' => 'eCommerce Platform for Growth (Enterprise Edition)',
205-
'keywords' => '',
206-
'versions' => '1.2.0, 1.1.0, 1.1.0-RC1, * 1.0.0',
207-
'type' => 'metapackage',
208-
'license' => 'OSL-3.0, AFL-3.0',
209-
'source' => '[]',
210-
'names' => 'magento/product-enterprise-edition',
211-
'current_version' => '1.0.0',
212-
'available_versions' => [1 => '1.2.0', 2 => '1.1.0', 3 => '1.1.0-RC1', 4 => '1.0.0'],
213-
'new_versions' => ['1.2.0', '1.1.0', '1.1.0-RC1'],
214-
]
215-
);
200+
'magento/product-enterprise-edition',
201+
false,
202+
[
203+
'name' => 'magento/product-enterprise-edition',
204+
'description' => 'eCommerce Platform for Growth (Enterprise Edition)',
205+
'keywords' => '',
206+
'versions' => '1.2.0, 1.1.0, 1.1.0-RC1, * 1.0.0',
207+
'type' => 'metapackage',
208+
'license' => 'OSL-3.0, AFL-3.0',
209+
'source' => '[]',
210+
'names' => 'magento/product-enterprise-edition',
211+
'current_version' => '1.0.0',
212+
'available_versions' => [1 => '1.2.0', 2 => '1.1.0', 3 => '1.1.0-RC1', 4 => '1.0.0'],
213+
'new_versions' => ['1.2.0', '1.1.0', '1.1.0-RC1'],
214+
],
215+
216+
],
217+
[
218+
219+
'magento/product-b2b-edition',
220+
false,
221+
[
222+
'name' => 'magento/product-b2b-edition',
223+
'description' => 'eCommerce Platform for Growth (B2B Edition)',
224+
'keywords' => '',
225+
'versions' => '1.2.0, 1.1.0, 1.1.0-RC1, * 1.0.0',
226+
'type' => 'metapackage',
227+
'license' => 'OSL-3.0, AFL-3.0',
228+
'source' => '[]',
229+
'names' => 'magento/product-b2b-edition',
230+
'available_versions' => [],
231+
'new_versions' => ['1.2.0', '1.1.0', '1.1.0-RC1'],
232+
],
233+
],
234+
]);
216235
$this->assertEquals($this->expectedPackages, $this->systemPackage->getPackageVersions());
217236
}
218237

0 commit comments

Comments
 (0)