Exemplo n.º 1
0
 /**
  * Run application
  *
  * @return ResponseInterface
  */
 public function launch()
 {
     $this->_state->setAreaCode('crontab');
     $this->_eventManager->dispatch('default');
     $this->_response->setCode(0);
     return $this->_response;
 }
Exemplo n.º 2
0
 /**
  * Run application
  *
  * @return \Magento\Framework\App\ResponseInterface
  */
 public function launch()
 {
     $shell = $this->_shellFactory->create(['entryPoint' => $this->_entryFileName]);
     $shell->run();
     $this->_response->setCode(0);
     return $this->_response;
 }
Exemplo n.º 3
0
 /**
  * @dataProvider setCodeProvider
  */
 public function testSetCode($code, $expectedCode)
 {
     $this->model->terminateOnSend(false);
     $this->model->setCode($code);
     $result = $this->model->sendResponse();
     $this->assertEquals($expectedCode, $result);
 }
Exemplo n.º 4
0
 /**
  * Run application
  *
  * @return \Magento\Framework\App\ResponseInterface
  */
 public function launch()
 {
     /** @var $shell \Magento\Log\Model\Shell */
     $shell = $this->_shellFactory->create(['entryPoint' => $this->_entryFileName]);
     $shell->run();
     $this->_response->setCode(0);
     return $this->_response;
 }
Exemplo n.º 5
0
 public function testExecute()
 {
     $this->_response->expects($this->once())->method('setCode')->with(0);
     $this->_response->expects($this->once())->method('getCode')->will($this->returnValue(0));
     $dir = $this->getMock('Magento\\Framework\\Filesystem\\Directory\\Write', [], [], '', false);
     $dir->expects($this->any())->method('getRelativePath')->will($this->returnArgument(0));
     $this->filesystem->expects($this->once())->method('getDirectoryWrite')->will($this->returnValue($dir));
     $this->processor->expects($this->once())->method('reindexAll');
     $this->assertEquals(0, $this->entryPoint->launch()->getCode());
 }
Exemplo n.º 6
0
 /**
  * Run application
  *
  * @return ResponseInterface
  */
 public function launch()
 {
     $this->_state->setAreaCode(Area::AREA_CRONTAB);
     $configLoader = $this->objectManager->get('Magento\\Framework\\ObjectManager\\ConfigLoaderInterface');
     $this->objectManager->configure($configLoader->load(Area::AREA_CRONTAB));
     /** @var \Magento\Framework\Event\ManagerInterface $eventManager */
     $eventManager = $this->objectManager->get('Magento\\Framework\\Event\\ManagerInterface');
     $eventManager->dispatch('default');
     $this->_response->setCode(0);
     return $this->_response;
 }
Exemplo n.º 7
0
 /**
  * Run application
  *
  * @return \Magento\Framework\App\ResponseInterface
  */
 public function launch()
 {
     /** @var $shell \Magento\Indexer\Model\Shell */
     $shell = $this->shellFactory->create(array('entryPoint' => $this->entryFileName));
     $shell->run();
     if ($shell->hasErrors()) {
         $this->response->setCode(-1);
     } else {
         $this->response->setCode(0);
     }
     return $this->response;
 }
Exemplo n.º 8
0
 public function testLaunchDispatchesCronEvent()
 {
     $configLoader = $this->getMockForAbstractClass('Magento\\Framework\\ObjectManager\\ConfigLoaderInterface');
     $eventManagerMock = $this->getMock('Magento\\Framework\\Event\\ManagerInterface');
     $this->objectManager->expects($this->any())->method('get')->will($this->returnValueMap([['Magento\\Framework\\ObjectManager\\ConfigLoaderInterface', $configLoader], ['Magento\\Framework\\Event\\ManagerInterface', $eventManagerMock]]));
     $crontabConfig = ['config'];
     $configLoader->expects($this->once())->method('load')->with(Area::AREA_CRONTAB)->willReturn($crontabConfig);
     $this->objectManager->expects($this->once())->method('configure')->with($crontabConfig);
     $this->_stateMock->expects($this->once())->method('setAreaCode')->with(Area::AREA_CRONTAB);
     $eventManagerMock->expects($this->once())->method('dispatch')->with('default');
     $this->_responseMock->expects($this->once())->method('setCode')->with(0);
     $this->assertEquals($this->_responseMock, $this->_model->launch());
 }
