public function testExecute()
 {
     $this->deploymentConfig->expects($this->once())->method('isAvailable')->will($this->returnValue(true));
     $this->installer->expects($this->once())->method('installUserConfig');
     $this->installerFactory->expects($this->once())->method('create')->will($this->returnValue($this->installer));
     $tester = new CommandTester($this->command);
     $tester->execute([]);
 }
Exemple #2
0
 public function testStartActionWithSampleDataError()
 {
     $this->webLogger->expects($this->once())->method('clear');
     $this->webLogger->expects($this->once())->method('logError');
     $this->installer->method('install')->will($this->throwException(new \LogicException));
     $jsonModel = $this->controller->startAction();
     $this->assertInstanceOf('\Zend\View\Model\JsonModel', $jsonModel);
     $variables = $jsonModel->getVariables();
     $this->assertArrayHasKey('success', $variables);
     $this->assertFalse($variables['success']);
 }
 public function testStartActionWithSampleDataError()
 {
     $this->webLogger->expects($this->once())->method('clear');
     $this->webLogger->expects($this->never())->method('logError');
     $this->installer->method('install');
     $this->sampleDataState->expects($this->once())->method('hasError')->willReturn(true);
     $jsonModel = $this->controller->startAction();
     $this->assertInstanceOf('\\Zend\\View\\Model\\JsonModel', $jsonModel);
     $variables = $jsonModel->getVariables();
     $this->assertArrayHasKey('success', $variables);
     $this->assertTrue($variables['success']);
     $this->assertTrue($jsonModel->getVariable('isSampleDataError'));
 }
Exemple #4
0
 /**
  * Index Action
  *
  * @return JsonModel
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 public function startAction()
 {
     $this->log->clear();
     $json = new JsonModel;
     try {
         $data = array_merge(
             $this->importDeploymentConfigForm(),
             $this->importUserConfigForm(),
             $this->importAdminUserForm()
         );
         $this->installer->install($data);
         $json->setVariable(
             'key',
             $this->installer->getInstallInfo()[SetupConfigOptionsList::KEY_ENCRYPTION_KEY]
         );
         $json->setVariable('success', true);
         $json->setVariable('messages', $this->installer->getInstallInfo()[Installer::INFO_MESSAGE]);
     } catch (\Exception $e) {
         $this->log->logError($e);
         $json->setVariable('success', false);
         if ($e instanceof \Magento\Setup\SampleDataException) {
             $json->setVariable('isSampleDataError', true);
         }
     }
     return $json;
 }
Exemple #5
0
 /**
  * Index Action
  *
  * @return JsonModel
  */
 public function startAction()
 {
     $this->log->clear();
     $json = new JsonModel();
     try {
         $data = array_merge($this->importDeploymentConfigForm(), $this->importUserConfigForm(), $this->importAdminUserForm());
         $this->installer->install($data);
         $json->setVariable('key', $this->installer->getInstallInfo()[EncryptConfig::KEY_ENCRYPTION_KEY]);
         $json->setVariable('success', true);
         $json->setVariable('messages', $this->installer->getInstallInfo()[Installer::INFO_MESSAGE]);
     } catch (\Exception $e) {
         $this->log->logError($e);
         $json->setVariable('success', false);
     }
     return $json;
 }
Exemple #6
0
 /**
  * Get Deployment Config
  *
  * @return \Magento\Framework\App\DeploymentConfig
  *
  * @deprecated
  */
 private function getDeploymentConfig()
 {
     if ($this->deploymentConfig === null) {
         $this->deploymentConfig = $this->installer->getObjectManagerProvider()->get()->get(\Magento\Framework\App\DeploymentConfig::class);
     }
     return $this->deploymentConfig;
 }
 /**
  * Test install command with invalid sales_order_increment_prefix value
  *
  * @expectedException \InvalidArgumentException
  * @dataProvider validateWithExceptionDataProvider
  * @param $prefixValue
  */
 public function testValidateWithException($prefixValue)
 {
     $this->installerFactory->expects($this->never())->method('create')->will($this->returnValue($this->installer));
     $this->installer->expects($this->never())->method('install');
     $this->input['--' . InstallCommand::INPUT_KEY_SALES_ORDER_INCREMENT_PREFIX] = $prefixValue;
     $commandTester = new CommandTester($this->command);
     $commandTester->execute($this->input);
 }
 public function testCleanupDb()
 {
     $this->config->expects($this->once())->method('get')->with(ConfigOptionsListConstants::CONFIG_PATH_DB_CONNECTION_DEFAULT)->willReturn(self::$dbConfig);
     $this->connection->expects($this->at(0))->method('quoteIdentifier')->with('magento')->willReturn('`magento`');
     $this->connection->expects($this->at(1))->method('query')->with('DROP DATABASE IF EXISTS `magento`');
     $this->connection->expects($this->at(2))->method('query')->with('CREATE DATABASE IF NOT EXISTS `magento`');
     $this->logger->expects($this->once())->method('log')->with('Cleaning up database `magento`');
     $this->object->cleanupDb();
 }
Exemple #9
0
 /**
  * Index Action
  *
  * @return JsonModel
  */
 public function startAction()
 {
     $this->log->clear();
     $json = new JsonModel();
     try {
         $this->checkForPriorInstall();
         $content = $this->getRequest()->getContent();
         $source = $content ? $source = Json::decode($content, Json::TYPE_ARRAY) : [];
         $data = $this->requestDataConverter->convert($source);
         $this->installer->install($data);
         $json->setVariable('key', $this->installer->getInstallInfo()[SetupConfigOptionsList::KEY_ENCRYPTION_KEY]);
         $json->setVariable('success', true);
         if ($this->sampleDataState->hasError()) {
             $json->setVariable('isSampleDataError', true);
         }
         $json->setVariable('messages', $this->installer->getInstallInfo()[Installer::INFO_MESSAGE]);
     } catch (\Exception $e) {
         $this->log->logError($e);
         $json->setVariable('messages', $e->getMessage());
         $json->setVariable('success', false);
     }
     return $json;
 }
 public function testUninstallAction()
 {
     $this->installer->expects($this->once())->method('uninstall');
     $this->controller->uninstallAction();
 }
 /**
  * @expectedException \Magento\Setup\Exception
  * @expectedExceptionMessage Sorry, but we support MySQL version
  */
 public function testCheckDatabaseConnectionIncompatible()
 {
     $this->connection->expects($this->once())->method('fetchOne')->with('SELECT version()')->willReturn('5.5.40-0ubuntu0.12.04.1');
     $this->object->checkDatabaseConnection('name', 'host', 'user', 'password');
 }
 /**
  * Controller for Uninstall Command
  *
  * @return void
  */
 public function uninstallAction()
 {
     $this->installer->uninstall();
 }
 public function testIndexActionCheckPrefix()
 {
     $this->installer->expects($this->once())->method('checkDatabaseTablePrefix');
     $this->controller->indexAction();
 }
 public function testExecuteInteractionNo()
 {
     $this->installer->expects($this->exactly(0))->method('uninstall');
     $this->installerFactory->expects($this->exactly(0))->method('create');
     $this->checkInteraction(false);
 }