Beispiel #1
0
 public function handleInstall(Args $args, IO $io)
 {
     if ($args->isArgumentSet('server')) {
         $expr = Expr::same($args->getArgument('server'), AssetMapping::SERVER_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) {
             $serverPath = rtrim($params->getDocumentRoot(), '/') . $params->getServerPathForResource($resource);
             $io->writeLine(sprintf('Installing <c1>%s</c1> into <c2>%s</c2> via <u>%s</u>...', $resource->getRepositoryPath(), trim($serverPath, '/'), $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());
    }