Пример #1
0
 /**
  * Verify that constructing from environment variables works on linux.
  *
  * @test
  * @covers ::__construct
  * @covers ::create
  * @uses \Nubs\Which\Locator::__construct
  * @uses \Nubs\Which\LocatorFactory\PosixLocatorFactory::create
  * @uses \Nubs\Which\LocatorFactory\PosixLocatorFactory::createFromPath
  * @uses \Nubs\Which\PathBuilder\PosixPathBuilder::__construct
  * @uses \Nubs\Which\ExecutableTester::__construct
  */
 public function createWithPosix()
 {
     $this->_isolator->expects($this->once())->method('defined')->with('PHP_WINDOWS_VERSION_BUILD')->will($this->returnValue(false));
     $env = $this->createMock('\\Habitat\\Environment\\Environment');
     $env->expects($this->once())->method('getenv')->with('PATH')->will($this->returnValue('abcd'));
     $locatorFactory = new PlatformLocatorFactory($this->_isolator);
     $locator = $locatorFactory->create($env);
 }
Пример #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;
 }