|
@@ -50,12 +50,17 @@ class GitDownloaderTest extends \PHPUnit_Framework_TestCase
|
|
|
->will($this->returnValue('https://example.com/composer/composer'));
|
|
|
$processExecutor = $this->getMock('Composer\Util\ProcessExecutor');
|
|
|
|
|
|
- $expectedGitCommand = $this->getCmd("git clone 'https://example.com/composer/composer' 'composerPath' && cd 'composerPath' && git checkout 'ref' && git reset --hard 'ref' && git remote add composer 'https://example.com/composer/composer'");
|
|
|
- $processExecutor->expects($this->once())
|
|
|
+ $expectedGitCommand = $this->getCmd("git clone 'https://example.com/composer/composer' 'composerPath' && cd 'composerPath' && git remote add composer 'https://example.com/composer/composer' && git fetch composer");
|
|
|
+ $processExecutor->expects($this->at(0))
|
|
|
->method('execute')
|
|
|
->with($this->equalTo($expectedGitCommand))
|
|
|
->will($this->returnValue(0));
|
|
|
|
|
|
+ $processExecutor->expects($this->at(1))
|
|
|
+ ->method('execute')
|
|
|
+ ->with($this->equalTo($this->getCmd("git checkout 'ref' && git reset --hard 'ref'")), $this->equalTo(null), $this->equalTo('composerPath'))
|
|
|
+ ->will($this->returnValue(0));
|
|
|
+
|
|
|
$downloader = $this->getDownloaderMock(null, $processExecutor);
|
|
|
$downloader->download($packageMock, 'composerPath');
|
|
|
}
|
|
@@ -71,19 +76,19 @@ class GitDownloaderTest extends \PHPUnit_Framework_TestCase
|
|
|
->will($this->returnValue('https://github.com/composer/composer'));
|
|
|
$processExecutor = $this->getMock('Composer\Util\ProcessExecutor');
|
|
|
|
|
|
- $expectedGitCommand = $this->getCmd("git clone 'git://github.com/composer/composer' 'composerPath' && cd 'composerPath' && git checkout 'ref' && git reset --hard 'ref' && git remote add composer 'git://github.com/composer/composer'");
|
|
|
+ $expectedGitCommand = $this->getCmd("git clone 'git://github.com/composer/composer' 'composerPath' && cd 'composerPath' && git remote add composer 'git://github.com/composer/composer' && git fetch composer");
|
|
|
$processExecutor->expects($this->at(0))
|
|
|
->method('execute')
|
|
|
->with($this->equalTo($expectedGitCommand))
|
|
|
->will($this->returnValue(1));
|
|
|
|
|
|
- $expectedGitCommand = $this->getCmd("git clone 'https://github.com/composer/composer' 'composerPath' && cd 'composerPath' && git checkout 'ref' && git reset --hard 'ref' && git remote add composer 'https://github.com/composer/composer'");
|
|
|
+ $expectedGitCommand = $this->getCmd("git clone 'https://github.com/composer/composer' 'composerPath' && cd 'composerPath' && git remote add composer 'https://github.com/composer/composer' && git fetch composer");
|
|
|
$processExecutor->expects($this->at(2))
|
|
|
->method('execute')
|
|
|
->with($this->equalTo($expectedGitCommand))
|
|
|
->will($this->returnValue(1));
|
|
|
|
|
|
- $expectedGitCommand = $this->getCmd("git clone 'http://github.com/composer/composer' 'composerPath' && cd 'composerPath' && git checkout 'ref' && git reset --hard 'ref' && git remote add composer 'http://github.com/composer/composer'");
|
|
|
+ $expectedGitCommand = $this->getCmd("git clone 'http://github.com/composer/composer' 'composerPath' && cd 'composerPath' && git remote add composer 'http://github.com/composer/composer' && git fetch composer");
|
|
|
$processExecutor->expects($this->at(4))
|
|
|
->method('execute')
|
|
|
->with($this->equalTo($expectedGitCommand))
|
|
@@ -95,6 +100,11 @@ class GitDownloaderTest extends \PHPUnit_Framework_TestCase
|
|
|
->with($this->equalTo($expectedGitCommand), $this->equalTo(null), $this->equalTo('composerPath'))
|
|
|
->will($this->returnValue(0));
|
|
|
|
|
|
+ $processExecutor->expects($this->at(6))
|
|
|
+ ->method('execute')
|
|
|
+ ->with($this->equalTo($this->getCmd("git checkout 'ref' && git reset --hard 'ref'")), $this->equalTo(null), $this->equalTo('composerPath'))
|
|
|
+ ->will($this->returnValue(0));
|
|
|
+
|
|
|
$downloader = $this->getDownloaderMock(null, $processExecutor);
|
|
|
$downloader->download($packageMock, 'composerPath');
|
|
|
}
|
|
@@ -104,7 +114,7 @@ class GitDownloaderTest extends \PHPUnit_Framework_TestCase
|
|
|
*/
|
|
|
public function testDownloadThrowsRuntimeExceptionIfGitCommandFails()
|
|
|
{
|
|
|
- $expectedGitCommand = $this->getCmd("git clone 'https://example.com/composer/composer' 'composerPath' && cd 'composerPath' && git checkout 'ref' && git reset --hard 'ref' && git remote add composer 'https://example.com/composer/composer'");
|
|
|
+ $expectedGitCommand = $this->getCmd("git clone 'https://example.com/composer/composer' 'composerPath' && cd 'composerPath' && git remote add composer 'https://example.com/composer/composer' && git fetch composer");
|
|
|
$packageMock = $this->getMock('Composer\Package\PackageInterface');
|
|
|
$packageMock->expects($this->any())
|
|
|
->method('getSourceReference')
|
|
@@ -139,7 +149,7 @@ class GitDownloaderTest extends \PHPUnit_Framework_TestCase
|
|
|
|
|
|
public function testUpdate()
|
|
|
{
|
|
|
- $expectedGitUpdateCommand = $this->getCmd("cd 'composerPath' && git remote set-url composer 'git://github.com/composer/composer' && git fetch composer && git fetch --tags composer && git checkout 'ref' && git reset --hard 'ref'");
|
|
|
+ $expectedGitUpdateCommand = $this->getCmd("cd 'composerPath' && git remote set-url composer 'git://github.com/composer/composer' && git fetch composer && git fetch --tags composer");
|
|
|
$expectedGitResetCommand = $this->getCmd("cd 'composerPath' && git status --porcelain --untracked-files=no");
|
|
|
|
|
|
$packageMock = $this->getMock('Composer\Package\PackageInterface');
|
|
@@ -162,6 +172,10 @@ class GitDownloaderTest extends \PHPUnit_Framework_TestCase
|
|
|
->method('execute')
|
|
|
->with($this->equalTo($expectedGitUpdateCommand))
|
|
|
->will($this->returnValue(0));
|
|
|
+ $processExecutor->expects($this->at(3))
|
|
|
+ ->method('execute')
|
|
|
+ ->with($this->equalTo($this->getCmd("git checkout 'ref' && git reset --hard 'ref'")), $this->equalTo(null), $this->equalTo('composerPath'))
|
|
|
+ ->will($this->returnValue(0));
|
|
|
|
|
|
$downloader = $this->getDownloaderMock(null, $processExecutor);
|
|
|
$downloader->update($packageMock, $packageMock, 'composerPath');
|
|
@@ -172,7 +186,7 @@ class GitDownloaderTest extends \PHPUnit_Framework_TestCase
|
|
|
*/
|
|
|
public function testUpdateThrowsRuntimeExceptionIfGitCommandFails()
|
|
|
{
|
|
|
- $expectedGitUpdateCommand = $this->getCmd("cd 'composerPath' && git remote set-url composer 'git://github.com/composer/composer' && git fetch composer && git fetch --tags composer && git checkout 'ref' && git reset --hard 'ref'");
|
|
|
+ $expectedGitUpdateCommand = $this->getCmd("cd 'composerPath' && git remote set-url composer 'git://github.com/composer/composer' && git fetch composer && git fetch --tags composer");
|
|
|
$expectedGitResetCommand = $this->getCmd("cd 'composerPath' && git status --porcelain --untracked-files=no");
|
|
|
|
|
|
$packageMock = $this->getMock('Composer\Package\PackageInterface');
|