function testRunCommand() { $inputData = ['command' => 'update', MagentoComposerApplication::COMPOSER_WORKING_DIR => '.']; $this->composerApplication->expects($this->once())->method('resetComposer'); $this->inputFactory->expects($this->once())->method('create')->with($inputData); $this->consoleOutput->expects($this->once())->method('fetch')->willReturn('Nothing to update'); $this->composerApplication->expects($this->once())->method('run')->willReturn(0); $message = $this->application->runComposerCommand($inputData); $this->assertEquals('Nothing to update', $message); }
/** * Runs composer command * * @param array $commandParams * @param string|null $workingDir * @return bool * @throws \RuntimeException */ public function runComposerCommand(array $commandParams, $workingDir = null) { $this->consoleApplication->resetComposer(); if ($workingDir) { $commandParams[self::COMPOSER_WORKING_DIR] = $workingDir; } else { $commandParams[self::COMPOSER_WORKING_DIR] = dirname($this->composerJson); } $input = $this->consoleArrayInputFactory->create($commandParams); $exitCode = $this->consoleApplication->run($input, $this->consoleOutput); if ($exitCode) { throw new \RuntimeException(sprintf('Command "%s" failed: %s', $commandParams['command'], $this->consoleOutput->fetch())); } return $this->consoleOutput->fetch(); }
public function testCreate() { $this->assertInstanceOf('\\Symfony\\Component\\Console\\Input\\ArrayInput', $this->factory->create([])); }