1
0
Fork 0
mirror of https://github.com/composer/composer synced 2025-05-09 00:22:53 +00:00

Fix git checkouts of custom branches, fixes #889

This commit is contained in:
Jordi Boggiano 2012-07-10 19:02:06 +02:00
parent f12818233d
commit 354b82bb8c
2 changed files with 31 additions and 4 deletions

View file

@ -44,10 +44,13 @@ class GitDownloaderTest extends \PHPUnit_Framework_TestCase
$packageMock = $this->getMock('Composer\Package\PackageInterface');
$packageMock->expects($this->any())
->method('getSourceReference')
->will($this->returnValue('ref'));
->will($this->returnValue('1234567890123456789012345678901234567890'));
$packageMock->expects($this->any())
->method('getSourceUrl')
->will($this->returnValue('https://example.com/composer/composer'));
$packageMock->expects($this->any())
->method('getPrettyVersion')
->will($this->returnValue('dev-master'));
$processExecutor = $this->getMock('Composer\Util\ProcessExecutor');
$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");
@ -58,7 +61,7 @@ class GitDownloaderTest extends \PHPUnit_Framework_TestCase
$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'))
->with($this->equalTo($this->getCmd("git checkout '1234567890123456789012345678901234567890' && git reset --hard '1234567890123456789012345678901234567890'")), $this->equalTo(null), $this->equalTo('composerPath'))
->will($this->returnValue(0));
$downloader = $this->getDownloaderMock(null, $processExecutor);
@ -74,6 +77,9 @@ class GitDownloaderTest extends \PHPUnit_Framework_TestCase
$packageMock->expects($this->any())
->method('getSourceUrl')
->will($this->returnValue('https://github.com/composer/composer'));
$packageMock->expects($this->any())
->method('getPrettyVersion')
->will($this->returnValue('1.0.0'));
$processExecutor = $this->getMock('Composer\Util\ProcessExecutor');
$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");
@ -101,6 +107,11 @@ class GitDownloaderTest extends \PHPUnit_Framework_TestCase
->will($this->returnValue(0));
$processExecutor->expects($this->at(6))
->method('execute')
->with($this->equalTo('git branch -r'))
->will($this->returnValue(0));
$processExecutor->expects($this->at(7))
->method('execute')
->with($this->equalTo($this->getCmd("git checkout 'ref' && git reset --hard 'ref'")), $this->equalTo(null), $this->equalTo('composerPath'))
->will($this->returnValue(0));
@ -159,6 +170,9 @@ class GitDownloaderTest extends \PHPUnit_Framework_TestCase
$packageMock->expects($this->any())
->method('getSourceUrl')
->will($this->returnValue('https://github.com/composer/composer'));
$packageMock->expects($this->any())
->method('getPrettyVersion')
->will($this->returnValue('1.0.0'));
$processExecutor = $this->getMock('Composer\Util\ProcessExecutor');
$processExecutor->expects($this->at(0))
->method('execute')
@ -173,6 +187,10 @@ class GitDownloaderTest extends \PHPUnit_Framework_TestCase
->with($this->equalTo($expectedGitUpdateCommand))
->will($this->returnValue(0));
$processExecutor->expects($this->at(3))
->method('execute')
->with($this->equalTo('git branch -r'))
->will($this->returnValue(0));
$processExecutor->expects($this->at(4))
->method('execute')
->with($this->equalTo($this->getCmd("git checkout 'ref' && git reset --hard 'ref'")), $this->equalTo(null), $this->equalTo('composerPath'))
->will($this->returnValue(0));