Exemplo n.º 9
0
 /**
  * Run application
  *
  * @return \Magento\Framework\App\ResponseInterface
  */
 public function launch()
 {
     /* Clean reports */
     $directory = $this->filesystem->getDirectoryWrite(DirectoryList::ROOT);
     $path = $directory->getRelativePath($this->reportDir);
     if ($directory->isExist($path)) {
         $directory->delete($path);
     }
     /* Regenerate all indexers */
     $this->processor->reindexAll();
     $this->_response->setCode(0);
     return $this->_response;
 }
Exemplo n.º 10
0
 /**
  * Run application
  *
  * @return \Magento\Framework\App\ResponseInterface
  */
 public function launch()
 {
     $areaCode = 'install';
     $this->_state->setAreaCode($areaCode);
     $this->_objectManager->configure($this->_loader->load($areaCode));
     if (isset($this->_arguments['uninstall'])) {
         $sessionConsole = $this->_objectManager->create('\\Magento\\Framework\\Session\\SessionConsole');
         $installerModel = $this->_objectManager->create('Magento\\Install\\Model\\Installer', ['session' => $sessionConsole]);
         $installer = $this->_installerFactory->create(['installArgs' => $this->_arguments, 'installer' => $installerModel]);
     } else {
         $installer = $this->_installerFactory->create(array('installArgs' => $this->_arguments));
     }
     if (isset($this->_arguments['show_locales'])) {
         $this->_output->readableOutput($this->_output->prepareArray($installer->getAvailableLocales()));
     } elseif (isset($this->_arguments['show_currencies'])) {
         $this->_output->readableOutput($this->_output->prepareArray($installer->getAvailableCurrencies()));
     } elseif (isset($this->_arguments['show_timezones'])) {
         $this->_output->readableOutput($this->_output->prepareArray($installer->getAvailableTimezones()));
     } elseif (isset($this->_arguments['show_install_options'])) {
         $this->_output->readableOutput(PHP_EOL . 'Required parameters:');
         $this->_output->readableOutput($this->_output->alignArrayKeys($installer->getRequiredParams()));
         $this->_output->readableOutput(PHP_EOL . 'Optional parameters:');
         $this->_output->readableOutput($this->_output->alignArrayKeys($installer->getOptionalParams()));
         $this->_output->readableOutput(PHP_EOL . 'Flag values are considered positive if set to 1, y, true or yes.' . 'Any other value is considered as negative.' . PHP_EOL);
     } else {
         $this->_handleInstall($installer);
     }
     $this->_response->setCode(0);
     return $this->_response;
 }
Exemplo n.º 11
0
 /**
  * {@inheritdoc}
  */
 public function catchException(App\Bootstrap $bootstrap, \Exception $exception)
 {
     $this->response->setBody($exception->getMessage());
     $this->response->terminateOnSend(false);
     $this->response->sendResponse();
     return false;
 }
Exemplo n.º 12
0
 public function testCatchException()
 {
     $exceptionMessage = 'Exception message';
     $model = new ManagerApp($this->cacheManager, $this->response, []);
     $this->response->expects($this->once())->method('setBody')->with($exceptionMessage);
     $this->assertFalse($model->catchException($this->getMock('Magento\\Framework\\App\\Bootstrap', [], [], '', false), new \Exception($exceptionMessage)));
 }
