|
@@ -60,7 +60,7 @@ class GitDownloaderTest extends \PHPUnit_Framework_TestCase
|
|
|
->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");
|
|
|
+ $expectedGitCommand = $this->winCompat("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))
|
|
@@ -68,17 +68,17 @@ class GitDownloaderTest extends \PHPUnit_Framework_TestCase
|
|
|
|
|
|
$processExecutor->expects($this->at(1))
|
|
|
->method('execute')
|
|
|
- ->with($this->equalTo($this->getCmd("git branch -r")), $this->equalTo(null), $this->equalTo('composerPath'))
|
|
|
+ ->with($this->equalTo($this->winCompat("git branch -r")), $this->equalTo(null), $this->equalTo($this->winCompat('composerPath')))
|
|
|
->will($this->returnValue(0));
|
|
|
|
|
|
$processExecutor->expects($this->at(2))
|
|
|
->method('execute')
|
|
|
- ->with($this->equalTo($this->getCmd("git checkout 'master'")), $this->equalTo(null), $this->equalTo('composerPath'))
|
|
|
+ ->with($this->equalTo($this->winCompat("git checkout 'master'")), $this->equalTo(null), $this->equalTo($this->winCompat('composerPath')))
|
|
|
->will($this->returnValue(0));
|
|
|
|
|
|
$processExecutor->expects($this->at(3))
|
|
|
->method('execute')
|
|
|
- ->with($this->equalTo($this->getCmd("git reset --hard '1234567890123456789012345678901234567890'")), $this->equalTo(null), $this->equalTo('composerPath'))
|
|
|
+ ->with($this->equalTo($this->winCompat("git reset --hard '1234567890123456789012345678901234567890'")), $this->equalTo(null), $this->equalTo($this->winCompat('composerPath')))
|
|
|
->will($this->returnValue(0));
|
|
|
|
|
|
$downloader = $this->getDownloaderMock(null, null, $processExecutor);
|
|
@@ -99,28 +99,28 @@ class GitDownloaderTest extends \PHPUnit_Framework_TestCase
|
|
|
->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");
|
|
|
+ $expectedGitCommand = $this->winCompat("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 remote add composer 'https://github.com/composer/composer' && git fetch composer");
|
|
|
+ $expectedGitCommand = $this->winCompat("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 remote add composer 'http://github.com/composer/composer' && git fetch composer");
|
|
|
+ $expectedGitCommand = $this->winCompat("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))
|
|
|
->will($this->returnValue(0));
|
|
|
|
|
|
- $expectedGitCommand = $this->getCmd("git remote set-url --push origin 'git@github.com:composer/composer.git'");
|
|
|
+ $expectedGitCommand = $this->winCompat("git remote set-url --push origin 'git@github.com:composer/composer.git'");
|
|
|
$processExecutor->expects($this->at(5))
|
|
|
->method('execute')
|
|
|
- ->with($this->equalTo($expectedGitCommand), $this->equalTo(null), $this->equalTo('composerPath'))
|
|
|
+ ->with($this->equalTo($expectedGitCommand), $this->equalTo(null), $this->equalTo($this->winCompat('composerPath')))
|
|
|
->will($this->returnValue(0));
|
|
|
|
|
|
$processExecutor->expects($this->at(6))
|
|
@@ -130,7 +130,7 @@ class GitDownloaderTest extends \PHPUnit_Framework_TestCase
|
|
|
|
|
|
$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'))
|
|
|
+ ->with($this->equalTo($this->winCompat("git checkout 'ref' && git reset --hard 'ref'")), $this->equalTo(null), $this->equalTo($this->winCompat('composerPath')))
|
|
|
->will($this->returnValue(0));
|
|
|
|
|
|
$downloader = $this->getDownloaderMock(null, new Config(), $processExecutor);
|
|
@@ -151,7 +151,7 @@ class GitDownloaderTest extends \PHPUnit_Framework_TestCase
|
|
|
->will($this->returnValue('1.0.0'));
|
|
|
$processExecutor = $this->getMock('Composer\Util\ProcessExecutor');
|
|
|
|
|
|
- $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");
|
|
|
+ $expectedGitCommand = $this->winCompat("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(0))
|
|
|
->method('execute')
|
|
|
->with($this->equalTo($expectedGitCommand))
|
|
@@ -173,7 +173,7 @@ class GitDownloaderTest extends \PHPUnit_Framework_TestCase
|
|
|
*/
|
|
|
public function testDownloadThrowsRuntimeExceptionIfGitCommandFails()
|
|
|
{
|
|
|
- $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");
|
|
|
+ $expectedGitCommand = $this->winCompat("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')
|
|
@@ -208,7 +208,7 @@ class GitDownloaderTest extends \PHPUnit_Framework_TestCase
|
|
|
|
|
|
public function testUpdate()
|
|
|
{
|
|
|
- $expectedGitUpdateCommand = $this->getCmd("git remote set-url composer 'git://github.com/composer/composer' && git fetch composer && git fetch --tags composer");
|
|
|
+ $expectedGitUpdateCommand = $this->winCompat("git remote set-url composer 'git://github.com/composer/composer' && git fetch composer && git fetch --tags composer");
|
|
|
|
|
|
$packageMock = $this->getMock('Composer\Package\PackageInterface');
|
|
|
$packageMock->expects($this->any())
|
|
@@ -223,7 +223,7 @@ class GitDownloaderTest extends \PHPUnit_Framework_TestCase
|
|
|
$processExecutor = $this->getMock('Composer\Util\ProcessExecutor');
|
|
|
$processExecutor->expects($this->at(0))
|
|
|
->method('execute')
|
|
|
- ->with($this->equalTo($this->getCmd("git remote -v")))
|
|
|
+ ->with($this->equalTo($this->winCompat("git remote -v")))
|
|
|
->will($this->returnValue(0));
|
|
|
$processExecutor->expects($this->at(1))
|
|
|
->method('execute')
|
|
@@ -235,7 +235,7 @@ class GitDownloaderTest extends \PHPUnit_Framework_TestCase
|
|
|
->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'))
|
|
|
+ ->with($this->equalTo($this->winCompat("git checkout 'ref' && git reset --hard 'ref'")), $this->equalTo(null), $this->equalTo($this->winCompat('composerPath')))
|
|
|
->will($this->returnValue(0));
|
|
|
|
|
|
$downloader = $this->getDownloaderMock(null, new Config(), $processExecutor);
|
|
@@ -247,7 +247,7 @@ class GitDownloaderTest extends \PHPUnit_Framework_TestCase
|
|
|
*/
|
|
|
public function testUpdateThrowsRuntimeExceptionIfGitCommandFails()
|
|
|
{
|
|
|
- $expectedGitUpdateCommand = $this->getCmd("git remote set-url composer 'git://github.com/composer/composer' && git fetch composer && git fetch --tags composer");
|
|
|
+ $expectedGitUpdateCommand = $this->winCompat("git remote set-url composer 'git://github.com/composer/composer' && git fetch composer && git fetch --tags composer");
|
|
|
|
|
|
$packageMock = $this->getMock('Composer\Package\PackageInterface');
|
|
|
$packageMock->expects($this->any())
|
|
@@ -259,7 +259,7 @@ class GitDownloaderTest extends \PHPUnit_Framework_TestCase
|
|
|
$processExecutor = $this->getMock('Composer\Util\ProcessExecutor');
|
|
|
$processExecutor->expects($this->at(0))
|
|
|
->method('execute')
|
|
|
- ->with($this->equalTo($this->getCmd("git remote -v")))
|
|
|
+ ->with($this->equalTo($this->winCompat("git remote -v")))
|
|
|
->will($this->returnValue(0));
|
|
|
$processExecutor->expects($this->at(1))
|
|
|
->method('execute')
|
|
@@ -272,7 +272,7 @@ class GitDownloaderTest extends \PHPUnit_Framework_TestCase
|
|
|
|
|
|
public function testRemove()
|
|
|
{
|
|
|
- $expectedGitResetCommand = $this->getCmd("cd 'composerPath' && git status --porcelain --untracked-files=no");
|
|
|
+ $expectedGitResetCommand = $this->winCompat("cd 'composerPath' && git status --porcelain --untracked-files=no");
|
|
|
|
|
|
$packageMock = $this->getMock('Composer\Package\PackageInterface');
|
|
|
$processExecutor = $this->getMock('Composer\Util\ProcessExecutor');
|
|
@@ -297,10 +297,11 @@ class GitDownloaderTest extends \PHPUnit_Framework_TestCase
|
|
|
$this->assertEquals('source', $downloader->getInstallationSource());
|
|
|
}
|
|
|
|
|
|
- private function getCmd($cmd)
|
|
|
+ private function winCompat($cmd)
|
|
|
{
|
|
|
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
|
|
$cmd = str_replace('cd ', 'cd /D ', $cmd);
|
|
|
+ $cmd = str_replace('composerPath', getcwd().'/composerPath', $cmd);
|
|
|
|
|
|
return strtr($cmd, "'", '"');
|
|
|
}
|