|
@@ -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';
|