Skip to content

Commit 5d1590c

Browse files
authored
Merge pull request #1160 from magento-nord/MAGETWO-67358
Fixed - MAGETWO-67358: Remove unused code from Web Setup Wizard
2 parents bdbab10 + 3201636 commit 5d1590c

File tree

2 files changed

+3
-194
lines changed

2 files changed

+3
-194
lines changed

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

Lines changed: 2 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,9 @@ class SystemPackage
3131
*/
3232
private $composerInfo;
3333

34-
/**#@+
35-
* Constants for different Magento editions
36-
*/
3734
const EDITION_COMMUNITY = 'magento/product-community-edition';
35+
3836
const EDITION_ENTERPRISE = 'magento/product-enterprise-edition';
39-
const EDITION_B2B = 'magento/product-b2b-edition';
40-
/**#@-*/
4137

4238
/**
4339
* Constructor
@@ -63,7 +59,6 @@ public function __construct(
6359
public function getPackageVersions()
6460
{
6561
$currentCE = '0';
66-
$currentEE = $currentCE;
6762

6863
$result = [];
6964
$systemPackages = $this->getInstalledSystemPackages();
@@ -79,10 +74,6 @@ public function getPackageVersions()
7974
$currentCE = $systemPackageInfo[InfoCommand::CURRENT_VERSION];
8075
}
8176

82-
if ($systemPackageInfo['name'] == static::EDITION_ENTERPRISE) {
83-
$currentEE = $systemPackageInfo[InfoCommand::CURRENT_VERSION];
84-
}
85-
8677
if (count($versions) > 1) {
8778
$versions[0]['name'] .= ' (latest)';
8879
}
@@ -97,12 +88,6 @@ public function getPackageVersions()
9788
$result = array_merge($this->getAllowedEnterpriseVersions($currentCE), $result);
9889
}
9990

100-
if (in_array(static::EDITION_ENTERPRISE, $systemPackages)
101-
&& !in_array(static::EDITION_B2B, $systemPackages)
102-
) {
103-
$result = array_merge($this->getAllowedB2BVersions($currentEE), $result);
104-
}
105-
10691
$result = $this->formatPackages($result);
10792

10893
return $result;
@@ -137,63 +122,6 @@ public function getAllowedEnterpriseVersions($currentCE)
137122
return $result;
138123
}
139124

140-
/**
141-
* Retrieve allowed B2B versions
142-
*
143-
* @param string $currentEE
144-
* @return array
145-
*/
146-
public function getAllowedB2BVersions($currentEE)
147-
{
148-
$result = [];
149-
$versions = $this->fetchInfoVersions(static::EDITION_B2B);
150-
$versionsPrepared = [];
151-
$maxVersion = '';
152-
153-
if ($versions[InfoCommand::AVAILABLE_VERSIONS]) {
154-
$versions = $this->sortVersions($versions);
155-
if (isset($versions[InfoCommand::AVAILABLE_VERSIONS][0])) {
156-
$maxVersion = $versions[InfoCommand::AVAILABLE_VERSIONS][0];
157-
}
158-
$versionsPrepared = $this->filterB2bVersions($currentEE, $versions, $maxVersion);
159-
}
160-
161-
if ($versionsPrepared) {
162-
$result[] = [
163-
'package' => static::EDITION_B2B,
164-
'versions' => $versionsPrepared,
165-
];
166-
}
167-
168-
return $result;
169-
}
170-
171-
/**
172-
* Fetching of info command response to display all correct versions
173-
*
174-
* @param string $command
175-
* @return array
176-
*/
177-
private function fetchInfoVersions($command)
178-
{
179-
$versions = (array)$this->infoCommand->run($command);
180-
181-
$versions[InfoCommand::CURRENT_VERSION] = isset($versions[InfoCommand::CURRENT_VERSION])
182-
? $versions[InfoCommand::CURRENT_VERSION]
183-
: null;
184-
$versions[InfoCommand::AVAILABLE_VERSIONS] = isset($versions[InfoCommand::AVAILABLE_VERSIONS])
185-
? $versions[InfoCommand::AVAILABLE_VERSIONS]
186-
: null;
187-
$versions[InfoCommand::AVAILABLE_VERSIONS] = array_unique(
188-
array_merge(
189-
(array)$versions[InfoCommand::CURRENT_VERSION],
190-
(array)$versions[InfoCommand::AVAILABLE_VERSIONS]
191-
)
192-
);
193-
194-
return $versions;
195-
}
196-
197125
/**
198126
* Retrieve package versions
199127
*
@@ -209,8 +137,6 @@ public function getSystemPackageVersions($systemPackageInfo)
209137
$editionType .= 'CE';
210138
} elseif ($systemPackageInfo['name'] == static::EDITION_ENTERPRISE) {
211139
$editionType .= 'EE';
212-
} elseif ($systemPackageInfo['name'] == static::EDITION_B2B) {
213-
$editionType .= 'B2B';
214140
}
215141

216142
foreach ($systemPackageInfo[InfoCommand::NEW_VERSIONS] as $version) {
@@ -229,6 +155,7 @@ public function getSystemPackageVersions($systemPackageInfo)
229155

230156
/**
231157
* @return array
158+
* @throws \Exception
232159
* @throws \RuntimeException
233160
*/
234161
public function getInstalledSystemPackages()
@@ -342,36 +269,4 @@ public function filterEeVersions($currentCE, $enterpriseVersions, $maxVersion)
342269
}
343270
return $eeVersions;
344271
}
345-
346-
/**
347-
* Filtering B2B versions
348-
*
349-
* @param string $currentEE
350-
* @param array $b2bVersions
351-
* @param string $maxVersion
352-
* @return array
353-
*/
354-
public function filterB2bVersions($currentEE, $b2bVersions, $maxVersion)
355-
{
356-
$b2bVersionsPrepared = [];
357-
foreach ($b2bVersions[InfoCommand::AVAILABLE_VERSIONS] as $version) {
358-
$requires = $this->composerInfo->getPackageRequirements(static::EDITION_B2B, $version);
359-
if (array_key_exists(static::EDITION_ENTERPRISE, $requires)) {
360-
/** @var \Composer\Package\Link $eeRequire */
361-
$eeRequire = $requires[static::EDITION_ENTERPRISE];
362-
if (version_compare(
363-
$eeRequire->getConstraint()->getPrettyString(),
364-
$currentEE,
365-
'>='
366-
)) {
367-
$name = 'Version ' . $version . ' B2B';
368-
if ($maxVersion == $version) {
369-
$name .= ' (latest)';
370-
}
371-
$b2bVersionsPrepared[] = ['id' => $version, 'name' => $name, 'current' => false];
372-
}
373-
}
374-
}
375-
return $b2bVersionsPrepared;
376-
}
377272
}

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

