示例#1
0
 /**
  * @covers setError()
  */
 public function testHasError()
 {
     $this->filesystem->expects($this->any())->method('getDirectoryWrite')->willReturn($this->writeInterface);
     $this->writeInterface->expects($this->any())->method('openFile')->willReturnSelf();
     $this->writeInterface->expects($this->any())->method('write')->willReturnSelf();
     $this->writeInterface->expects($this->any())->method('close');
     $this->writeInterface->expects($this->any())->method('isExist')->willReturn(true);
     $this->writeInterface->expects($this->any())->method('read')->willReturn(\Magento\Framework\Setup\SampleData\State::ERROR);
     $this->state->setError();
     $this->assertTrue($this->state->hasError());
 }
示例#2
0
 /**
  * Checks progress of installation
  *
  * @return JsonModel
  */
 public function progressAction()
 {
     $percent = 0;
     $success = false;
     $contents = [];
     $json = new JsonModel();
     // Depending upon the install environment and network latency, there is a possibility that
     // "progress" check request may arrive before the Install POST request. In that case
     // "install.log" file may not be created yet. Check the "install.log" is created before
     // trying to read from it.
     if (!$this->log->logfileExists()) {
         return $json->setVariables(['progress' => $percent, 'success' => true, 'console' => $contents]);
     }
     try {
         $progress = $this->progressFactory->createFromLog($this->log);
         $percent = sprintf('%d', $progress->getRatio() * 100);
         $success = true;
         $contents = $this->log->get();
         if ($this->sampleDataState->hasError()) {
             $json->setVariable('isSampleDataError', true);
         }
     } catch (\Exception $e) {
         $contents = [(string) $e];
     }
     return $json->setVariables(['progress' => $percent, 'success' => $success, 'console' => $contents]);
 }
示例#3
0
 /**
  * Checks progress of installation
  *
  * @return JsonModel
  */
 public function progressAction()
 {
     $percent = 0;
     $success = false;
     $json = new JsonModel();
     try {
         $progress = $this->progressFactory->createFromLog($this->log);
         $percent = sprintf('%d', $progress->getRatio() * 100);
         $success = true;
         $contents = $this->log->get();
         if ($this->sampleDataState->hasError()) {
             $json->setVariable('isSampleDataError', true);
         }
     } catch (\Exception $e) {
         $contents = [(string) $e];
     }
     return $json->setVariables(['progress' => $percent, 'success' => $success, 'console' => $contents]);
 }
    /**
     * Install Magento application
     *
     * @param \ArrayObject|array $request
     * @return void
     * @throws \LogicException
     */
    public function install($request)
    {
        $script[] = ['File permissions check...', 'checkInstallationFilePermissions', []];
        $script[] = ['Enabling Maintenance Mode...', 'setMaintenanceMode', [1]];
        $script[] = ['Installing deployment configuration...', 'installDeploymentConfig', [$request]];
        if (!empty($request[InstallCommand::INPUT_KEY_CLEANUP_DB])) {
            $script[] = ['Cleaning up database...', 'cleanupDb', []];
        }
        $script[] = ['Installing database schema:', 'installSchema', []];
        $script[] = ['Installing user configuration...', 'installUserConfig', [$request]];
        $script[] = ['Enabling caches:', 'enableCaches', []];
        $script[] = ['Installing data...', 'installDataFixtures', []];
        if (!empty($request[InstallCommand::INPUT_KEY_SALES_ORDER_INCREMENT_PREFIX])) {
            $script[] = [
                'Creating sales order increment prefix...',
                'installOrderIncrementPrefix',
                [$request[InstallCommand::INPUT_KEY_SALES_ORDER_INCREMENT_PREFIX]],
            ];
        }
        $script[] = ['Installing admin user...', 'installAdminUser', [$request]];
        $script[] = ['Caches clearing:', 'cleanCaches', []];
        $script[] = ['Disabling Maintenance Mode:', 'setMaintenanceMode', [0]];
        $script[] = ['Post installation file permissions check...', 'checkApplicationFilePermissions', []];

        $estimatedModules = $this->createModulesConfig($request, true);
        $total = count($script) + 4 * count(array_filter($estimatedModules));
        $this->progress = new Installer\Progress($total, 0);

        $this->log->log('Starting Magento installation:');

        while (list(, list($message, $method, $params)) = each($script)) {
            $this->log->log($message);
            call_user_func_array([$this, $method], $params);
            $this->logProgress();
        }

        $this->log->logSuccess('Magento installation complete.');
        $this->log->logSuccess(
            'Magento Admin URI: /'
            . $this->deploymentConfig->get(BackendConfigOptionsList::CONFIG_PATH_BACKEND_FRONTNAME)
        );

        if ($this->progress->getCurrent() != $this->progress->getTotal()) {
            throw new \LogicException('Installation progress did not finish properly.');
        }
        if ($this->sampleDataState->hasError()) {
            $this->log->log('Sample Data is installed with errors. See log file for details');
        }
    }