Esempio n. 1
0
 /**
  * @expectedException \RuntimeException
  */
 public function testDownloadThrowsRuntimeExceptionIfGitCommandFails()
 {
     $expectedGitCommand = $this->getCmd('git clone \'https://github.com/l3l0/composer\' \'composerPath\' && cd \'composerPath\' && git checkout \'ref\' && git reset --hard \'ref\'');
     $packageMock = $this->getMock('Composer\\Package\\PackageInterface');
     $packageMock->expects($this->any())->method('getSourceReference')->will($this->returnValue('ref'));
     $packageMock->expects($this->once())->method('getSourceUrl')->will($this->returnValue('https://github.com/l3l0/composer'));
     $processExecutor = $this->getMock('Composer\\Util\\ProcessExecutor');
     $processExecutor->expects($this->once())->method('execute')->with($this->equalTo($expectedGitCommand))->will($this->returnValue(1));
     $downloader = new GitDownloader($this->getMock('Composer\\IO\\IOInterface'), $processExecutor);
     $downloader->download($packageMock, 'composerPath');
 }
Esempio n. 2
0
 protected function fetch($target)
 {
     $package = Package::factory($this->name, $this->version, $this->prettyVersion);
     $package->setSourceType('git');
     $package->setSourceUrl($this->url);
     $package->setSourceReference($this->version);
     $package->setRootDir($target);
     $downloader = new GitDownloader($this->io, new Config());
     if (null !== $downloader) {
         $downloader->download($package, $target);
     }
 }