Lines changed: 1 addition & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -214,24 +214,7 @@ public function testGetPackageVersions()
214214
'new_versions' => ['1.2.0', '1.1.0', '1.1.0-RC1'],
215215
],
216216

217-
],
218-
[
219-
220-
SystemPackage::EDITION_B2B,
221-
false,
222-
[
223-
'name' => SystemPackage::EDITION_B2B,
224-
'description' => 'eCommerce Platform for Growth (B2B Edition)',
225-
'keywords' => '',
226-
'versions' => '1.2.0, 1.1.0, 1.1.0-RC1, * 1.0.0',
227-
'type' => 'metapackage',
228-
'license' => 'OSL-3.0, AFL-3.0',
229-
'source' => '[]',
230-
'names' => SystemPackage::EDITION_B2B,
231-
InfoCommand::AVAILABLE_VERSIONS => [],
232-
'new_versions' => ['1.2.0', '1.1.0', '1.1.0-RC1'],
233-
],
234-
],
217+
]
235218
]);
236219
$this->assertEquals($this->expectedPackages, $this->systemPackage->getPackageVersions());
237220
}
@@ -340,39 +323,6 @@ public function testGetAllowedEnterpriseVersions($ceCurrentVersion, $expectedRes
340323
);
341324
}
342325

343-
/**
344-
* @param string $eeCurrentVersion
345-
* @param array $expectedResult
346-
*
347-
* @dataProvider getAllowedB2bVersionsDataProvider
348-
*/
349-
public function testGetAllowedB2bVersions($eeCurrentVersion, $expectedResult)
350-
{
351-
$this->composerAppFactory->expects($this->once())
352-
->method('createInfoCommand')
353-
->willReturn($this->infoCommand);
354-
$this->systemPackage = new SystemPackage($this->composerAppFactory, $this->composerInformation);
355-
$this->infoCommand->expects($this->once())
356-
->method('run')
357-
->with(SystemPackage::EDITION_B2B)
358-
->willReturn([InfoCommand::AVAILABLE_VERSIONS => ['1.0.0', '1.0.1', '1.0.2']]);
359-
$require = $this->getMock(\Composer\Package\Link::class, [], [], '', false);
360-
$constraintMock = $this->getMock(\Composer\Semver\Constraint\Constraint::class, [], [], '', false);
361-
$constraintMock->expects($this->any())->method('getPrettyString')
362-
->willReturn('1.0.1');
363-
$require->expects($this->any())
364-
->method('getConstraint')
365-
->willReturn($constraintMock);
366-
367-
$this->composerInformation->expects($this->any())
368-
->method('getPackageRequirements')
369-
->willReturn([SystemPackage::EDITION_ENTERPRISE => $require]);
370-
$this->assertEquals(
371-
$expectedResult,
372-
$this->systemPackage->getAllowedB2BVersions($eeCurrentVersion)
373-
);
374-
}
375-
376326
/**
377327
* @return array
378328
*/
@@ -408,40 +358,4 @@ public function getAllowedEnterpriseVersionsDataProvider()
408358
],
409359
];
410360
}
411-
412-
/**
413-
* @return array
414-
*/
415-
public function getAllowedB2bVersionsDataProvider()
416-
{
417-
return [
418-
['2.0.0', []],
419-
[
420-
'1.0.0',
421-
[
422-
[
423-
'package' => SystemPackage::EDITION_B2B,
424-
'versions' => [
425-
[
426-
'id' => '1.0.2',
427-
'name' => 'Version 1.0.2 B2B (latest)',
428-
'current' => false,
429-
],
430-
[
431-
'id' => '1.0.1',
432-
'name' => 'Version 1.0.1 B2B',
433-
'current' => false,
434-
],
435-
[
436-
437-
'id' => '1.0.0',
438-
'name' => 'Version 1.0.0 B2B',
439-
'current' => false,
440-
],
441-
],
442-
],
443-
],
444-
],
445-
];
446-
}
447361
}

0 commit comments

Comments
 (0)