17 private $composerInfo;
27 private $versionParser;
39 private $phpReadinessCheck;
43 $this->composerInfo = $this->createMock(\
Magento\Framework\Composer\ComposerInformation::class);
44 $this->phpInfo = $this->createMock(\
Magento\
Setup\Model\PhpInformation::class);
45 $this->versionParser = $this->createMock(\Composer\Package\Version\VersionParser::class);
46 $this->dataSize = $this->createMock(\
Magento\Framework\Convert\DataSize::class);
57 $this->composerInfo->expects($this->once())
58 ->method(
'getRequiredPhpVersion')
63 'error' =>
'phpVersionError',
64 'message' =>
'Cannot determine required PHP version: ' 67 $this->assertEquals($expected, $this->phpReadinessCheck->checkPhpVersion());
72 $this->composerInfo->expects($this->once())->method(
'getRequiredPhpVersion')->willReturn(
'1.0');
73 $multipleConstraints = $this->getMockForAbstractClass(
74 \Composer\Semver\Constraint\ConstraintInterface::class,
79 $this->versionParser->expects($this->at(0))->method(
'parseConstraints')->willReturn($multipleConstraints);
80 $this->versionParser->expects($this->at(1))
82 ->willThrowException(
new \UnexpectedValueException());
83 $this->versionParser->expects($this->at(2))->method(
'normalize')->willReturn(
'1.0');
84 $currentPhpVersion = $this->getMockForAbstractClass(
85 \Composer\Semver\Constraint\ConstraintInterface::class,
90 $this->versionParser->expects($this->at(3))->method(
'parseConstraints')->willReturn($currentPhpVersion);
91 $multipleConstraints->expects($this->once())->method(
'matches')->willReturn(
true);
96 'current' => PHP_VERSION,
99 $this->assertEquals($expected, $this->phpReadinessCheck->checkPhpVersion());
104 $this->composerInfo->expects($this->once())->method(
'getRequiredPhpVersion')->willReturn(
'1.0');
105 $multipleConstraints = $this->getMockForAbstractClass(
106 \Composer\Semver\Constraint\ConstraintInterface::class,
111 $this->versionParser->expects($this->at(0))->method(
'parseConstraints')->willReturn($multipleConstraints);
112 $this->versionParser->expects($this->at(1))
113 ->method(
'normalize')
114 ->willThrowException(
new \UnexpectedValueException());
115 $this->versionParser->expects($this->at(2))->method(
'normalize')->willReturn(
'1.0');
116 $currentPhpVersion = $this->getMockForAbstractClass(
117 \Composer\Semver\Constraint\ConstraintInterface::class,
122 $this->versionParser->expects($this->at(3))->method(
'parseConstraints')->willReturn($currentPhpVersion);
123 $multipleConstraints->expects($this->once())->method(
'matches')->willReturn(
false);
128 'current' => PHP_VERSION,
131 $this->assertEquals($expected, $this->phpReadinessCheck->checkPhpVersion());
134 private function setUpNoPrettyVersionParser()
136 $multipleConstraints = $this->getMockForAbstractClass(
137 \Composer\Semver\Constraint\ConstraintInterface::class,
142 $this->versionParser->expects($this->at(0))->method(
'parseConstraints')->willReturn($multipleConstraints);
143 $this->versionParser->expects($this->at(1))->method(
'normalize')->willReturn(
'1.0');
144 $currentPhpVersion = $this->getMockForAbstractClass(
145 \Composer\Semver\Constraint\ConstraintInterface::class,
150 $this->versionParser->expects($this->at(2))->method(
'parseConstraints')->willReturn($currentPhpVersion);
151 $multipleConstraints->expects($this->once())->method(
'matches')->willReturn(
true);
156 $this->composerInfo->expects($this->once())->method(
'getRequiredPhpVersion')->willReturn(
'1.0');
158 $this->setUpNoPrettyVersionParser();
163 'current' => PHP_VERSION,
166 $this->assertEquals($expected, $this->phpReadinessCheck->checkPhpVersion());
171 $this->composerInfo->expects($this->once())->method(
'getRequiredPhpVersion')->willReturn(
'1.0');
172 $multipleConstraints = $this->getMockForAbstractClass(
173 \Composer\Semver\Constraint\ConstraintInterface::class,
178 $this->versionParser->expects($this->at(0))->method(
'parseConstraints')->willReturn($multipleConstraints);
179 $this->versionParser->expects($this->at(1))->method(
'normalize')->willReturn(
'1.0');
180 $currentPhpVersion = $this->getMockForAbstractClass(
181 \Composer\Semver\Constraint\ConstraintInterface::class,
186 $this->versionParser->expects($this->at(2))->method(
'parseConstraints')->willReturn($currentPhpVersion);
187 $multipleConstraints->expects($this->once())->method(
'matches')->willReturn(
false);
192 'current' => PHP_VERSION,
195 $this->assertEquals($expected, $this->phpReadinessCheck->checkPhpVersion());
200 $this->phpInfo->expects($this->once())->method(
'getCurrent')->willReturn([
'xdebug']);
201 $this->phpInfo->expects($this->once())->method(
'getRequiredMinimumXDebugNestedLevel')->willReturn(50);
202 $xdebugMessage = sprintf(
203 'Your current setting of xdebug.max_nesting_level=%d. 204 Magento 2 requires it to be set to %d or more. 205 Edit your config, restart web server, and try again.',
210 $rawPostMessage = sprintf(
211 'Your PHP Version is %s, but always_populate_raw_post_data = -1. 212 $HTTP_RAW_POST_DATA is deprecated from PHP 5.6 onwards and will be removed in PHP 7.0. 213 This will stop the installer from running. 214 Please open your php.ini file and set always_populate_raw_post_data to -1. 215 If you need more help please call your hosting provider.',
221 'xdebug_max_nesting_level' => [
222 'message' => $xdebugMessage,
225 'missed_function_imagecreatefromjpeg' => [
226 'message' =>
'You must have installed GD library with --with-jpeg-dir=DIR option.',
227 'helpUrl' =>
'http://php.net/manual/en/image.installation.php',
233 $this->setUpNoPrettyVersionParser();
234 $expected[
'data'][
'always_populate_raw_post_data'] = [
235 'message' => $rawPostMessage,
236 'helpUrl' =>
'http://php.net/manual/en/ini.core.php#ini.always-populate-settings-data',
240 $this->assertEquals($expected, $this->phpReadinessCheck->checkPhpSettings());
245 $this->phpInfo->expects($this->once())->method(
'getCurrent')->willReturn([
'xdebug']);
246 $this->phpInfo->expects($this->once())->method(
'getRequiredMinimumXDebugNestedLevel')->willReturn(200);
247 $xdebugMessage = sprintf(
248 'Your current setting of xdebug.max_nesting_level=%d. 249 Magento 2 requires it to be set to %d or more. 250 Edit your config, restart web server, and try again.',
255 $rawPostMessage = sprintf(
256 'Your PHP Version is %s, but always_populate_raw_post_data = -1. 257 $HTTP_RAW_POST_DATA is deprecated from PHP 5.6 onwards and will be removed in PHP 7.0. 258 This will stop the installer from running. 259 Please open your php.ini file and set always_populate_raw_post_data to -1. 260 If you need more help please call your hosting provider.',
266 'xdebug_max_nesting_level' => [
267 'message' => $xdebugMessage,
270 'missed_function_imagecreatefromjpeg' => [
271 'message' =>
'You must have installed GD library with --with-jpeg-dir=DIR option.',
272 'helpUrl' =>
'http://php.net/manual/en/image.installation.php',
278 $this->setUpNoPrettyVersionParser();
279 $expected[
'data'][
'always_populate_raw_post_data'] = [
280 'message' => $rawPostMessage,
281 'helpUrl' =>
'http://php.net/manual/en/ini.core.php#ini.always-populate-settings-data',
285 $this->assertEquals($expected, $this->phpReadinessCheck->checkPhpSettings());
290 $this->phpInfo->expects($this->once())->method(
'getCurrent')->willReturn([]);
292 $rawPostMessage = sprintf(
293 'Your PHP Version is %s, but always_populate_raw_post_data = -1. 294 $HTTP_RAW_POST_DATA is deprecated from PHP 5.6 onwards and will be removed in PHP 7.0. 295 This will stop the installer from running. 296 Please open your php.ini file and set always_populate_raw_post_data to -1. 297 If you need more help please call your hosting provider.',
305 $this->setUpNoPrettyVersionParser();
306 $expected[
'data'] = [
307 'always_populate_raw_post_data' => [
308 'message' => $rawPostMessage,
309 'helpUrl' =>
'http://php.net/manual/en/ini.core.php#ini.always-populate-settings-data',
315 $expected[
'data'][
'missed_function_imagecreatefromjpeg'] = [
316 'message' =>
'You must have installed GD library with --with-jpeg-dir=DIR option.',
317 'helpUrl' =>
'http://php.net/manual/en/image.installation.php',
321 $this->assertEquals($expected, $this->phpReadinessCheck->checkPhpSettings());
327 $this->dataSize->expects($this->any())->method(
'convertSizeToBytes')->willReturnMap(
337 'Your current PHP memory limit is 512M. 338 Magento 2 requires it to be set to 756M or more. 339 As a user with root privileges, edit your php.ini file to increase memory_limit. 340 (The command php --ini tells you where it is located.) 341 After that, restart your web server and try again.';
343 $expected[
'memory_limit'] = [
344 'message' => $rawPostMessage,
349 $this->assertEquals($expected, $this->phpReadinessCheck->checkMemoryLimit());
354 $this->composerInfo->expects($this->once())
355 ->method(
'getRequiredExtensions')
360 'error' =>
'phpExtensionError',
361 'message' =>
'Cannot determine required PHP extensions: ' 364 $this->assertEquals($expected, $this->phpReadinessCheck->checkPhpExtensions());
369 $this->composerInfo->expects($this->once())
370 ->method(
'getRequiredExtensions')
371 ->willReturn([
'a',
'b',
'c']);
372 $this->phpInfo->expects($this->once())
373 ->method(
'getCurrent')
374 ->willReturn([
'a',
'b',
'c',
'd']);
378 'required' => [
'a',
'b',
'c'],
382 $this->assertEquals($expected, $this->phpReadinessCheck->checkPhpExtensions());
387 $this->composerInfo->expects($this->once())
388 ->method(
'getRequiredExtensions')
389 ->willReturn([
'a',
'b',
'c']);
390 $this->phpInfo->expects($this->once())
391 ->method(
'getCurrent')
392 ->willReturn([
'a',
'b']);
396 'required' => [
'a',
'b',
'c'],
400 $this->assertEquals($expected, $this->phpReadinessCheck->checkPhpExtensions());
408 return version_compare(PHP_VERSION,
'7.0.0-beta') >= 0 || defined(
'HHVM_VERSION');
420 if ($param ===
'xdebug.max_nesting_level') {
422 }
elseif ($param ===
'always_populate_raw_post_data') {
424 }
elseif ($param ===
'memory_limit') {
testCheckPhpSettingsNoXDebug()
elseif(isset( $params[ 'redirect_parent']))
testCheckPhpVersionPrettyVersionFailed()
testCheckPhpVersionFailed()
const RESPONSE_TYPE_SUCCESS
testCheckPhpExtensionsFailed()
testCheckPhpVersionPrettyVersion()
const RESPONSE_TYPE_ERROR
testCheckPhpVersionNoRequiredVersion()
testCheckPhpSettingsFailed()
testCheckPhpExtensionsNoRequired()
testCheckPhpSettingsMemoryLimitError()