Пример #1
0
 /**
  * Verify that create throws an exception when no command found.
  *
  * @test
  * @covers ::__construct
  * @covers ::create
  * @covers \Nubs\Sensible\CommandFactory\CommandFactoryTrait
  * @expectedException \Exception
  * @expectedExceptionMessage Failed to locate a sensible command
  */
 public function createNoCommandFound()
 {
     $this->_environment->expects($this->once())->method('getenv')->with('EDITOR')->will($this->returnValue(null));
     $this->_commandLocator->expects($this->once())->method('locate')->with('a')->will($this->returnValue(null));
     $factory = new EditorFactory($this->_commandLocator, ['a'], $this->_environment);
     $editor = $factory->create();
 }
Пример #2
0
 /**
  * Allows the user to amend the release notes.
  *
  * @param \Symfony\Component\Console\Input\InputInterface $input The command input.
  * @param string $releaseNotes The release notes to amend.
  * @return string The amended release notes.
  */
 private function _amendReleaseNotes(InputInterface $input, $releaseNotes)
 {
     $commandLocatorFactory = new WhichLocatorFactory();
     $editorFactory = new EditorFactory($commandLocatorFactory->create());
     $editor = $editorFactory->create();
     $processBuilder = new ProcessBuilder();
     return $input->isInteractive() ? $editor->editData($processBuilder, $releaseNotes) : $releaseNotes;
 }
Пример #3
0
Файл: Set.php Проект: nubs/pwman
 /**
  * Alters the passwords with the user's changes returning the passwords to use instead.
  *
  * @param array $passwords The passwords to replace.
  * @return array The new passwords to use instead.
  */
 private function _alterPasswords(array $passwords)
 {
     $commandLocatorFactory = new WhichLocatorFactory();
     $editorFactory = new EditorFactory($commandLocatorFactory->create());
     $editor = $editorFactory->create();
     $updates = json_decode($editor->editData(new ProcessBuilder(), json_encode($passwords, JSON_PRETTY_PRINT | JSON_FORCE_OBJECT)), true);
     if ($updates === null) {
         throw new Exception('Invalid json for application!');
     }
     return $updates;
 }