Permalink
Browse files

GogsBuild: unit tests for the links generations

  • Loading branch information...
simmstein committed Jun 7, 2018
1 parent 0205400 commit 9bc2f69712bbd4d74cab9c004abe8bfa3c6cc86b
Showing with 37 additions and 0 deletions.
  1. +37 −0 tests/src/Model/BuildTest.php
@@ -4,6 +4,8 @@
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 @@ public function testExecute_TestBuildExtra()
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()
);
}
}

0 comments on commit 9bc2f69

Please sign in to comment.