예제 #1
0
 /**
  * Handles the "puli plugin --remove" command.
  *
  * @param Args $args The console arguments.
  *
  * @return int The status code.
  */
 public function handleDelete(Args $args)
 {
     $pluginClass = $args->getArgument('class');
     if (!$this->manager->hasPluginClass($pluginClass)) {
         throw new RuntimeException(sprintf('The plugin class "%s" is not installed.', $pluginClass));
     }
     $this->manager->removePluginClass($pluginClass);
     return 0;
 }
예제 #2
0
 /**
  * Handles the "upgrade" command.
  *
  * @param Args $args The console arguments.
  * @param IO   $io   The I/O.
  *
  * @return int The status code.
  */
 public function handle(Args $args, IO $io)
 {
     $packageFile = $this->packageFileManager->getPackageFile();
     $originVersion = $packageFile->getVersion();
     $targetVersion = $args->getArgument('version');
     if (version_compare($originVersion, $targetVersion, '=')) {
         $io->writeLine(sprintf('Your puli.json is already at version %s.', $targetVersion));
         return 0;
     }
     $this->packageFileManager->migrate($targetVersion);
     $io->writeLine(sprintf('Migrated your puli.json from version %s to version %s.', $originVersion, $targetVersion));
     return 0;
 }
예제 #3
0
 /**
  * @expectedException \RuntimeException
  */
 public function testDeletePluginFailsIfNotInstalled()
 {
     $args = self::$deleteCommand->parseArgs(new StringArgs('My\\Plugin\\Class'));
     $this->manager->expects($this->once())->method('hasPluginClass')->with('My\\Plugin\\Class')->willReturn(false);
     $this->manager->expects($this->never())->method('removePluginClass');
     $this->handler->handleDelete($args);
 }
 private function persistServersData()
 {
     if ($this->serversData) {
         $this->rootPackageFileManager->setExtraKey(self::SERVERS_KEY, (object) $this->serversData);
     } else {
         $this->rootPackageFileManager->removeExtraKey(self::SERVERS_KEY);
     }
 }
 public function testClearRootInstallerDescriptors()
 {
     $this->rootPackageFile->setExtraKey(AssetPlugin::INSTALLERS_KEY, (object) array('symlink' => (object) array('class' => 'SymlinkInstaller'), 'cdn' => (object) array('class' => 'CdnInstaller')));
     $this->packageFileManager->expects($this->once())->method('removeExtraKey')->with(AssetPlugin::INSTALLERS_KEY);
     $this->manager->clearRootInstallerDescriptors();
     $this->assertFalse($this->manager->hasInstallerDescriptor('symlink'));
     $this->assertFalse($this->manager->hasInstallerDescriptor('cdn'));
 }
예제 #6
0
 public function testResetKey()
 {
     $args = self::$resetCommand->parseArgs(new StringArgs('the-key'));
     $this->manager->expects($this->once())->method('removeConfigKey')->with('the-key');
     $statusCode = $this->handler->handleReset($args);
     $this->assertSame(0, $statusCode);
     $this->assertEmpty($this->io->fetchOutput());
     $this->assertEmpty($this->io->fetchErrors());
 }
 private function persistTargetsData()
 {
     if ($this->targetsData) {
         $this->updateDefaultTargetData();
         $this->rootPackageFileManager->setExtraKey(AssetPlugin::INSTALL_TARGETS_KEY, (object) $this->targetsData);
     } else {
         $this->rootPackageFileManager->removeExtraKey(AssetPlugin::INSTALL_TARGETS_KEY);
     }
 }
 private function persistInstallersData()
 {
     $data = array();
     foreach ($this->rootInstallerDescriptors as $installerName => $installer) {
         $data[$installerName] = $this->installerToData($installer);
     }
     if ($data) {
         $this->rootPackageFileManager->setExtraKey(self::INSTALLERS_KEY, (object) $data);
     } else {
         $this->rootPackageFileManager->removeExtraKey(self::INSTALLERS_KEY);
     }
 }
 protected function populateDefaultManager()
 {
     $this->packageFileManager->expects($this->any())->method('getExtraKey')->with(PackageFileServerManager::SERVERS_KEY)->willReturn((object) array('localhost' => (object) array('installer' => 'symlink', 'document-root' => 'web', 'url-format' => '/public/%s')));
 }
예제 #10
0
 /**
  * Handles the "config -r <key>" command.
  *
  * @param Args $args The console arguments.
  *
  * @return int The status code.
  */
 public function handleReset(Args $args)
 {
     $this->manager->removeConfigKey($args->getArgument('key'));
     return 0;
 }
 protected function populateDefaultManager()
 {
     $this->packageFileManager->expects($this->any())->method('getExtraKey')->with(AssetPlugin::INSTALL_TARGETS_KEY)->willReturn((object) array('local' => (object) array('installer' => 'symlink', 'location' => 'web', 'url-format' => '/public/%s', 'default' => true)));
 }