예제 #1
0
 public function testCloneCallsTheGitCommandCorrectlyAndReturnsRepositoryInstance()
 {
     $binary = '/usr/bin/git';
     $url = 'https://github.com/lshepstone/php-git.git';
     $path = $this->getMockRepoPath();
     $class = '\\PhpGit\\GitTest_Repository';
     $result = $this->getMockBuilder('\\PhpProc\\Result')->disableOriginalConstructor()->getMock();
     $result->expects($this->once())->method('hasErrors')->will($this->returnValue(false));
     $process = $this->getMockBuilder('\\PhpProc\\Process')->disableOriginalConstructor()->getMock();
     $process->expects($this->once())->method('setCommand')->with($this->equalTo("{$binary} clone \"{$url}\" \"{$path}\""))->will($this->returnSelf());
     $process->expects($this->once())->method('execute')->will($this->returnValue($result));
     $git = new Git($binary, $process);
     $git->setRepositoryClass($class);
     $repository = $git->clone($url, $path);
     $this->assertInstanceOf($class, $repository);
 }