22 private $systemPackage;
37 private $magentoComposerApp;
42 private $composerAppFactory;
52 private $expectedPackages = [
55 'name' =>
'Version 1.2.0 EE (latest)',
62 'name' =>
'Version 1.2.0 CE (latest)',
69 'name' =>
'Version 1.1.0 EE',
76 'name' =>
'Version 1.1.0 CE',
83 'name' =>
'Version 1.1.0-RC1 EE (unstable version)',
90 'name' =>
'Version 1.1.0-RC1 CE (unstable version)',
97 'name' =>
'Version 1.0.0 EE',
104 'name' =>
'Version 1.0.0 CE',
114 private $composerInformation;
118 $this->composerAppFactory = $this->createMock(
119 \
Magento\Framework\Composer\MagentoComposerApplicationFactory::class
122 $this->infoCommand = $this->createMock(
123 \
Magento\Composer\InfoCommand::class
126 $this->magentoComposerApp =
127 $this->createMock(\
Magento\Composer\MagentoComposerApplication::class);
128 $this->locker = $this->createMock(\Composer\Package\Locker::class);
129 $this->repository = $this->createMock(\Composer\Repository\ArrayRepository::class);
130 $this->composer = $this->createMock(\Composer\Composer::class);
131 $this->composerInformation = $this->createMock(
132 \
Magento\Framework\Composer\ComposerInformation::class
138 $communityPackage = $this->createMock(\Composer\Package\Package::class);
140 $enterprisePackage = $this->createMock(\Composer\Package\Package::class);
142 $this->composerInformation->expects($this->any())->method(
'isSystemPackage')->willReturn(
true);
143 $this->composerInformation->expects($this->once())->method(
'isPackageInComposerJson')->willReturn(
true);
145 ->expects($this->once())
146 ->method(
'getPackages')
147 ->willReturn([$communityPackage, $enterprisePackage]);
149 $this->locker->expects($this->once())->method(
'getLockedRepository')->willReturn($this->repository);
151 $this->composer->expects($this->once())->method(
'getLocker')->willReturn($this->locker);
152 $this->magentoComposerApp->expects($this->once())->method(
'createComposer')->willReturn($this->composer);
154 $this->composerAppFactory->expects($this->once())
155 ->method(
'createInfoCommand')
156 ->willReturn($this->infoCommand);
158 $this->composerAppFactory->expects($this->once())
160 ->willReturn($this->magentoComposerApp);
162 $this->composerAppFactory->expects($this->once())
163 ->method(
'createInfoCommand')
164 ->willReturn($this->infoCommand);
166 $this->systemPackage =
new SystemPackage($this->composerAppFactory, $this->composerInformation);
168 $this->infoCommand->expects($this->any())
176 'description' =>
'eCommerce Platform for Growth (Enterprise Edition)',
178 'versions' =>
'1.2.0, 1.1.0, 1.1.0-RC1, * 1.0.0',
179 'type' =>
'metapackage',
180 'license' =>
'OSL-3.0, AFL-3.0',
183 'current_version' =>
'1.0.0',
185 'new_versions' => [
'1.2.0',
'1.1.0',
'1.1.0-RC1'],
193 'description' =>
'eCommerce Platform for Growth (Enterprise Edition)',
195 'versions' =>
'1.2.0, 1.1.0, 1.1.0-RC1, * 1.0.0',
196 'type' =>
'metapackage',
197 'license' =>
'OSL-3.0, AFL-3.0',
200 'current_version' =>
'1.0.0',
202 'new_versions' => [
'1.2.0',
'1.1.0',
'1.1.0-RC1'],
207 $this->assertEquals($this->expectedPackages, $this->systemPackage->getPackageVersions());
216 $package = $this->createMock(\Composer\Package\Package::class);
218 ->expects($this->once())
219 ->method(
'getPackages')
220 ->willReturn([$package]);
222 $this->locker->expects($this->once())->method(
'getLockedRepository')->willReturn($this->repository);
223 $this->composerInformation->expects($this->any())->method(
'isSystemPackage')->willReturn(
false);
224 $this->composer->expects($this->once())->method(
'getLocker')->willReturn($this->locker);
225 $this->magentoComposerApp->expects($this->once())->method(
'createComposer')->willReturn($this->composer);
227 $this->composerAppFactory->expects($this->once())
229 ->willReturn($this->magentoComposerApp);
231 $this->composerAppFactory->expects($this->once())
232 ->method(
'createInfoCommand')
233 ->willReturn($this->infoCommand);
235 $this->systemPackage =
new SystemPackage($this->composerAppFactory, $this->composerInformation);
236 $this->systemPackage->getPackageVersions();
245 $communityPackage = $this->createMock(\Composer\Package\Package::class);
246 $enterprisePackage = $this->createMock(\Composer\Package\Package::class);
250 $this->composerInformation->expects($this->any())->method(
'isSystemPackage')->willReturn(
true);
251 $this->composerInformation->expects($this->once())->method(
'isPackageInComposerJson')->willReturn(
true);
254 ->expects($this->once())
255 ->method(
'getPackages')
256 ->willReturn([$communityPackage, $enterprisePackage]);
258 $this->locker->expects($this->once())->method(
'getLockedRepository')->willReturn($this->repository);
260 $this->composer->expects($this->once())->method(
'getLocker')->willReturn($this->locker);
261 $this->magentoComposerApp->expects($this->once())->method(
'createComposer')->willReturn($this->composer);
263 $this->composerAppFactory->expects($this->once())
265 ->willReturn($this->magentoComposerApp);
267 $this->composerAppFactory->expects($this->once())
268 ->method(
'createInfoCommand')
269 ->willReturn($this->infoCommand);
271 $this->systemPackage =
new SystemPackage($this->composerAppFactory, $this->composerInformation);
273 $this->infoCommand->expects($this->once())
278 $this->systemPackage->getPackageVersions();
289 $this->composerAppFactory->expects($this->once())
290 ->method(
'createInfoCommand')
291 ->willReturn($this->infoCommand);
292 $this->systemPackage =
new SystemPackage($this->composerAppFactory, $this->composerInformation);
293 $this->infoCommand->expects($this->once())
297 $require = $this->createMock(\Composer\Package\Link::class);
298 $constraintMock = $this->createMock(\Composer\Semver\Constraint\Constraint::class);
299 $constraintMock->expects($this->any())->method(
'getPrettyString')
300 ->willReturn(
'1.0.1');
301 $require->expects($this->any())
302 ->method(
'getConstraint')
303 ->willReturn($constraintMock);
305 $this->composerInformation->expects($this->any())
306 ->method(
'getPackageRequirements')
310 $this->systemPackage->getAllowedEnterpriseVersions($ceCurrentVersion)
329 'name' =>
'Version 1.0.2 EE (latest)',
334 'name' =>
'Version 1.0.1 EE',
340 'name' =>
'Version 1.0.0 EE',
testGetPackageVersionGitCloned()
getAllowedEnterpriseVersionsDataProvider()
testGetPackageVersionsFailed()
testGetAllowedEnterpriseVersions($ceCurrentVersion, $expectedResult)