GogsBuild: unit tests for the links generations

This commit is contained in:
Simon Vieille 2018-06-07 16:45:39 +02:00
parent 0205400c77
commit 9bc2f69712
No known key found for this signature in database
GPG key ID: 919533E2B946EA10

View file

@ -4,6 +4,8 @@ namespace Tests\PHPCensor\Model;
use PHPCensor\Exception\InvalidArgumentException;
use PHPCensor\Model\Build;
use PHPCensor\Model\Project;
use PHPCensor\Model\Build\GogsBuild;
/**
* Unit tests for the Build model class.
@ -138,4 +140,39 @@ class BuildTest extends \PHPUnit\Framework\TestCase
self::assertEquals('Item One', $build->getExtra('item1'));
self::assertEquals('Item Three', $build->getExtra('item3'));
}
public function testGogsBuildLinks()
{
$project = new Project();
$project->setType(Project::TYPE_GOGS);
$project->setReference('https://gogs.repository/the-vendor/the-project.git');
$stub = $this->getMockBuilder(GogsBuild::class)
->setMethods(['getProject', 'getCommitId', 'getBranch'])
->getMock();
$stub->method('getProject')
->will($this->returnValue($project));
$stub->method('getCommitId')
->will($this->returnValue('abcdef'));
$stub->method('getBranch')
->will($this->returnValue('master'));
$this->assertEquals(
'https://gogs.repository/the-vendor/the-project/commit/abcdef',
$stub->getCommitLink()
);
$this->assertEquals(
'https://gogs.repository/the-vendor/the-project/src/master',
$stub->getBranchLink()
);
$this->assertEquals(
'https://gogs.repository/the-vendor/the-project/src/abcdef/{FILE}#L{LINE}',
$stub->getFileLinkTemplate()
);
}
}