public function handleInstall(Args $args, IO $io) { if ($args->isArgumentSet('target')) { $expr = Expr::same($args->getArgument('target'), AssetMapping::TARGET_NAME); $mappings = $this->assetManager->findAssetMappings($expr); } else { $mappings = $this->assetManager->getAssetMappings(); } if (!$mappings) { $io->writeLine('Nothing to install.'); return 0; } /** @var InstallationParams[] $paramsToInstall */ $paramsToInstall = array(); // Prepare and validate the installation of all matching mappings foreach ($mappings as $mapping) { $paramsToInstall[] = $this->installationManager->prepareInstallation($mapping); } foreach ($paramsToInstall as $params) { foreach ($params->getResources() as $resource) { $webPath = rtrim($params->getTargetLocation(), '/') . $params->getWebPathForResource($resource); $io->writeLine(sprintf('Installing <c1>%s</c1> into <c2>%s</c2> via <u>%s</u>...', $resource->getRepositoryPath(), trim($webPath, '/'), $params->getInstallerDescriptor()->getName())); $this->installationManager->installResource($resource, $params); } } return 0; }
public function testInstallNothing() { $this->assetManager->expects($this->once())->method('getAssetMappings')->willReturn(array()); $this->installationManager->expects($this->never())->method('prepareInstallation'); $this->installationManager->expects($this->never())->method('installResource'); $args = self::$installCommand->parseArgs(new StringArgs('')); $expected = <<<EOF Nothing to install. EOF; $this->assertSame(0, $this->handler->handleInstall($args, $this->io)); $this->assertSame($expected, $this->io->fetchOutput()); $this->assertEmpty($this->io->fetchErrors()); }