コード例 #1
0
 /**
  * @see https://github.com/cpliakas/git-wrapper/issues/50
  */
 public function testMultiOption()
 {
     $git = GitCommand::getInstance('test-command')->setOption('test-arg', array(true, true));
     $expected = 'test-command --test-arg --test-arg';
     $commandLine = $git->getCommandLine();
     $this->assertEquals($expected, $commandLine);
 }
コード例 #2
0
ファイル: GitListenerTest.php プロジェクト: bazo/git-wrapper
 public function testEvent()
 {
     $process = new Process('');
     $command = GitCommand::getInstance();
     $event = new GitEvent($this->_wrapper, $process, $command);
     $this->assertEquals($this->_wrapper, $event->getWrapper());
     $this->assertEquals($process, $event->getProcess());
     $this->assertEquals($command, $event->getCommand());
 }
コード例 #3
0
 public function testLogBypassedCommand()
 {
     $logger = new TestLogger();
     $this->wrapper->addLoggerListener(new GitLoggerListener($logger));
     $command = GitCommand::getInstance('status', array('s' => true));
     $command->bypass();
     $this->wrapper->run($command);
     $this->assertEquals('Git command bypassed', $logger->messages[1]);
     $this->assertArrayHasKey('command', $logger->contexts[1]);
     $this->assertEquals(LogLevel::INFO, $logger->levels[1]);
 }
コード例 #4
0
ファイル: GitTest.php プロジェクト: sourcerer-mike/phpsemver
 /**
  * @param $data
  *
  * @dataProvider getGitLsFilesOutputData
  */
 public function testItCanFilterSomeFileNames($data)
 {
     $gitWrapper = $this->getMockBuilder('\\GitWrapper\\GitWrapper')->disableOriginalConstructor()->setMethods(array('run'))->getMock();
     $terminalOutput = implode(PHP_EOL, $data);
     $gitWrapper->expects($this->any())->method('run')->withAnyParameters()->willReturn($terminalOutput);
     $command = GitCommand::getInstance();
     $command->setFlag('version')->setDirectory('.');
     $this->assertSame($terminalOutput, $gitWrapper->run($command));
     $git = $this->getTargetMockBuilder()->disableOriginalConstructor()->setMethods(array('_getGitWrapper'))->getMock();
     $git->expects($this->any())->method('_getGitWrapper')->willReturn($gitWrapper);
     // assert empty dir
     $fs = new Filesystem();
     $fs->remove($git->getTempPath());
     // create directory
     mkdir($git->getTempPath(), 0777, true);
     // set wrapper for temporary path
     $reflectObject = new \ReflectionObject($git);
     $property = $reflectObject->getProperty('_fileWrapper');
     $property->setAccessible(true);
     $property->setValue($git, new Directory($git->getTempPath()));
     $this->assertEquals($data, array_keys($git->getAllFileNames()));
 }
コード例 #5
0
ファイル: GitWrapper.php プロジェクト: shirone/git-wrapper
 /**
  * Runs an arbitrary Git command.
  *
  * The command is simply a raw command line entry for everything after the
  * Git binary. For example, a `git config -l` command would be passed as
  * `config -l` via the first argument of this method.
  *
  * Note that no events are thrown by this method.
  *
  * @param string $commandLine
  *   The raw command containing the Git options and arguments. The Git
  *   binary should not be in the command, for example `git config -l` would
  *   translate to "config -l".
  * @param string|null $cwd
  *   The working directory of the Git process. Defaults to null which uses
  *   the current working directory of the PHP process.
  *
  * @return string
  *   The STDOUT returned by the Git command.
  *
  * @throws \GitWrapper\GitException
  *
  * @see GitWrapper::run()
  */
 public function git($commandLine, $cwd = null)
 {
     $command = GitCommand::getInstance($commandLine);
     $command->setDirectory($cwd);
     return $this->run($command);
 }
コード例 #6
0
ファイル: GitCommandTest.php プロジェクト: bazo/git-wrapper
 /**
  * @depends testGitCommit
  */
 public function testGitCommitArgs()
 {
     $commit = GitCommand::getInstance('commit', 'files', array('m' => 'log message'));
     $expected = "commit -m 'log message' 'files'";
     $this->assertEquals($expected, $commit->getCommandLine());
 }
コード例 #7
0
ファイル: GitWrapperTest.php プロジェクト: bazo/git-wrapper
 /**
  * @expectedException \GitWrapper\GitException
  */
 public function testGitRunDirectoryError()
 {
     $command = GitCommand::getInstance();
     $command->setFlag('version');
     $command->setDirectory('/some/bad/directory');
     $this->_wrapper->run($command);
 }