/** * Run Composer dependency check * * @param array $packages * @return array * @throws \Exception */ public function runReadinessCheck(array $packages) { $composerJson = $this->composerJsonFinder->findComposerJson(); $this->file->copy($composerJson, $this->directoryList->getPath(DirectoryList::VAR_DIR) . '/composer.json'); $workingDir = $this->directoryList->getPath(DirectoryList::VAR_DIR); try { foreach ($packages as $package) { if (strpos($package, 'magento/product-enterprise-edition') !== false) { $this->magentoComposerApplication->runComposerCommand(['command' => 'remove', 'packages' => ['magento/product-community-edition'], '--no-update' => true], $workingDir); } } $this->requireUpdateDryRunCommand->run($packages, $workingDir); return ['success' => true]; } catch (\RuntimeException $e) { $message = str_replace(PHP_EOL, '<br/>', htmlspecialchars($e->getMessage())); return ['success' => false, 'error' => $message]; } }
/** * @expectedException \RuntimeException * @expectedExceptionMessage */ public function testRunException() { $this->application->expects($this->at(1))->method('runComposerCommand')->willThrowException(new \RuntimeException($this->errorMessage)); $this->infoCommand->expects($this->once())->method('run')->willReturn($this->packageInfo); $this->requireUpdateDryRunCommand->run(['3rdp/e 1.2.0'], ''); }