Re-add unit test for FETCH_HEAD parsing
parent
313e6b914d
commit
c2fe198ebc
|
@ -158,16 +158,15 @@ class VersionGuesserTest extends \PHPUnit_Framework_TestCase
|
|||
$this->assertEquals("dev-$commitHash", $versionData['version']);
|
||||
}
|
||||
|
||||
public function testDetachedHeadBecomesDevHashGit2()
|
||||
public function testDetachedFetchHeadBecomesDevHashGit2()
|
||||
{
|
||||
$commitHash = '03a15d220da53c52eddd5f32ffca64a7b3801bea';
|
||||
$commitHash = 'da53c52eddd5f32ffca64a7b3801bea';
|
||||
|
||||
$executor = $this->getMockBuilder('\\Composer\\Util\\ProcessExecutor')
|
||||
->setMethods(array('execute'))
|
||||
->setMethods(['execute'])
|
||||
->disableArgumentCloning()
|
||||
->disableOriginalConstructor()
|
||||
->getMock()
|
||||
;
|
||||
->getMock();
|
||||
|
||||
$self = $this;
|
||||
|
||||
|
@ -176,16 +175,45 @@ class VersionGuesserTest extends \PHPUnit_Framework_TestCase
|
|||
->method('execute')
|
||||
->willReturnCallback(function ($command, &$output) use ($self, $commitHash) {
|
||||
$self->assertEquals('git branch --no-color --no-abbrev -v', $command);
|
||||
$output = "* (HEAD detached at " . substr($commitHash, 0, 9) . ") $commitHash Commit message\n";
|
||||
$output = "* (HEAD detached at FETCH_HEAD) $commitHash Commit message\n";
|
||||
|
||||
return 0;
|
||||
})
|
||||
;
|
||||
});
|
||||
|
||||
$config = new Config;
|
||||
$config->merge(array('repositories' => array('packagist' => false)));
|
||||
$config->merge(['repositories' => ['packagist' => false]]);
|
||||
$guesser = new VersionGuesser($config, $executor, new VersionParser());
|
||||
$versionData = $guesser->guessVersion(array(), 'dummy/path');
|
||||
$versionData = $guesser->guessVersion([], 'dummy/path');
|
||||
|
||||
$this->assertEquals("dev-$commitHash", $versionData['version']);
|
||||
}
|
||||
|
||||
public function testDetachedCommitHeadBecomesDevHashGit2()
|
||||
{
|
||||
$commitHash = 'da53c52eddd5f32ffca64a7b3801bea';
|
||||
|
||||
$executor = $this->getMockBuilder('\\Composer\\Util\\ProcessExecutor')
|
||||
->setMethods(['execute'])
|
||||
->disableArgumentCloning()
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$self = $this;
|
||||
|
||||
$executor
|
||||
->expects($this->at(0))
|
||||
->method('execute')
|
||||
->willReturnCallback(function ($command, &$output) use ($self, $commitHash) {
|
||||
$self->assertEquals('git branch --no-color --no-abbrev -v', $command);
|
||||
$output = "* (HEAD detached at da53c52ed) $commitHash Commit message\n";
|
||||
|
||||
return 0;
|
||||
});
|
||||
|
||||
$config = new Config;
|
||||
$config->merge(['repositories' => ['packagist' => false]]);
|
||||
$guesser = new VersionGuesser($config, $executor, new VersionParser());
|
||||
$versionData = $guesser->guessVersion([], 'dummy/path');
|
||||
|
||||
$this->assertEquals("dev-$commitHash", $versionData['version']);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue