Fix build service test - mock environment store
This commit is contained in:
parent
5da247afc7
commit
1cef8260e9
2 changed files with 49 additions and 6 deletions
|
|
@ -24,6 +24,11 @@ class BuildServiceTest extends \PHPUnit_Framework_TestCase
|
|||
*/
|
||||
protected $mockBuildStore;
|
||||
|
||||
/**
|
||||
* @var \ $mockEnvironmentStore
|
||||
*/
|
||||
protected $mockEnvironmentStore;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$this->mockBuildStore = $this->getMockBuilder('PHPCensor\Store\BuildStore')->getMock();
|
||||
|
|
@ -31,12 +36,25 @@ class BuildServiceTest extends \PHPUnit_Framework_TestCase
|
|||
->method('save')
|
||||
->will($this->returnArgument(0));
|
||||
|
||||
$this->mockEnvironmentStore = $this->getMockBuilder('PHPCensor\Store\EnvironmentStore')->getMock();
|
||||
$this->mockEnvironmentStore->expects($this->any())
|
||||
->method('getByProjectId')
|
||||
->will($this->returnValue(['items' => [], 'count' => 0]));
|
||||
|
||||
$this->testedService = new BuildService($this->mockBuildStore);
|
||||
}
|
||||
|
||||
public function testExecute_CreateBasicBuild()
|
||||
{
|
||||
$project = new Project();
|
||||
$project = $this
|
||||
->getMockBuilder('PHPCensor\Model\Project')
|
||||
->setMethods(['getEnvironmentStore'])
|
||||
->getMock();
|
||||
|
||||
$project->expects($this->any())
|
||||
->method('getEnvironmentStore')
|
||||
->will($this->returnValue($this->mockEnvironmentStore));
|
||||
|
||||
$project->setType('github');
|
||||
$project->setId(101);
|
||||
|
||||
|
|
@ -57,7 +75,15 @@ class BuildServiceTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
public function testExecute_CreateBuildWithOptions()
|
||||
{
|
||||
$project = new Project();
|
||||
$project = $this
|
||||
->getMockBuilder('PHPCensor\Model\Project')
|
||||
->setMethods(['getEnvironmentStore'])
|
||||
->getMock();
|
||||
|
||||
$project->expects($this->any())
|
||||
->method('getEnvironmentStore')
|
||||
->will($this->returnValue($this->mockEnvironmentStore));
|
||||
|
||||
$project->setType('hg');
|
||||
$project->setId(101);
|
||||
|
||||
|
|
@ -71,7 +97,15 @@ class BuildServiceTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
public function testExecute_CreateBuildWithExtra()
|
||||
{
|
||||
$project = new Project();
|
||||
$project = $this
|
||||
->getMockBuilder('PHPCensor\Model\Project')
|
||||
->setMethods(['getEnvironmentStore'])
|
||||
->getMock();
|
||||
|
||||
$project->expects($this->any())
|
||||
->method('getEnvironmentStore')
|
||||
->will($this->returnValue($this->mockEnvironmentStore));
|
||||
|
||||
$project->setType('bitbucket');
|
||||
$project->setId(101);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue