public function testUpdateDataNoUpdates()
 {
     $this->moduleManager->expects($this->once())->method('isDbSchemaUpToDate')->with('Test_Module', 'catalog_setup')->will($this->returnValue(true));
     $this->moduleManager->expects($this->once())->method('isDbDataUpToDate')->with('Test_Module', 'catalog_setup')->will($this->returnValue(true));
     $this->_factoryMock->expects($this->never())->method('create');
     $this->_appStateMock->expects($this->at(0))->method('setUpdateMode')->with(true);
     $this->_appStateMock->expects($this->at(1))->method('setUpdateMode')->with(false);
     $this->_factoryMock->expects($this->never())->method('create');
     $this->_model->updateScheme();
     $this->_model->updateData();
 }
Exemple #2
0
 public function testUpdateDataAppliesDataUpdatesIfSchemaIsUpdated()
 {
     $this->_appStateMock->expects($this->once())->method('isInstalled')->will($this->returnValue(false));
     $this->_appStateMock->expects($this->at(1))->method('setUpdateMode')->with(true);
     $this->_appStateMock->expects($this->at(2))->method('setUpdateMode')->with(false);
     $this->_resourceSetupMock->expects($this->once())->method('applyUpdates');
     $this->_resourceSetupMock->expects($this->once())->method('getCallAfterApplyAllUpdates')->will($this->returnValue(true));
     $this->_resourceSetupMock->expects($this->once())->method('afterApplyAllUpdates');
     $this->_resourceSetupMock->expects($this->once())->method('applyDataUpdates');
     $this->_model->updateScheme();
     $this->_model->updateData();
 }
Exemple #3
0
 /**
  * Database installation
  *
  * @return $this
  */
 public function installDb()
 {
     $this->_dbUpdater->updateScheme();
     $data = $this->getDataModel()->getConfigData();
     /**
      * Saving host information into DB
      */
     if (!empty($data['use_rewrites'])) {
         $this->_installSetup->setConfigData(\Magento\Store\Model\Store::XML_PATH_USE_REWRITES, 1);
     }
     if (!empty($data['enable_charts'])) {
         $this->_installSetup->setConfigData(\Magento\Backend\Block\Dashboard::XML_PATH_ENABLE_CHARTS, 1);
     } else {
         $this->_installSetup->setConfigData(\Magento\Backend\Block\Dashboard::XML_PATH_ENABLE_CHARTS, 0);
     }
     if (!empty($data['admin_no_form_key'])) {
         $this->_installSetup->setConfigData('admin/security/use_form_key', 0);
     }
     $unsecureBaseUrl = $this->_storeManager->getStore()->getBaseUrl('web');
     if (!empty($data['unsecure_base_url'])) {
         $unsecureBaseUrl = $data['unsecure_base_url'];
         $this->_installSetup->setConfigData(\Magento\Store\Model\Store::XML_PATH_UNSECURE_BASE_URL, $unsecureBaseUrl);
     }
     if (!empty($data['use_secure'])) {
         $this->_installSetup->setConfigData(\Magento\Store\Model\Store::XML_PATH_SECURE_IN_FRONTEND, 1);
         $this->_installSetup->setConfigData(\Magento\Store\Model\Store::XML_PATH_SECURE_BASE_URL, $data['secure_base_url']);
         if (!empty($data['use_secure_admin'])) {
             $this->_installSetup->setConfigData(\Magento\Store\Model\Store::XML_PATH_SECURE_IN_ADMINHTML, 1);
         }
     } elseif (!empty($data['unsecure_base_url'])) {
         $this->_installSetup->setConfigData(\Magento\Store\Model\Store::XML_PATH_SECURE_BASE_URL, $unsecureBaseUrl);
     }
     /**
      * Saving locale information into DB
      */
     $locale = $this->getDataModel()->getLocaleData();
     if (!empty($locale['locale'])) {
         $this->_installSetup->setConfigData($this->_localeResolver->getDefaultLocalePath(), $locale['locale']);
     }
     if (!empty($locale['timezone'])) {
         $this->_installSetup->setConfigData($this->_localeDate->getDefaultTimezonePath(), $locale['timezone']);
     }
     if (!empty($locale['currency'])) {
         $this->_installSetup->setConfigData(\Magento\Directory\Model\Currency::XML_PATH_CURRENCY_BASE, $locale['currency']);
         $this->_installSetup->setConfigData(\Magento\Directory\Model\Currency::XML_PATH_CURRENCY_DEFAULT, $locale['currency']);
         $this->_installSetup->setConfigData(\Magento\Directory\Model\Currency::XML_PATH_CURRENCY_ALLOW, $locale['currency']);
     }
     if (!empty($data['order_increment_prefix'])) {
         $this->_setOrderIncrementPrefix($this->_installSetup, $data['order_increment_prefix']);
     }
     return $this;
 }
Exemple #4
0
 /**
  * Install Magento
  *
  * @param array $options
  * @return string|false
  */
 public function install(array $options)
 {
     try {
         $options = $this->_getInstallOptions($options);
         if (!$options) {
             return false;
         }
         /**
          * Skip URL validation, if set
          */
         $this->_installerData->setSkipUrlValidation($options['skip_url_validation']);
         $this->_installerData->setSkipBaseUrlValidation($options['skip_url_validation']);
         /**
          * Locale settings
          */
         $this->_installerData->setLocaleData(['locale' => $options['locale'], 'timezone' => $options['timezone'], 'currency' => $options['default_currency']]);
         /**
          * Database and web config
          */
         $this->_installerData->setConfigData(['db_model' => $options['db_model'], 'db_host' => $options['db_host'], 'db_name' => $options['db_name'], 'db_user' => $options['db_user'], 'db_pass' => $options['db_pass'], 'db_prefix' => $options['db_prefix'], 'use_rewrites' => $this->_getFlagValue($options['use_rewrites']), 'use_secure' => $this->_getFlagValue($options['use_secure']), 'unsecure_base_url' => $options['url'], 'secure_base_url' => $options['secure_base_url'], 'use_secure_admin' => $this->_getFlagValue($options['use_secure_admin']), 'session_save' => $this->_checkSessionSave($options['session_save']), 'backend_frontname' => $this->_checkBackendFrontname($options['backend_frontname']), 'admin_no_form_key' => $this->_getFlagValue($options['admin_no_form_key']), 'skip_url_validation' => $this->_getFlagValue($options['skip_url_validation']), 'enable_charts' => $this->_getFlagValue($options['enable_charts']), 'order_increment_prefix' => $options['order_increment_prefix']]);
         /**
          * Primary admin user
          */
         $this->_installerData->setAdminData(['firstname' => $options['admin_firstname'], 'lastname' => $options['admin_lastname'], 'email' => $options['admin_email'], 'username' => $options['admin_username'], 'password' => $options['admin_password']]);
         $this->checkServer();
         if ($this->hasErrors()) {
             return false;
         }
         /**
          * Install configuration
          */
         $this->installer->installConfig($this->_installerData->getConfigData());
         if (!empty($options['cleanup_database'])) {
             $this->db->cleanUpDatabase();
         }
         if ($this->hasErrors()) {
             return false;
         }
         /**
          * Install database
          */
         $this->installer->installDb();
         if ($this->hasErrors()) {
             return false;
         }
         // apply data updates
         $this->_dbUpdater->updateData();
         /**
          * Create primary administrator user & install encryption key
          */
         $encryptionKey = !empty($options['encryption_key']) ? $options['encryption_key'] : null;
         $encryptionKey = $this->installer->getValidEncryptionKey($encryptionKey);
         $this->installer->createAdministrator($this->_installerData->getAdminData());
         $this->installer->installEncryptionKey($encryptionKey);
         /**
          * Installation finish
          */
         $this->installer->finish();
         if ($this->hasErrors()) {
             return false;
         }
         return $encryptionKey;
     } catch (\Exception $e) {
         if ($e instanceof \Magento\Framework\Model\Exception) {
             $errorMessages = $e->getMessages(\Magento\Framework\Message\MessageInterface::TYPE_ERROR);
             if (!empty($errorMessages)) {
                 foreach ($errorMessages as $errorMessage) {
                     $this->addError($errorMessage);
                 }
             } else {
                 $this->addError($e->getMessage());
             }
         } else {
             $this->addError('ERROR: ' . $e->getMessage() . $e->getTraceAsString());
         }
         return false;
     }
 }
Exemple #5
0
 public function testUpdateDataNoUpdates()
 {
     $this->_dbVersionInfo->expects($this->once())->method('isDataUpToDate')->with('Test_Module', 'catalog_setup')->will($this->returnValue(true));
     $this->_factoryMock->expects($this->never())->method('create');
     $this->_model->updateData();
 }