Added status and source build fields validation.

This commit is contained in:
Dmitry Khomutov 2018-03-12 19:51:41 +07:00
commit d3a390d3f8
No known key found for this signature in database
GPG key ID: EC19426474B37AAC
5 changed files with 59 additions and 2 deletions

View file

@ -80,6 +80,9 @@ class BuildTest extends TestCase
$result = $build->setStatus(Build::STATUS_FAILED);
self::assertEquals(false, $result);
self::expectException('\PHPCensor\Exception\HttpException\ValidationException');
$build->setStatus(10);
}
public function testLog()
@ -226,6 +229,9 @@ class BuildTest extends TestCase
$result = $build->setSource(Build::SOURCE_WEBHOOK_PULL_REQUEST);
self::assertEquals(false, $result);
self::expectException('\PHPCensor\Exception\HttpException\ValidationException');
$build->setSource(20);
}
public function testUserId()

View file

@ -137,8 +137,10 @@ class ProjectTest extends TestCase
$result = $project->setType('git');
self::assertEquals(false, $result);
}
self::expectException('\PHPCensor\Exception\HttpException\ValidationException');
$project->setType('invalid-type');
}
public function testAccessInformation()
{

View file

@ -2,6 +2,7 @@
namespace Tests\PHPCensor\Model;
use PHPCensor\Exception\HttpException\ValidationException;
use PHPCensor\Model\Project;
use PHPCensor\Model;
@ -16,6 +17,15 @@ class ProjectTest extends \PHPUnit\Framework\TestCase
{
$project = new Project();
self::assertTrue($project instanceof Model);
try {
$project->setArchived('true');
} catch (ValidationException $e) {
self::assertEquals(
'Column "archived" must be a boolean.',
$e->getMessage()
);
}
}
public function testExecute_TestGitDefaultBranch()