From f70d527f4f9d03bd7d748c373db68dde56ada74f Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Wed, 17 Jun 2020 17:53:00 +0200 Subject: [PATCH] Fix git tests --- src/Composer/Util/Git.php | 2 +- .../Test/Downloader/GitDownloaderTest.php | 21 +++++++------------ 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/src/Composer/Util/Git.php b/src/Composer/Util/Git.php index c53c0a11a..8a934cf30 100644 --- a/src/Composer/Util/Git.php +++ b/src/Composer/Util/Git.php @@ -403,7 +403,7 @@ class Git * * @return string|null The git version number. */ - public static function getVersion(ProcessExecutor $process = null) + public static function getVersion(ProcessExecutor $process) { if (false === self::$version) { self::$version = null; diff --git a/tests/Composer/Test/Downloader/GitDownloaderTest.php b/tests/Composer/Test/Downloader/GitDownloaderTest.php index 933fa26b1..6618618e1 100644 --- a/tests/Composer/Test/Downloader/GitDownloaderTest.php +++ b/tests/Composer/Test/Downloader/GitDownloaderTest.php @@ -404,7 +404,6 @@ class GitDownloaderTest extends TestCase ->will($this->returnValue('1.0.0.0')); $process = $this->prophesize('Composer\Util\ProcessExecutor'); - $process->execute($this->winCompat('git --version'), Argument::cetera())->willReturn(0); $process->execute($this->winCompat('git show-ref --head -d'), Argument::cetera())->willReturn(0); $process->execute($this->winCompat('git status --porcelain --untracked-files=no'), Argument::cetera())->willReturn(0); $process->execute($this->winCompat('git remote -v'), Argument::cetera())->willReturn(0); @@ -441,33 +440,29 @@ class GitDownloaderTest extends TestCase $processExecutor = $this->getMockBuilder('Composer\Util\ProcessExecutor')->getMock(); $processExecutor->expects($this->at(0)) ->method('execute') - ->with($this->equalTo($this->winCompat("git --version"))) + ->with($this->equalTo($this->winCompat("git show-ref --head -d"))) ->will($this->returnValue(0)); $processExecutor->expects($this->at(1)) ->method('execute') - ->with($this->equalTo($this->winCompat("git show-ref --head -d"))) + ->with($this->equalTo($this->winCompat("git status --porcelain --untracked-files=no"))) ->will($this->returnValue(0)); $processExecutor->expects($this->at(2)) ->method('execute') - ->with($this->equalTo($this->winCompat("git status --porcelain --untracked-files=no"))) + ->with($this->equalTo($this->winCompat("git remote -v"))) ->will($this->returnValue(0)); $processExecutor->expects($this->at(3)) ->method('execute') - ->with($this->equalTo($this->winCompat("git remote -v"))) + ->with($this->equalTo($this->winCompat($expectedGitUpdateCommand)), $this->equalTo(null), $this->equalTo($this->winCompat($this->workingDir))) ->will($this->returnValue(0)); $processExecutor->expects($this->at(4)) ->method('execute') - ->with($this->equalTo($this->winCompat($expectedGitUpdateCommand)), $this->equalTo(null), $this->equalTo($this->winCompat($this->workingDir))) + ->with($this->equalTo('git branch -r')) ->will($this->returnValue(0)); $processExecutor->expects($this->at(5)) - ->method('execute') - ->with($this->equalTo('git branch -r')) - ->will($this->returnValue(0)); - $processExecutor->expects($this->at(6)) ->method('execute') ->with($this->equalTo($this->winCompat("git checkout 'ref' -- && git reset --hard 'ref' --")), $this->equalTo(null), $this->equalTo($this->winCompat($this->workingDir))) ->will($this->returnValue(0)); - $processExecutor->expects($this->at(7)) + $processExecutor->expects($this->at(6)) ->method('execute') ->with($this->equalTo($this->winCompat("git remote -v"))) ->will($this->returnCallback(function ($cmd, &$output, $cwd) { @@ -479,11 +474,11 @@ composer https://github.com/old/url (push) return 0; })); - $processExecutor->expects($this->at(8)) + $processExecutor->expects($this->at(7)) ->method('execute') ->with($this->equalTo($this->winCompat("git remote set-url origin 'https://github.com/composer/composer'")), $this->equalTo(null), $this->equalTo($this->winCompat($this->workingDir))) ->will($this->returnValue(0)); - $processExecutor->expects($this->at(9)) + $processExecutor->expects($this->at(8)) ->method('execute') ->with($this->equalTo($this->winCompat("git remote set-url --push origin 'git@github.com:composer/composer.git'")), $this->equalTo(null), $this->equalTo($this->winCompat($this->workingDir))) ->will($this->returnValue(0));