Exemplo n.º 13
0
 /**
  * Launch application
  *
  * @return \Magento\Framework\App\ResponseInterface
  */
 public function launch()
 {
     $this->objectManager->configure(['preferences' => ['Magento\\Tools\\Di\\Compiler\\Config\\WriterInterface' => 'Magento\\Tools\\Di\\Compiler\\Config\\Writer\\Filesystem']]);
     $operations = [Task\OperationFactory::AREA => [BP . '/' . 'app/code', BP . '/' . 'lib/internal/Magento/Framework', BP . '/' . 'var/generation'], Task\OperationFactory::INTERCEPTION => BP . '/var/generation', Task\OperationFactory::INTERCEPTION_CACHE => [BP . '/' . 'app/code', BP . '/' . 'lib/internal/Magento/Framework', BP . '/' . 'var/generation']];
     $responseCode = Response::SUCCESS;
     try {
         foreach ($operations as $operationCode => $arguments) {
             $this->taskManager->addOperation($operationCode, $arguments);
         }
         $this->taskManager->process();
     } catch (Task\OperationException $e) {
         $responseCode = Response::ERROR;
         $this->response->setBody($e->getMessage());
     }
     $this->response->setCode($responseCode);
     return $this->response;
 }
Exemplo n.º 14
0
 /**
  * Launch application
  *
  * @return \Magento\Framework\App\ResponseInterface
  */
 public function launch()
 {
     $this->objectManager->configure(['preferences' => ['Magento\\Tools\\Di\\Compiler\\Config\\WriterInterface' => 'Magento\\Tools\\Di\\Compiler\\Config\\Writer\\Filesystem', 'Magento\\Tools\\Di\\Compiler\\Log\\Writer\\WriterInterface' => 'Magento\\Tools\\Di\\Compiler\\Log\\Writer\\Console'], 'Magento\\Tools\\Di\\Compiler\\Config\\ModificationChain' => ['arguments' => ['modificationsList' => ['BackslashTrim' => ['instance' => 'Magento\\Tools\\Di\\Compiler\\Config\\Chain\\BackslashTrim'], 'PreferencesResolving' => ['instance' => 'Magento\\Tools\\Di\\Compiler\\Config\\Chain\\PreferencesResolving'], 'InterceptorSubstitution' => ['instance' => 'Magento\\Tools\\Di\\Compiler\\Config\\Chain\\InterceptorSubstitution'], 'InterceptionPreferencesResolving' => ['instance' => 'Magento\\Tools\\Di\\Compiler\\Config\\Chain\\PreferencesResolving'], 'ArgumentsSerialization' => ['instance' => 'Magento\\Tools\\Di\\Compiler\\Config\\Chain\\ArgumentsSerialization']]]], 'Magento\\Tools\\Di\\Code\\Generator\\PluginList' => ['arguments' => ['cache' => ['instance' => 'Magento\\Framework\\App\\Interception\\Cache\\CompiledConfig']]], 'Magento\\Tools\\Di\\Code\\Reader\\ClassesScanner' => ['arguments' => ['excludePatterns' => $this->excludedPathsList]]]);
     $operations = [Task\OperationFactory::REPOSITORY_GENERATOR => ['path' => $this->compiledPathsList['application'], 'filePatterns' => ['di' => '/\\/etc\\/([a-zA-Z_]*\\/di|di)\\.xml$/']], Task\OperationFactory::APPLICATION_CODE_GENERATOR => [$this->compiledPathsList['application'], $this->compiledPathsList['library'], $this->compiledPathsList['generated_helpers']], Task\OperationFactory::INTERCEPTION => ['intercepted_paths' => [$this->compiledPathsList['application'], $this->compiledPathsList['library'], $this->compiledPathsList['generated_helpers']], 'path_to_store' => $this->compiledPathsList['generated_helpers']], Task\OperationFactory::AREA_CONFIG_GENERATOR => [$this->compiledPathsList['application'], $this->compiledPathsList['library'], $this->compiledPathsList['generated_helpers']], Task\OperationFactory::INTERCEPTION_CACHE => [$this->compiledPathsList['application'], $this->compiledPathsList['library'], $this->compiledPathsList['generated_helpers']]];
     $responseCode = Response::SUCCESS;
     try {
         foreach ($operations as $operationCode => $arguments) {
             $this->taskManager->addOperation($operationCode, $arguments);
         }
         $this->taskManager->process();
     } catch (Task\OperationException $e) {
         $responseCode = Response::ERROR;
         $this->response->setBody($e->getMessage());
     }
     $this->response->setCode($responseCode);
     return $this->response;
 }
Exemplo n.º 15
0
 /**
  * Run application
  *
  * @return \Magento\Framework\App\ResponseInterface
  */
 public function launch()
 {
     /* Clean reports */
     $directory = $this->_filesystem->getDirectoryWrite(\Magento\Framework\App\Filesystem::ROOT_DIR);
     $path = $directory->getRelativePath($this->_reportDir);
     if ($directory->isExist($path)) {
         $directory->delete($path);
     }
     /* Run all indexer processes */
     /** @var $indexer \Magento\Index\Model\Indexer */
     $indexer = $this->_indexerFactory->create();
     /** @var $process \Magento\Index\Model\Process */
     foreach ($indexer->getProcessesCollection() as $process) {
         if ($process->getIndexer()->isVisible()) {
             $process->reindexEverything();
         }
     }
     $this->_response->setCode(0);
     return $this->_response;
 }
Exemplo n.º 16
0
 /**
  * Launch application
  *
  * @return \Magento\Framework\App\ResponseInterface
  */
 public function launch()
 {
     $this->state->setAreaCode($this->params->getArea());
     $this->objectManager->configure($this->configLoader->load($this->params->getArea()));
     $sourceFileGenerator = $this->sourceFileGeneratorPool->create($this->params->getExt());
     foreach ($this->params->getFiles() as $file) {
         $file .= '.' . $this->params->getExt();
         $this->logger->logMessage("Gathering {$file} sources.");
         $asset = $this->assetRepo->createAsset($file, ['area' => $this->params->getArea(), 'theme' => $this->params->getTheme(), 'locale' => $this->params->getLocale()]);
         $sourceFile = $this->assetSource->findSource($asset);
         $content = \file_get_contents($sourceFile);
         $chain = $this->chainFactory->create(['asset' => $asset, 'origContent' => $content, 'origContentType' => $asset->getContentType()]);
         $processedCoreFile = $sourceFileGenerator->generateFileTree($chain);
         $targetDir = $this->filesystem->getDirectoryWrite(DirectoryList::STATIC_VIEW);
         $rootDir = $this->filesystem->getDirectoryWrite(DirectoryList::ROOT);
         $source = $rootDir->getRelativePath($processedCoreFile);
         $destination = $asset->getPath();
         $rootDir->copyFile($source, $destination, $targetDir);
         $this->logger->logMessage("Done");
     }
     $this->response->setCode(Response::SUCCESS);
     return $this->response;
 }
Exemplo n.º 17
0
 public function testSetBodyNoOutput()
 {
     $this->expectOutputString('');
     $this->model->sendResponse();
 }
Exemplo n.º 18
0
 /**
  * Launch application. Prevent application termination on sent response, initialize DB connection.
  *
  * @return \Magento\Framework\App\ResponseInterface
  */
 public function launch()
 {
     $this->_response->terminateOnSend(false);
     $this->_storeManager->getStores(false, true);
     return $this->_response;
 }
Exemplo n.º 19
0
 /**
  * Run application
  *
  * @return \Magento\Framework\App\ResponseInterface
  */
 public function launch()
 {
     $this->response->terminateOnSend(false);
     $this->updateUserConfigData();
     return $this->response;
 }