2014-07-14 15:59:04 +02:00
|
|
|
<?php
|
2015-03-03 17:18:17 +01:00
|
|
|
|
2016-07-19 20:28:11 +02:00
|
|
|
namespace Tests\PHPCensor\Model;
|
2014-07-14 15:59:04 +02:00
|
|
|
|
2016-07-19 20:28:11 +02:00
|
|
|
use PHPCensor\Model\Project;
|
|
|
|
use PHPCensor\Model;
|
2014-07-14 15:59:04 +02:00
|
|
|
|
|
|
|
/**
|
2014-07-14 17:02:36 +02:00
|
|
|
* Unit tests for the Project model class.
|
2017-03-04 16:39:56 +01:00
|
|
|
*
|
2014-07-14 15:59:04 +02:00
|
|
|
* @author Dan Cryer <dan@block8.co.uk>
|
|
|
|
*/
|
2017-07-24 08:45:52 +02:00
|
|
|
class ProjectTest extends \PHPUnit\Framework\TestCase
|
2014-07-14 15:59:04 +02:00
|
|
|
{
|
2014-07-14 17:02:36 +02:00
|
|
|
public function testExecute_TestIsAValidModel()
|
|
|
|
{
|
|
|
|
$project = new Project();
|
|
|
|
$this->assertTrue($project instanceof \b8\Model);
|
|
|
|
$this->assertTrue($project instanceof Model);
|
|
|
|
}
|
|
|
|
|
2014-07-14 15:59:04 +02:00
|
|
|
public function testExecute_TestGitDefaultBranch()
|
|
|
|
{
|
|
|
|
$project = new Project();
|
|
|
|
$project->setType('git');
|
|
|
|
|
|
|
|
$this->assertEquals('master', $project->getBranch());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testExecute_TestGithubDefaultBranch()
|
|
|
|
{
|
|
|
|
$project = new Project();
|
|
|
|
$project->setType('github');
|
|
|
|
|
|
|
|
$this->assertEquals('master', $project->getBranch());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testExecute_TestGitlabDefaultBranch()
|
|
|
|
{
|
|
|
|
$project = new Project();
|
|
|
|
$project->setType('gitlab');
|
|
|
|
|
|
|
|
$this->assertEquals('master', $project->getBranch());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testExecute_TestBitbucketDefaultBranch()
|
|
|
|
{
|
|
|
|
$project = new Project();
|
|
|
|
$project->setType('bitbucket');
|
|
|
|
|
|
|
|
$this->assertEquals('master', $project->getBranch());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testExecute_TestMercurialDefaultBranch()
|
|
|
|
{
|
|
|
|
$project = new Project();
|
|
|
|
$project->setType('hg');
|
|
|
|
|
|
|
|
$this->assertEquals('default', $project->getBranch());
|
|
|
|
}
|
2014-07-14 17:02:36 +02:00
|
|
|
|
|
|
|
public function testExecute_TestProjectAccessInformation()
|
|
|
|
{
|
2016-04-21 09:46:38 +02:00
|
|
|
$info = [
|
2014-07-14 17:02:36 +02:00
|
|
|
'item1' => 'Item One',
|
|
|
|
'item2' => 2,
|
2016-04-21 09:46:38 +02:00
|
|
|
];
|
2014-07-14 17:02:36 +02:00
|
|
|
|
|
|
|
$project = new Project();
|
2014-07-30 16:13:50 +02:00
|
|
|
$project->setAccessInformation($info);
|
2014-07-14 17:02:36 +02:00
|
|
|
|
|
|
|
$this->assertEquals('Item One', $project->getAccessInformation('item1'));
|
|
|
|
$this->assertEquals(2, $project->getAccessInformation('item2'));
|
|
|
|
$this->assertNull($project->getAccessInformation('item3'));
|
|
|
|
$this->assertEquals($info, $project->getAccessInformation());
|
|
|
|
}
|
2014-07-14 15:59:04 +02:00
|
|
|
}
|