1
0
Fork 0

VersionGuesser test for HG

pull/6236/head
Filippo Tessarotto 2017-03-08 16:10:12 +01:00
parent 122e422682
commit 04b1ddb79f
1 changed files with 67 additions and 0 deletions

View File

@ -25,6 +25,73 @@ class VersionGuesserTest extends \PHPUnit_Framework_TestCase
}
}
public function testHgGuessVersionReturnsData()
{
$branch = 'default';
$executor = $this->getMockBuilder('\\Composer\\Util\\ProcessExecutor')
->setMethods(array('execute'))
->disableArgumentCloning()
->disableOriginalConstructor()
->getMock()
;
$self = $this;
$step = 0;
$executor
->expects($this->at($step))
->method('execute')
->willReturnCallback(function ($command, &$output) use ($self) {
$self->assertEquals('git branch --no-color --no-abbrev -v', $command);
return 128;
})
;
++$step;
$executor
->expects($this->at($step))
->method('execute')
->willReturnCallback(function ($command, &$output) use ($self) {
$self->assertEquals('git describe --exact-match --tags', $command);
return 128;
})
;
++$step;
$executor
->expects($this->at($step))
->method('execute')
->willReturnCallback(function ($command, &$output) use ($self) {
$self->assertEquals('git log --pretty="%H" -n1 HEAD', $command);
return 128;
})
;
++$step;
$executor
->expects($this->at($step))
->method('execute')
->willReturnCallback(function ($command, &$output) use ($self, $branch) {
$self->assertEquals('hg branch', $command);
$output = $branch;
return 0;
})
;
$config = new Config;
$config->merge(array('repositories' => array('packagist' => false)));
$guesser = new VersionGuesser($config, $executor, new VersionParser());
$versionArray = $guesser->guessVersion(array(), 'dummy/path');
$this->assertEquals($branch, $versionArray['version']);
$this->assertEmpty($versionArray['commit']);
}
public function testGuessVersionReturnsData()
{
$commitHash = '03a15d220da53c52eddd5f32ffca64a7b3801bea';