public function testCreateUpdaterTaskUninstall()
 {
     $queue = $this->getMock('Magento\\Setup\\Model\\Cron\\Queue', [], [], '', false);
     $queue->expects($this->once())->method('addJobs')->with([['name' => 'uninstall', 'params' => ['components' => [['name' => 'vendor/package']], 'dataOption' => true]]]);
     $updater = new Updater($queue);
     $updater->createUpdaterTask([['name' => 'vendor/package']], Updater::TASK_TYPE_UNINSTALL, ['dataOption' => true]);
 }
 /**
  * Update action
  *
  * @return JsonModel
  */
 public function updateAction()
 {
     $postPayload = Json::decode($this->getRequest()->getContent(), Json::TYPE_ARRAY);
     $errorMessage = '';
     if (isset($postPayload[self::KEY_POST_PACKAGES]) && is_array($postPayload[self::KEY_POST_PACKAGES]) && isset($postPayload[self::KEY_POST_JOB_TYPE])) {
         $errorMessage .= $this->validatePayload($postPayload);
         if (empty($errorMessage)) {
             $packages = $postPayload[self::KEY_POST_PACKAGES];
             $jobType = $postPayload[self::KEY_POST_JOB_TYPE];
             $this->createTypeFlag($jobType, $postPayload[self::KEY_POST_HEADER_TITLE]);
             $additionalOptions = [];
             $cronTaskType = '';
             $this->getCronTaskConfigInfo($jobType, $postPayload, $additionalOptions, $cronTaskType);
             $errorMessage .= $this->updater->createUpdaterTask($packages, $cronTaskType, $additionalOptions);
             // for module enable job types, we need to follow up with 'setup:upgrade' task to
             // make sure enabled modules are properly registered
             if ($jobType == 'enable') {
                 $errorMessage .= $this->updater->createUpdaterTask([], \Magento\Setup\Model\Cron\JobFactory::JOB_UPGRADE, []);
             }
         }
     } else {
         $errorMessage .= 'Invalid request';
     }
     $success = empty($errorMessage) ? true : false;
     return new JsonModel(['success' => $success, 'message' => $errorMessage]);
 }
 /**
  * @expectedException \RuntimeException
  * @expectedExceptionMessage error
  */
 public function testExecuteUpdateFails()
 {
     $this->updater->expects($this->once())->method('createUpdaterTask')->willReturn('error');
     $this->composerInformation->expects($this->once())->method('getInstalledMagentoPackages')->willReturn(['vendor/language-a' => ['type' => JobComponentUninstall::COMPONENT_LANGUAGE]]);
     $this->job = new JobComponentUninstall($this->composerInformation, $this->moduleUninstallHelper, $this->themeUninstallHelper, $this->objectManagerProvider, $this->output, $this->quence, $this->status, $this->updater, 'setup:component:uninstall', ['components' => [[JobComponentUninstall::COMPONENT_NAME => 'vendor/language-a']]]);
     $this->job->execute();
 }
 /**
  * Run remove component job
  *
  * @return void
  * @throw \RuntimeException
  */
 public function execute()
 {
     if (!isset($this->params['components']) || !is_array($this->params['components'])) {
         $this->status->toggleUpdateError(true);
         throw new \RunTimeException('Job parameter format is incorrect');
     }
     $components = $this->params['components'];
     foreach ($components as $component) {
         $this->executeComponent($component);
     }
     $this->queue->addJobs([['name' => JobFactory::JOB_STATIC_REGENERATE, 'params' => []]]);
     $errorMessage = $this->updater->createUpdaterTask($components, Updater::TASK_TYPE_UNINSTALL);
     if ($errorMessage) {
         $this->status->toggleUpdateError(true);
         throw new \RuntimeException($errorMessage);
     }
 }