protected function setUp() { $this->packageFileManager = $this->getMock('Puli\\Manager\\Api\\Package\\RootPackageFileManager'); $this->installerManager = $this->getMock('Puli\\Manager\\Api\\Installer\\InstallerManager'); $this->serverManager = new PackageFileServerManager($this->packageFileManager, $this->installerManager); $this->installerManager->expects($this->any())->method('hasInstallerDescriptor')->willReturnMap(array(array('symlink', true), array('rsync', true))); }
public function handleDelete(Args $args) { $installerName = $args->getArgument('name'); if (!$this->installerManager->hasInstallerDescriptor($installerName)) { throw new RuntimeException(sprintf('The installer "%s" does not exist.', $installerName)); } $this->installerManager->removeRootInstallerDescriptor($installerName); return 0; }
/** * {@inheritdoc} */ public function addServer(Server $server) { $this->assertServersLoaded(); if (!$this->installerManager->hasInstallerDescriptor($server->getInstallerName())) { throw NoSuchInstallerException::forInstallerName($server->getInstallerName()); } $previousServers = $this->servers->toArray(); $previousData = $this->serversData; $this->servers->add($server); $this->serversData[$server->getName()] = $this->serverToData($server); try { $this->persistServersData(); } catch (Exception $e) { $this->servers->replace($previousServers); $this->serversData = $previousData; throw $e; } }
/** * @expectedException \Puli\Manager\Api\Installation\NotInstallableException * @expectedExceptionMessage Puli\Manager\Tests\Installation\Fixtures\TestInstallerInvalid * @expectedExceptionCode 8 */ public function testFailIfInstallerClassInvalid() { $resources = new ArrayResourceCollection(array(new GenericResource('/path/css'), new GenericResource('/path/js'))); $installerDescriptor = new InstallerDescriptor('rsync', self::INSTALLER_CLASS_INVALID, null, array(new InstallerParameter('param1', InstallerParameter::REQUIRED), new InstallerParameter('param2', InstallerParameter::OPTIONAL, 'default1'), new InstallerParameter('param3', InstallerParameter::OPTIONAL, 'default2'))); $server = new Server('example.com', 'rsync', 'ssh://server/public_html', '/%s', array('param1' => 'custom1', 'param3' => 'custom2')); $mapping = new AssetMapping('/path/{css,js}', 'example.com', 'assets'); $this->servers->add($server); $this->repo->expects($this->any())->method('find')->with('/path/{css,js}')->willReturn($resources); $this->installerManager->expects($this->any())->method('hasInstallerDescriptor')->with('rsync')->willReturn(true); $this->installerManager->expects($this->any())->method('getInstallerDescriptor')->with('rsync')->willReturn($installerDescriptor); $this->manager->prepareInstallation($mapping); }
/** * {@inheritdoc} */ public function prepareInstallation(AssetMapping $mapping) { $glob = $mapping->getGlob(); $serverName = $mapping->getServerName(); $resources = $this->repo->find($glob); if ($resources->isEmpty()) { throw NotInstallableException::noResourceMatches($glob); } if (!$this->servers->contains($serverName)) { throw NotInstallableException::serverNotFound($serverName); } $server = $this->servers->get($serverName); $installerName = $server->getInstallerName(); if (!$this->installerManager->hasInstallerDescriptor($installerName)) { throw NotInstallableException::installerNotFound($installerName); } $installerDescriptor = $this->installerManager->getInstallerDescriptor($installerName); $installer = $this->loadInstaller($installerDescriptor); $rootDir = $this->context->getRootDirectory(); $params = new InstallationParams($installer, $installerDescriptor, $resources, $mapping, $server, $rootDir); $installer->validateParams($params); return $params; }
private function initDefaultInstallers() { $this->installerManager->expects($this->once())->method('getInstallerDescriptors')->willReturn(array(new InstallerDescriptor('symlink', 'Puli\\Installer\\SymlinkInstaller', 'Symlink description'), new InstallerDescriptor('copy', 'Puli\\Installer\\CopyInstaller', 'The copy description is significantly longer than all the other descriptions, although it doesn\'t bear any more information.'), new InstallerDescriptor('rsync', 'Puli\\Installer\\RsyncInstaller', 'Just a short description', array(new InstallerParameter('required', InstallerParameter::REQUIRED, null, 'The description of "required"'), new InstallerParameter('optional', InstallerParameter::OPTIONAL, 42, 'The description of "optional"'))))); }