/** * @expectedException \RuntimeException * @expectedExceptionMessage Cannot find component to update */ public function testExecuteNoRequire() { $om = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); $jobUpdate = $om->create('Magento\\Update\\Queue\\JobUpdate', ['composerApp' => $this->composerApp, 'status' => $this->status, 'params' => [], 'queue' => $this->queue, 'name' => 'setup:upgrade']); $this->composerApp->expects($this->never())->method('runComposerCommand'); $this->queue->expects($this->never())->method('addJobs'); $jobUpdate->execute(); }
/** * {@inheritdoc} */ public function execute() { try { $this->status->add('Starting composer remove...'); if (isset($this->params['components'])) { $packages = []; foreach ($this->params['components'] as $compObj) { $packages[] = $compObj['name']; } $this->status->add($this->composerApp->runComposerCommand(['command' => 'remove', 'packages' => $packages, '--no-update' => true])); } else { throw new \RuntimeException('Cannot find component to uninstall'); } $this->status->add($this->composerApp->runComposerCommand(['command' => 'update'])); $this->status->add('Composer remove completed successfully'); $this->queue->addJobs([['name' => \Magento\Update\Queue\JobFactory::NAME_MAINTENANCE_MODE, 'params' => ['enable' => false]]]); } catch (\Exception $e) { $this->status->setUpdateError(true); throw new \RuntimeException(sprintf('Could not complete %s successfully: %s', $this, $e->getMessage())); } return $this; }
/** * @dataProvider popQueueJobInvalidQueueFormatProvider * @param string $queueJson * @param string $expectedExceptionMessage */ public function testPopQueueJobInvalidQueueFormat($queueJson, $expectedExceptionMessage) { $this->setExpectedException('\\RuntimeException', $expectedExceptionMessage); $this->queueReaderMock->expects($this->once())->method('read')->willReturn($queueJson); $this->queue->popQueuedJobs(); }
/** * Create setup:upgrade task for setup application cron * * @return void */ private function createSetupUpgradeTasks() { $jobs = [['name' => 'setup:upgrade', 'params' => []]]; $this->queue->addJobs($jobs); }
/** * @expectedException \RuntimeException * @expectedExceptionMessage field is missing for one or more jobs */ public function testAddJobsInvalidJobs() { $this->queue->addJobs([['no_name' => 'no job', 'no_params' => []]]); }