/** * {@inheritdoc} */ public function launch() { $this->createDirectories(); /** @var Shell $shell */ $shell = $this->shellFactory->create(['entryPoint' => $this->entryPoint]); try { $shell->run(); } catch (\Exception $e) { echo $e->getMessage(); } return $this->response; }
public function testLaunchWithException() { $writer = $this->getMock('Magento\\Framework\\Filesystem\\Directory\\WriteInterface'); $writer->expects($this->any())->method('isDirectory')->will($this->returnValue(false)); $writer->expects($this->any())->method('create')->will($this->returnValue(true)); $this->writeFactory->expects($this->any())->method('create')->will($this->returnValue($writer)); $shell = $this->getMock('\\Migration\\App\\Shell', ['run'], [], '', false); $shell->expects($this->any())->method('run')->willThrowException(new \Exception('error')); $this->shellFactory->expects($this->any())->method('create')->will($this->returnValue($shell)); ob_start(); $this->migration->launch(); $error = ob_get_clean(); $this->assertEquals('error', $error); }