public function testCheckPhpExtensionsFailed()
 {
     $this->composerInfo->expects($this->once())->method('getRequiredExtensions')->willReturn(['a', 'b', 'c']);
     $this->phpInfo->expects($this->once())->method('getCurrent')->willReturn(['a', 'b']);
     $expected = ['responseType' => ResponseTypeInterface::RESPONSE_TYPE_ERROR, 'data' => ['required' => ['a', 'b', 'c'], 'missing' => ['c']]];
     $this->assertEquals($expected, $this->phpReadinessCheck->checkPhpExtensions());
 }
예제 #2
0
    /**
     * Checks if xdebug.max_nesting_level is set 200 or more
     * @return array
     */
    private function checkXDebugNestedLevel()
    {
        $data = [];
        $error = false;

        $currentExtensions = $this->phpInformation->getCurrent();
        if (in_array('xdebug', $currentExtensions)) {

            $currentXDebugNestingLevel = intval(ini_get('xdebug.max_nesting_level'));
            $minimumRequiredXDebugNestedLevel = $this->phpInformation->getRequiredMinimumXDebugNestedLevel();

            if ($minimumRequiredXDebugNestedLevel > $currentXDebugNestingLevel) {
                $error = true;
            }

            $message = sprintf(
                'Your current setting of xdebug.max_nesting_level=%d.
                 Magento 2 requires it to be set to %d or more.
                 Edit your config, restart web server, and try again.',
                $currentXDebugNestingLevel,
                $minimumRequiredXDebugNestedLevel
            );

            $data['xdebug_max_nesting_level'] = [
                'message' => $message,
                'error' => $error
            ];
        }

        return $data;
    }
예제 #3
0
 /**
  * Verifies php verifications
  *
  * @return JsonModel
  */
 public function phpExtensionsAction()
 {
     try {
         $required = $this->phpInformation->getRequired();
         $current = $this->phpInformation->getCurrent();
     } catch (\Exception $e) {
         return new JsonModel(['responseType' => ResponseTypeInterface::RESPONSE_TYPE_ERROR, 'data' => ['error' => 'phpExtensionError', 'message' => 'Cannot determine required PHP extensions: ' . $e->getMessage()]]);
     }
     $responseType = ResponseTypeInterface::RESPONSE_TYPE_SUCCESS;
     $missing = array_values(array_diff($required, $current));
     if ($missing) {
         $responseType = ResponseTypeInterface::RESPONSE_TYPE_ERROR;
     }
     $data = ['responseType' => $responseType, 'data' => ['required' => $required, 'missing' => $missing]];
     return new JsonModel($data);
 }
 public function testGetRequiredMinimumXDebugNestedLevel()
 {
     $phpInformation = new PhpInformation();
     $this->assertEquals(200, $phpInformation->getRequiredMinimumXDebugNestedLevel());
 }
 /**
  * @expectedException \Exception
  * @expectedExceptionMessage Missing key 'packages' in 'composer.lock' file
  */
 public function testGetRequiredExceptionMissingPackages()
 {
     $this->directoryReadMock->expects($this->once())->method('isExist')->will($this->returnValue(true));
     $this->directoryReadMock->expects($this->once())->method('readFile')->with('composer.lock')->will($this->returnValue('{"platform-dev":{"ext-e":"*", "f":"*"}}'));
     $phpInfo = new PhpInformation($this->filesystemMock);
     $phpInfo->getRequired();
 }