/** * */ public function execute() { if ($this->config->installGlobally()) { $targetDirectory = dirname($this->environment->getBinaryName()); } else { $targetDirectory = $this->config->getWorkingDirectory(); } foreach ($this->config->getRequestedPhars() as $requestedPhar) { $this->pharService->install($requestedPhar, $targetDirectory); if ($this->config->doNotAddToPhiveXml()) { continue; } $this->phiveXmlConfig->addPhar($requestedPhar); } }
public function testGetRequestedPharsFromCliOptions() { $options = $this->getOptionsMock(); $options->expects($this->any())->method('getArgumentCount')->willReturn(3); $options->expects($this->any())->method('getArgument')->willReturnMap([[0, 'https://example.com/foo.phar'], [1, 'phpunit'], [2, 'phpab@1.12.0']]); $expected = [RequestedPhar::fromUrl(new Url('https://example.com/foo.phar')), RequestedPhar::fromAlias(new PharAlias('phpunit', new AnyVersionConstraint())), RequestedPhar::fromAlias(new PharAlias('phpab', new ExactVersionConstraint('1.12.0')))]; $commandConfig = new InstallCommandConfig($options, $this->getConfigMock(), $this->getPhiveXmlConfigMock()); $this->assertEquals($expected, $commandConfig->getRequestedPhars()); }