Added unit tests for base models.
This commit is contained in:
parent
fb11ba4652
commit
ad7670e81e
|
@ -67,10 +67,14 @@ class Model
|
|||
|
||||
/**
|
||||
* @param string $column
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
protected function setModified($column)
|
||||
{
|
||||
$this->modified[$column] = $column;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -50,6 +50,8 @@ class Build extends Model
|
|||
|
||||
/**
|
||||
* @param integer $value
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function setId($value)
|
||||
{
|
||||
|
@ -57,12 +59,12 @@ class Build extends Model
|
|||
$this->validateInt('id', $value);
|
||||
|
||||
if ($this->data['id'] === $value) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->data['id'] = (integer)$value;
|
||||
|
||||
$this->setModified('id');
|
||||
return $this->setModified('id');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -75,6 +77,8 @@ class Build extends Model
|
|||
|
||||
/**
|
||||
* @param integer $value
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function setProjectId($value)
|
||||
{
|
||||
|
@ -82,12 +86,12 @@ class Build extends Model
|
|||
$this->validateInt('project_id', $value);
|
||||
|
||||
if ($this->data['project_id'] === $value) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->data['project_id'] = $value;
|
||||
|
||||
$this->setModified('project_id');
|
||||
return $this->setModified('project_id');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -100,6 +104,8 @@ class Build extends Model
|
|||
|
||||
/**
|
||||
* @param string $value
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function setCommitId($value)
|
||||
{
|
||||
|
@ -107,12 +113,12 @@ class Build extends Model
|
|||
$this->validateString('commit_id', $value);
|
||||
|
||||
if ($this->data['commit_id'] === $value) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->data['commit_id'] = $value;
|
||||
|
||||
$this->setModified('commit_id');
|
||||
return $this->setModified('commit_id');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -125,6 +131,8 @@ class Build extends Model
|
|||
|
||||
/**
|
||||
* @param integer $value
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function setStatus($value)
|
||||
{
|
||||
|
@ -132,12 +140,12 @@ class Build extends Model
|
|||
$this->validateInt('status', $value);
|
||||
|
||||
if ($this->data['status'] === $value) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->data['status'] = $value;
|
||||
|
||||
$this->setModified('status');
|
||||
return $this->setModified('status');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -150,18 +158,20 @@ class Build extends Model
|
|||
|
||||
/**
|
||||
* @param string $value
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function setLog($value)
|
||||
{
|
||||
$this->validateString('log', $value);
|
||||
|
||||
if ($this->data['log'] === $value) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->data['log'] = $value;
|
||||
|
||||
$this->setModified('log');
|
||||
return $this->setModified('log');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -174,6 +184,8 @@ class Build extends Model
|
|||
|
||||
/**
|
||||
* @param string $value
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function setBranch($value)
|
||||
{
|
||||
|
@ -181,12 +193,12 @@ class Build extends Model
|
|||
$this->validateString('branch', $value);
|
||||
|
||||
if ($this->data['branch'] === $value) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->data['branch'] = $value;
|
||||
|
||||
$this->setModified('branch');
|
||||
return $this->setModified('branch');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -199,18 +211,20 @@ class Build extends Model
|
|||
|
||||
/**
|
||||
* @param string $value
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function setTag($value)
|
||||
{
|
||||
$this->validateString('tag', $value);
|
||||
|
||||
if ($this->data['tag'] === $value) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->data['tag'] = $value;
|
||||
|
||||
$this->setModified('tag');
|
||||
return $this->setModified('tag');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -227,18 +241,20 @@ class Build extends Model
|
|||
|
||||
/**
|
||||
* @param \DateTime $value
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function setCreateDate(\DateTime $value)
|
||||
{
|
||||
$stringValue = $value->format('Y-m-d H:i:s');
|
||||
|
||||
if ($this->data['create_date'] === $stringValue) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->data['create_date'] = $stringValue;
|
||||
|
||||
$this->setModified('create_date');
|
||||
return $this->setModified('create_date');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -255,18 +271,20 @@ class Build extends Model
|
|||
|
||||
/**
|
||||
* @param \DateTime $value
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function setStartDate(\DateTime $value)
|
||||
{
|
||||
$stringValue = $value->format('Y-m-d H:i:s');
|
||||
|
||||
if ($this->data['start_date'] === $stringValue) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->data['start_date'] = $stringValue;
|
||||
|
||||
$this->setModified('start_date');
|
||||
return $this->setModified('start_date');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -283,18 +301,20 @@ class Build extends Model
|
|||
|
||||
/**
|
||||
* @param \DateTime $value
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function setFinishDate(\DateTime $value)
|
||||
{
|
||||
$stringValue = $value->format('Y-m-d H:i:s');
|
||||
|
||||
if ($this->data['finish_date'] === $stringValue) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->data['finish_date'] = $stringValue;
|
||||
|
||||
$this->setModified('finish_date');
|
||||
return $this->setModified('finish_date');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -307,18 +327,20 @@ class Build extends Model
|
|||
|
||||
/**
|
||||
* @param string $value
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function setCommitterEmail($value)
|
||||
{
|
||||
$this->validateString('committer_email', $value);
|
||||
|
||||
if ($this->data['committer_email'] === $value) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->data['committer_email'] = $value;
|
||||
|
||||
$this->setModified('committer_email');
|
||||
return $this->setModified('committer_email');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -331,18 +353,20 @@ class Build extends Model
|
|||
|
||||
/**
|
||||
* @param string $value
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function setCommitMessage($value)
|
||||
{
|
||||
$this->validateString('commit_message', $value);
|
||||
|
||||
if ($this->data['commit_message'] === $value) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->data['commit_message'] = $value;
|
||||
|
||||
$this->setModified('commit_message');
|
||||
return $this->setModified('commit_message');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -365,6 +389,8 @@ class Build extends Model
|
|||
|
||||
/**
|
||||
* @param array $value
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function setExtra(array $value)
|
||||
{
|
||||
|
@ -372,12 +398,12 @@ class Build extends Model
|
|||
|
||||
$extra = json_encode($value);
|
||||
if ($this->data['extra'] === $extra) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->data['extra'] = $extra;
|
||||
|
||||
$this->setModified('extra');
|
||||
return $this->setModified('extra');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -390,18 +416,20 @@ class Build extends Model
|
|||
|
||||
/**
|
||||
* @param string $value
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function setEnvironment($value)
|
||||
{
|
||||
$this->validateString('environment', $value);
|
||||
|
||||
if ($this->data['environment'] === $value) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->data['environment'] = $value;
|
||||
|
||||
$this->setModified('environment');
|
||||
return $this->setModified('environment');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -414,18 +442,20 @@ class Build extends Model
|
|||
|
||||
/**
|
||||
* @param integer $value
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function setSource($value)
|
||||
{
|
||||
$this->validateInt('source', $value);
|
||||
|
||||
if ($this->data['source'] === $value) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->data['source'] = $value;
|
||||
|
||||
$this->setModified('source');
|
||||
return $this->setModified('source');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -438,6 +468,8 @@ class Build extends Model
|
|||
|
||||
/**
|
||||
* @param integer $value
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function setUserId($value)
|
||||
{
|
||||
|
@ -445,11 +477,11 @@ class Build extends Model
|
|||
$this->validateInt('user_id', $value);
|
||||
|
||||
if ($this->data['user_id'] === $value) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->data['user_id'] = $value;
|
||||
|
||||
$this->setModified('user_id');
|
||||
return $this->setModified('user_id');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,11 @@ use PHPCensor\Model;
|
|||
|
||||
class BuildError extends Model
|
||||
{
|
||||
const SEVERITY_CRITICAL = 0;
|
||||
const SEVERITY_HIGH = 1;
|
||||
const SEVERITY_NORMAL = 2;
|
||||
const SEVERITY_LOW = 3;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
|
@ -15,17 +20,17 @@ class BuildError extends Model
|
|||
* @var array
|
||||
*/
|
||||
protected $data = [
|
||||
'id' => null,
|
||||
'build_id' => null,
|
||||
'plugin' => null,
|
||||
'file' => null,
|
||||
'line_start' => null,
|
||||
'line_end' => null,
|
||||
'severity' => null,
|
||||
'message' => null,
|
||||
'create_date' => null,
|
||||
'hash' => null,
|
||||
'is_new' => null,
|
||||
'id' => null,
|
||||
'build_id' => null,
|
||||
'plugin' => null,
|
||||
'file' => null,
|
||||
'line_start' => null,
|
||||
'line_end' => null,
|
||||
'severity' => null,
|
||||
'message' => null,
|
||||
'create_date' => null,
|
||||
'hash' => null,
|
||||
'is_new' => null,
|
||||
];
|
||||
|
||||
/**
|
||||
|
@ -38,6 +43,8 @@ class BuildError extends Model
|
|||
|
||||
/**
|
||||
* @param integer $value
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function setId($value)
|
||||
{
|
||||
|
@ -45,12 +52,12 @@ class BuildError extends Model
|
|||
$this->validateInt('id', $value);
|
||||
|
||||
if ($this->data['id'] === $value) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->data['id'] = $value;
|
||||
|
||||
$this->setModified('id');
|
||||
return $this->setModified('id');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -63,6 +70,8 @@ class BuildError extends Model
|
|||
|
||||
/**
|
||||
* @param integer $value
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function setBuildId($value)
|
||||
{
|
||||
|
@ -70,12 +79,12 @@ class BuildError extends Model
|
|||
$this->validateInt('build_id', $value);
|
||||
|
||||
if ($this->data['build_id'] === $value) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->data['build_id'] = $value;
|
||||
|
||||
$this->setModified('build_id');
|
||||
return $this->setModified('build_id');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -88,6 +97,8 @@ class BuildError extends Model
|
|||
|
||||
/**
|
||||
* @param string $value
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function setPlugin($value)
|
||||
{
|
||||
|
@ -95,12 +106,12 @@ class BuildError extends Model
|
|||
$this->validateString('plugin', $value);
|
||||
|
||||
if ($this->data['plugin'] === $value) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->data['plugin'] = $value;
|
||||
|
||||
$this->setModified('plugin');
|
||||
return $this->setModified('plugin');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -113,18 +124,20 @@ class BuildError extends Model
|
|||
|
||||
/**
|
||||
* @param string $value
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function setFile($value)
|
||||
{
|
||||
$this->validateString('file', $value);
|
||||
|
||||
if ($this->data['file'] === $value) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->data['file'] = $value;
|
||||
|
||||
$this->setModified('file');
|
||||
return $this->setModified('file');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -137,18 +150,20 @@ class BuildError extends Model
|
|||
|
||||
/**
|
||||
* @param integer $value
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function setLineStart($value)
|
||||
{
|
||||
$this->validateInt('line_start', $value);
|
||||
|
||||
if ($this->data['line_start'] === $value) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->data['line_start'] = $value;
|
||||
|
||||
$this->setModified('line_start');
|
||||
return $this->setModified('line_start');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -161,18 +176,20 @@ class BuildError extends Model
|
|||
|
||||
/**
|
||||
* @param integer $value
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function setLineEnd($value)
|
||||
{
|
||||
$this->validateInt('line_end', $value);
|
||||
|
||||
if ($this->data['line_end'] === $value) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->data['line_end'] = $value;
|
||||
|
||||
$this->setModified('line_end');
|
||||
return $this->setModified('line_end');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -185,6 +202,8 @@ class BuildError extends Model
|
|||
|
||||
/**
|
||||
* @param integer $value
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function setSeverity($value)
|
||||
{
|
||||
|
@ -192,12 +211,12 @@ class BuildError extends Model
|
|||
$this->validateInt('severity', $value);
|
||||
|
||||
if ($this->data['severity'] === $value) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->data['severity'] = $value;
|
||||
|
||||
$this->setModified('severity');
|
||||
return $this->setModified('severity');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -210,6 +229,8 @@ class BuildError extends Model
|
|||
|
||||
/**
|
||||
* @param string $value
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function setMessage($value)
|
||||
{
|
||||
|
@ -217,12 +238,12 @@ class BuildError extends Model
|
|||
$this->validateString('message', $value);
|
||||
|
||||
if ($this->data['message'] === $value) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->data['message'] = $value;
|
||||
|
||||
$this->setModified('message');
|
||||
return $this->setModified('message');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -239,6 +260,8 @@ class BuildError extends Model
|
|||
|
||||
/**
|
||||
* @param \DateTime $value
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function setCreateDate(\DateTime $value)
|
||||
{
|
||||
|
@ -247,12 +270,12 @@ class BuildError extends Model
|
|||
$stringValue = $value->format('Y-m-d H:i:s');
|
||||
|
||||
if ($this->data['create_date'] === $stringValue) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->data['create_date'] = $stringValue;
|
||||
|
||||
$this->setModified('create_date');
|
||||
return $this->setModified('create_date');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -265,6 +288,8 @@ class BuildError extends Model
|
|||
|
||||
/**
|
||||
* @param string $value
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function setHash($value)
|
||||
{
|
||||
|
@ -272,12 +297,12 @@ class BuildError extends Model
|
|||
$this->validateString('hash', $value);
|
||||
|
||||
if ($this->data['hash'] === $value) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->data['hash'] = $value;
|
||||
|
||||
$this->setModified('hash');
|
||||
return $this->setModified('hash');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -290,18 +315,20 @@ class BuildError extends Model
|
|||
|
||||
/**
|
||||
* @param boolean $value
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function setIsNew($value)
|
||||
{
|
||||
$this->validateNotNull('is_new', $value);
|
||||
$this->validateBoolean('is_new', $value);
|
||||
|
||||
if ($this->data['is_new'] === $value) {
|
||||
return;
|
||||
if ($this->data['is_new'] === (integer)$value) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->data['is_new'] = (integer)$value;
|
||||
|
||||
$this->setModified('is_new');
|
||||
return $this->setModified('is_new');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,6 +31,8 @@ class BuildMeta extends Model
|
|||
|
||||
/**
|
||||
* @param integer $value
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function setId($value)
|
||||
{
|
||||
|
@ -38,12 +40,12 @@ class BuildMeta extends Model
|
|||
$this->validateInt('id', $value);
|
||||
|
||||
if ($this->data['id'] === $value) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->data['id'] = $value;
|
||||
|
||||
$this->setModified('id');
|
||||
return $this->setModified('id');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -56,6 +58,8 @@ class BuildMeta extends Model
|
|||
|
||||
/**
|
||||
* @param integer $value
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function setBuildId($value)
|
||||
{
|
||||
|
@ -63,12 +67,12 @@ class BuildMeta extends Model
|
|||
$this->validateInt('build_id', $value);
|
||||
|
||||
if ($this->data['build_id'] === $value) {
|
||||
return;
|
||||
return false ;
|
||||
}
|
||||
|
||||
$this->data['build_id'] = $value;
|
||||
|
||||
$this->setModified('build_id');
|
||||
return $this->setModified('build_id');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -81,6 +85,8 @@ class BuildMeta extends Model
|
|||
|
||||
/**
|
||||
* @param string $value
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function setMetaKey($value)
|
||||
{
|
||||
|
@ -88,12 +94,12 @@ class BuildMeta extends Model
|
|||
$this->validateString('meta_key', $value);
|
||||
|
||||
if ($this->data['meta_key'] === $value) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->data['meta_key'] = $value;
|
||||
|
||||
$this->setModified('meta_key');
|
||||
return $this->setModified('meta_key');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -106,6 +112,8 @@ class BuildMeta extends Model
|
|||
|
||||
/**
|
||||
* @param string $value
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function setMetaValue($value)
|
||||
{
|
||||
|
@ -113,11 +121,11 @@ class BuildMeta extends Model
|
|||
$this->validateString('meta_value', $value);
|
||||
|
||||
if ($this->data['meta_value'] === $value) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->data['meta_value'] = $value;
|
||||
|
||||
$this->setModified('meta_value');
|
||||
return $this->setModified('meta_value');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,6 +31,8 @@ class Environment extends Model
|
|||
|
||||
/**
|
||||
* @param integer $value
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function setId($value)
|
||||
{
|
||||
|
@ -38,12 +40,12 @@ class Environment extends Model
|
|||
$this->validateInt('id', $value);
|
||||
|
||||
if ($this->data['id'] === $value) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->data['id'] = $value;
|
||||
|
||||
$this->setModified('id');
|
||||
return $this->setModified('id');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -56,6 +58,8 @@ class Environment extends Model
|
|||
|
||||
/**
|
||||
* @param integer $value
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function setProjectId($value)
|
||||
{
|
||||
|
@ -63,12 +67,12 @@ class Environment extends Model
|
|||
$this->validateInt('project_id', $value);
|
||||
|
||||
if ($this->data['project_id'] === $value) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->data['project_id'] = $value;
|
||||
|
||||
$this->setModified('project_id');
|
||||
return $this->setModified('project_id');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -81,6 +85,8 @@ class Environment extends Model
|
|||
|
||||
/**
|
||||
* @param string $value
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function setName($value)
|
||||
{
|
||||
|
@ -88,12 +94,12 @@ class Environment extends Model
|
|||
$this->validateString('name', $value);
|
||||
|
||||
if ($this->data['name'] === $value) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->data['name'] = $value;
|
||||
|
||||
$this->setModified('name');
|
||||
return $this->setModified('name');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -111,6 +117,8 @@ class Environment extends Model
|
|||
|
||||
/**
|
||||
* @param array $value
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function setBranches(array $value)
|
||||
{
|
||||
|
@ -118,11 +126,11 @@ class Environment extends Model
|
|||
|
||||
$branches = implode("\n", $value);
|
||||
if ($this->data['branches'] === $branches) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->data['branches'] = $branches;
|
||||
|
||||
$this->setModified('branches');
|
||||
return $this->setModified('branches');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,6 +43,8 @@ class Project extends Model
|
|||
|
||||
/**
|
||||
* @param integer $value
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function setId($value)
|
||||
{
|
||||
|
@ -50,12 +52,12 @@ class Project extends Model
|
|||
$this->validateInt('id', $value);
|
||||
|
||||
if ($this->data['id'] === $value) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->data['id'] = $value;
|
||||
|
||||
$this->setModified('id');
|
||||
return $this->setModified('id');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -68,6 +70,8 @@ class Project extends Model
|
|||
|
||||
/**
|
||||
* @param string $value
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function setTitle($value)
|
||||
{
|
||||
|
@ -75,12 +79,12 @@ class Project extends Model
|
|||
$this->validateString('title', $value);
|
||||
|
||||
if ($this->data['title'] === $value) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->data['title'] = $value;
|
||||
|
||||
$this->setModified('title');
|
||||
return $this->setModified('title');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -93,6 +97,8 @@ class Project extends Model
|
|||
|
||||
/**
|
||||
* @param string $value
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function setReference($value)
|
||||
{
|
||||
|
@ -100,12 +106,12 @@ class Project extends Model
|
|||
$this->validateString('reference', $value);
|
||||
|
||||
if ($this->data['reference'] === $value) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->data['reference'] = $value;
|
||||
|
||||
$this->setModified('reference');
|
||||
return $this->setModified('reference');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -134,6 +140,8 @@ class Project extends Model
|
|||
|
||||
/**
|
||||
* @param string $value
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function setBranch($value)
|
||||
{
|
||||
|
@ -141,12 +149,12 @@ class Project extends Model
|
|||
$this->validateString('branch', $value);
|
||||
|
||||
if ($this->data['branch'] === $value) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->data['branch'] = $value;
|
||||
|
||||
$this->setModified('branch');
|
||||
return $this->setModified('branch');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -159,19 +167,21 @@ class Project extends Model
|
|||
|
||||
/**
|
||||
* @param boolean $value
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function setDefaultBranchOnly($value)
|
||||
{
|
||||
$this->validateNotNull('default_branch_only', $value);
|
||||
$this->validateBoolean('default_branch_only', $value);
|
||||
|
||||
if ($this->data['default_branch_only'] === $value) {
|
||||
return;
|
||||
if ($this->data['default_branch_only'] === (integer)$value) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->data['default_branch_only'] = (integer)$value;
|
||||
|
||||
$this->setModified('default_branch_only');
|
||||
return $this->setModified('default_branch_only');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -184,18 +194,20 @@ class Project extends Model
|
|||
|
||||
/**
|
||||
* @param string $value
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function setSshPrivateKey($value)
|
||||
{
|
||||
$this->validateString('ssh_private_key', $value);
|
||||
|
||||
if ($this->data['ssh_private_key'] === $value) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->data['ssh_private_key'] = $value;
|
||||
|
||||
$this->setModified('ssh_private_key');
|
||||
return $this->setModified('ssh_private_key');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -208,18 +220,20 @@ class Project extends Model
|
|||
|
||||
/**
|
||||
* @param string $value
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function setSshPublicKey($value)
|
||||
{
|
||||
$this->validateString('ssh_public_key', $value);
|
||||
|
||||
if ($this->data['ssh_public_key'] === $value) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->data['ssh_public_key'] = $value;
|
||||
|
||||
$this->setModified('ssh_public_key');
|
||||
return $this->setModified('ssh_public_key');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -232,6 +246,8 @@ class Project extends Model
|
|||
|
||||
/**
|
||||
* @param string $value
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function setType($value)
|
||||
{
|
||||
|
@ -239,12 +255,12 @@ class Project extends Model
|
|||
$this->validateString('type', $value);
|
||||
|
||||
if ($this->data['type'] === $value) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->data['type'] = $value;
|
||||
|
||||
$this->setModified('type');
|
||||
return $this->setModified('type');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -267,6 +283,8 @@ class Project extends Model
|
|||
|
||||
/**
|
||||
* @param array $value
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function setAccessInformation(array $value)
|
||||
{
|
||||
|
@ -274,12 +292,12 @@ class Project extends Model
|
|||
|
||||
$accessInformation = json_encode($value);
|
||||
if ($this->data['access_information'] === $accessInformation) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->data['access_information'] = $accessInformation;
|
||||
|
||||
$this->setModified('access_information');
|
||||
return $this->setModified('access_information');
|
||||
}
|
||||
|
||||
|
||||
|
@ -293,18 +311,20 @@ class Project extends Model
|
|||
|
||||
/**
|
||||
* @param string $value
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function setLastCommit($value)
|
||||
{
|
||||
$this->validateString('last_commit', $value);
|
||||
|
||||
if ($this->data['last_commit'] === $value) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->data['last_commit'] = $value;
|
||||
|
||||
$this->setModified('last_commit');
|
||||
return $this->setModified('last_commit');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -317,18 +337,20 @@ class Project extends Model
|
|||
|
||||
/**
|
||||
* @param string $value
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function setBuildConfig($value)
|
||||
{
|
||||
$this->validateString('build_config', $value);
|
||||
|
||||
if ($this->data['build_config'] === $value) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->data['build_config'] = $value;
|
||||
|
||||
$this->setModified('build_config');
|
||||
return $this->setModified('build_config');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -341,19 +363,21 @@ class Project extends Model
|
|||
|
||||
/**
|
||||
* @param boolean $value
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function setAllowPublicStatus($value)
|
||||
{
|
||||
$this->validateNotNull('allow_public_status', $value);
|
||||
$this->validateBoolean('allow_public_status', $value);
|
||||
|
||||
if ($this->data['allow_public_status'] === $value) {
|
||||
return;
|
||||
if ($this->data['allow_public_status'] === (integer)$value) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->data['allow_public_status'] = (integer)$value;
|
||||
|
||||
$this->setModified('allow_public_status');
|
||||
return $this->setModified('allow_public_status');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -366,19 +390,21 @@ class Project extends Model
|
|||
|
||||
/**
|
||||
* @param boolean $value
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function setArchived($value)
|
||||
{
|
||||
$this->validateNotNull('archived', $value);
|
||||
$this->validateBoolean('archived', $value);
|
||||
|
||||
if ($this->data['archived'] === $value) {
|
||||
return;
|
||||
if ($this->data['archived'] === (integer)$value) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->data['archived'] = (integer)$value;
|
||||
|
||||
$this->setModified('archived');
|
||||
return $this->setModified('archived');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -391,6 +417,8 @@ class Project extends Model
|
|||
|
||||
/**
|
||||
* @param integer $value
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function setGroupId($value)
|
||||
{
|
||||
|
@ -398,12 +426,12 @@ class Project extends Model
|
|||
$this->validateInt('group_id', $value);
|
||||
|
||||
if ($this->data['group_id'] === $value) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->data['group_id'] = $value;
|
||||
|
||||
$this->setModified('group_id');
|
||||
return $this->setModified('group_id');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -420,18 +448,20 @@ class Project extends Model
|
|||
|
||||
/**
|
||||
* @param \DateTime $value
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function setCreateDate(\DateTime $value)
|
||||
{
|
||||
$stringValue = $value->format('Y-m-d H:i:s');
|
||||
|
||||
if ($this->data['create_date'] === $stringValue) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->data['create_date'] = $stringValue;
|
||||
|
||||
$this->setModified('create_date');
|
||||
return $this->setModified('create_date');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -444,6 +474,8 @@ class Project extends Model
|
|||
|
||||
/**
|
||||
* @param integer $value
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function setUserId($value)
|
||||
{
|
||||
|
@ -451,11 +483,11 @@ class Project extends Model
|
|||
$this->validateInt('user_id', $value);
|
||||
|
||||
if ($this->data['user_id'] === $value) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->data['user_id'] = $value;
|
||||
|
||||
$this->setModified('user_id');
|
||||
return $this->setModified('user_id');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,6 +31,8 @@ class ProjectGroup extends Model
|
|||
|
||||
/**
|
||||
* @param integer $value
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function setId($value)
|
||||
{
|
||||
|
@ -38,12 +40,12 @@ class ProjectGroup extends Model
|
|||
$this->validateInt('id', $value);
|
||||
|
||||
if ($this->data['id'] === $value) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->data['id'] = $value;
|
||||
|
||||
$this->setModified('id');
|
||||
return $this->setModified('id');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -56,6 +58,8 @@ class ProjectGroup extends Model
|
|||
|
||||
/**
|
||||
* @param string $value
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function setTitle($value)
|
||||
{
|
||||
|
@ -63,12 +67,12 @@ class ProjectGroup extends Model
|
|||
$this->validateString('title', $value);
|
||||
|
||||
if ($this->data['title'] === $value) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->data['title'] = $value;
|
||||
|
||||
$this->setModified('title');
|
||||
return $this->setModified('title');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -85,18 +89,20 @@ class ProjectGroup extends Model
|
|||
|
||||
/**
|
||||
* @param \DateTime $value
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function setCreateDate(\DateTime $value)
|
||||
{
|
||||
$stringValue = $value->format('Y-m-d H:i:s');
|
||||
|
||||
if ($this->data['create_date'] === $stringValue) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->data['create_date'] = $stringValue;
|
||||
|
||||
$this->setModified('create_date');
|
||||
return $this->setModified('create_date');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -109,6 +115,8 @@ class ProjectGroup extends Model
|
|||
|
||||
/**
|
||||
* @param integer $value
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function setUserId($value)
|
||||
{
|
||||
|
@ -116,11 +124,11 @@ class ProjectGroup extends Model
|
|||
$this->validateInt('user_id', $value);
|
||||
|
||||
if ($this->data['user_id'] === $value) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->data['user_id'] = $value;
|
||||
|
||||
$this->setModified('user_id');
|
||||
return $this->setModified('user_id');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,6 +37,8 @@ class User extends Model
|
|||
|
||||
/**
|
||||
* @param integer $value
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function setId($value)
|
||||
{
|
||||
|
@ -44,12 +46,12 @@ class User extends Model
|
|||
$this->validateInt('id', $value);
|
||||
|
||||
if ($this->data['id'] === $value) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->data['id'] = $value;
|
||||
|
||||
$this->setModified('id');
|
||||
return $this->setModified('id');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -62,6 +64,8 @@ class User extends Model
|
|||
|
||||
/**
|
||||
* @param string $value
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function setEmail($value)
|
||||
{
|
||||
|
@ -69,12 +73,12 @@ class User extends Model
|
|||
$this->validateString('email', $value);
|
||||
|
||||
if ($this->data['email'] === $value) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->data['email'] = $value;
|
||||
|
||||
$this->setModified('email');
|
||||
return $this->setModified('email');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -87,6 +91,8 @@ class User extends Model
|
|||
|
||||
/**
|
||||
* @param string $value
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function setHash($value)
|
||||
{
|
||||
|
@ -94,12 +100,12 @@ class User extends Model
|
|||
$this->validateString('hash', $value);
|
||||
|
||||
if ($this->data['hash'] === $value) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->data['hash'] = $value;
|
||||
|
||||
$this->setModified('hash');
|
||||
return $this->setModified('hash');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -112,19 +118,21 @@ class User extends Model
|
|||
|
||||
/**
|
||||
* @param boolean $value
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function setIsAdmin($value)
|
||||
{
|
||||
$this->validateNotNull('is_admin', $value);
|
||||
$this->validateBoolean('is_admin', $value);
|
||||
|
||||
if ($this->data['is_admin'] === $value) {
|
||||
return;
|
||||
if ($this->data['is_admin'] === (integer)$value) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->data['is_admin'] = (integer)$value;
|
||||
|
||||
$this->setModified('is_admin');
|
||||
return $this->setModified('is_admin');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -137,6 +145,8 @@ class User extends Model
|
|||
|
||||
/**
|
||||
* @param string $value
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function setName($value)
|
||||
{
|
||||
|
@ -144,12 +154,12 @@ class User extends Model
|
|||
$this->validateString('name', $value);
|
||||
|
||||
if ($this->data['name'] === $value) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->data['name'] = $value;
|
||||
|
||||
$this->setModified('name');
|
||||
return $this->setModified('name');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -162,16 +172,18 @@ class User extends Model
|
|||
|
||||
/**
|
||||
* @param string $value
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function setLanguage($value)
|
||||
{
|
||||
if ($this->data['language'] === $value) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->data['language'] = $value;
|
||||
|
||||
$this->setModified('language');
|
||||
return $this->setModified('language');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -184,18 +196,20 @@ class User extends Model
|
|||
|
||||
/**
|
||||
* @param integer $value
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function setPerPage($value)
|
||||
{
|
||||
$this->validateInt('per_page', $value);
|
||||
|
||||
if ($this->data['per_page'] === $value) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->data['per_page'] = $value;
|
||||
|
||||
$this->setModified('per_page');
|
||||
return $this->setModified('per_page');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -208,6 +222,8 @@ class User extends Model
|
|||
|
||||
/**
|
||||
* @param string $value
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function setProviderKey($value)
|
||||
{
|
||||
|
@ -215,12 +231,12 @@ class User extends Model
|
|||
$this->validateString('provider_key', $value);
|
||||
|
||||
if ($this->data['provider_key'] === $value) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->data['provider_key'] = $value;
|
||||
|
||||
$this->setModified('provider_key');
|
||||
return $this->setModified('provider_key');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -230,7 +246,7 @@ class User extends Model
|
|||
*/
|
||||
public function getProviderData($key = null)
|
||||
{
|
||||
$data = json_decode($this->data['provider_data'], true);
|
||||
$data = json_decode($this->data['provider_data'], true);
|
||||
$providerData = null;
|
||||
if (is_null($key)) {
|
||||
$providerData = $data;
|
||||
|
@ -243,6 +259,8 @@ class User extends Model
|
|||
|
||||
/**
|
||||
* @param array $value
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function setProviderData(array $value)
|
||||
{
|
||||
|
@ -250,12 +268,12 @@ class User extends Model
|
|||
|
||||
$providerData = json_encode($value);
|
||||
if ($this->data['provider_data'] === $providerData) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->data['provider_data'] = $providerData;
|
||||
|
||||
$this->setModified('provider_data');
|
||||
return $this->setModified('provider_data');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -268,17 +286,19 @@ class User extends Model
|
|||
|
||||
/**
|
||||
* @param string $value
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function setRememberKey($value)
|
||||
{
|
||||
$this->validateString('remember_key', $value);
|
||||
|
||||
if ($this->data['remember_key'] === $value) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->data['remember_key'] = $value;
|
||||
|
||||
$this->setModified('remember_key');
|
||||
return $this->setModified('remember_key');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,11 +8,6 @@ use PHPCensor\Store\Factory;
|
|||
|
||||
class BuildError extends BaseBuildError
|
||||
{
|
||||
const SEVERITY_CRITICAL = 0;
|
||||
const SEVERITY_HIGH = 1;
|
||||
const SEVERITY_NORMAL = 2;
|
||||
const SEVERITY_LOW = 3;
|
||||
|
||||
/**
|
||||
* @return Build|null
|
||||
*/
|
||||
|
|
167
tests/src/Model/Base/BuildErrorTest.php
Normal file
167
tests/src/Model/Base/BuildErrorTest.php
Normal file
|
@ -0,0 +1,167 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\PHPCensor\Model\Base;
|
||||
|
||||
use PHPCensor\Model\Base\BuildError;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class BuildErrorTest extends TestCase
|
||||
{
|
||||
public function testConstruct()
|
||||
{
|
||||
$buildError = new BuildError();
|
||||
|
||||
self::assertInstanceOf('PHPCensor\Model', $buildError);
|
||||
self::assertInstanceOf('PHPCensor\Model\Base\BuildError', $buildError);
|
||||
|
||||
self::assertEquals([
|
||||
'id' => null,
|
||||
'build_id' => null,
|
||||
'plugin' => null,
|
||||
'file' => null,
|
||||
'line_start' => null,
|
||||
'line_end' => null,
|
||||
'severity' => null,
|
||||
'message' => null,
|
||||
'create_date' => null,
|
||||
'hash' => null,
|
||||
'is_new' => null,
|
||||
], $buildError->getDataArray());
|
||||
}
|
||||
|
||||
public function testId()
|
||||
{
|
||||
$buildError = new BuildError();
|
||||
|
||||
$result = $buildError->setId(100);
|
||||
self::assertEquals(true, $result);
|
||||
self::assertEquals(100, $buildError->getId());
|
||||
|
||||
$result = $buildError->setId(100);
|
||||
self::assertEquals(false, $result);
|
||||
}
|
||||
|
||||
public function testBuildId()
|
||||
{
|
||||
$buildError = new BuildError();
|
||||
|
||||
$result = $buildError->setBuildId(200);
|
||||
self::assertEquals(true, $result);
|
||||
self::assertEquals(200, $buildError->getBuildId());
|
||||
|
||||
$result = $buildError->setBuildId(200);
|
||||
self::assertEquals(false, $result);
|
||||
}
|
||||
|
||||
public function testPlugin()
|
||||
{
|
||||
$buildError = new BuildError();
|
||||
|
||||
$result = $buildError->setPlugin('plugin');
|
||||
self::assertEquals(true, $result);
|
||||
self::assertEquals('plugin', $buildError->getPlugin());
|
||||
|
||||
$result = $buildError->setPlugin('plugin');
|
||||
self::assertEquals(false, $result);
|
||||
}
|
||||
|
||||
public function testFile()
|
||||
{
|
||||
$buildError = new BuildError();
|
||||
|
||||
$result = $buildError->setFile('file.php');
|
||||
self::assertEquals(true, $result);
|
||||
self::assertEquals('file.php', $buildError->getFile());
|
||||
|
||||
$result = $buildError->setFile('file.php');
|
||||
self::assertEquals(false, $result);
|
||||
}
|
||||
|
||||
public function testLineStart()
|
||||
{
|
||||
$buildError = new BuildError();
|
||||
|
||||
$result = $buildError->setLineStart(5);
|
||||
self::assertEquals(true, $result);
|
||||
self::assertEquals(5, $buildError->getLineStart());
|
||||
|
||||
$result = $buildError->setLineStart(5);
|
||||
self::assertEquals(false, $result);
|
||||
}
|
||||
|
||||
public function testLineEnd()
|
||||
{
|
||||
$buildError = new BuildError();
|
||||
|
||||
$result = $buildError->setLineEnd(10);
|
||||
self::assertEquals(true, $result);
|
||||
self::assertEquals(10, $buildError->getLineEnd());
|
||||
|
||||
$result = $buildError->setLineEnd(10);
|
||||
self::assertEquals(false, $result);
|
||||
}
|
||||
|
||||
public function testSeverity()
|
||||
{
|
||||
$buildError = new BuildError();
|
||||
|
||||
$result = $buildError->setSeverity(BuildError::SEVERITY_CRITICAL);
|
||||
self::assertEquals(true, $result);
|
||||
self::assertEquals(BuildError::SEVERITY_CRITICAL, $buildError->getSeverity());
|
||||
|
||||
$result = $buildError->setSeverity(BuildError::SEVERITY_CRITICAL);
|
||||
self::assertEquals(false, $result);
|
||||
}
|
||||
|
||||
public function testMessage()
|
||||
{
|
||||
$buildError = new BuildError();
|
||||
|
||||
$result = $buildError->setMessage('message');
|
||||
self::assertEquals(true, $result);
|
||||
self::assertEquals('message', $buildError->getMessage());
|
||||
|
||||
$result = $buildError->setMessage('message');
|
||||
self::assertEquals(false, $result);
|
||||
}
|
||||
|
||||
public function testCreateDate()
|
||||
{
|
||||
$buildError = new BuildError();
|
||||
self::assertEquals(null, $buildError->getCreateDate());
|
||||
|
||||
$buildError = new BuildError();
|
||||
$createDate = new \DateTime();
|
||||
|
||||
$result = $buildError->setCreateDate($createDate);
|
||||
self::assertEquals(true, $result);
|
||||
self::assertEquals($createDate->getTimestamp(), $buildError->getCreateDate()->getTimestamp());
|
||||
|
||||
$result = $buildError->setCreateDate($createDate);
|
||||
self::assertEquals(false, $result);
|
||||
}
|
||||
|
||||
public function testHash()
|
||||
{
|
||||
$buildError = new BuildError();
|
||||
|
||||
$result = $buildError->setHash('hash');
|
||||
self::assertEquals(true, $result);
|
||||
self::assertEquals('hash', $buildError->getHash());
|
||||
|
||||
$result = $buildError->setHash('hash');
|
||||
self::assertEquals(false, $result);
|
||||
}
|
||||
|
||||
public function testIsNew()
|
||||
{
|
||||
$buildError = new BuildError();
|
||||
|
||||
$result = $buildError->setIsNew(true);
|
||||
self::assertEquals(true, $result);
|
||||
self::assertEquals(true, $buildError->getIsNew());
|
||||
|
||||
$result = $buildError->setIsNew(true);
|
||||
self::assertEquals(false, $result);
|
||||
}
|
||||
}
|
72
tests/src/Model/Base/BuildMetaTest.php
Normal file
72
tests/src/Model/Base/BuildMetaTest.php
Normal file
|
@ -0,0 +1,72 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\PHPCensor\Model\Base;
|
||||
|
||||
use PHPCensor\Model\Base\BuildMeta;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class BuildMetaTest extends TestCase
|
||||
{
|
||||
public function testConstruct()
|
||||
{
|
||||
$buildMeta = new BuildMeta();
|
||||
|
||||
self::assertInstanceOf('PHPCensor\Model', $buildMeta);
|
||||
self::assertInstanceOf('PHPCensor\Model\Base\BuildMeta', $buildMeta);
|
||||
|
||||
self::assertEquals([
|
||||
'id' => null,
|
||||
'build_id' => null,
|
||||
'meta_key' => null,
|
||||
'meta_value' => null,
|
||||
], $buildMeta->getDataArray());
|
||||
}
|
||||
|
||||
public function testId()
|
||||
{
|
||||
$buildMeta = new BuildMeta();
|
||||
|
||||
$result = $buildMeta->setId(100);
|
||||
self::assertEquals(true, $result);
|
||||
self::assertEquals(100, $buildMeta->getId());
|
||||
|
||||
$result = $buildMeta->setId(100);
|
||||
self::assertEquals(false, $result);
|
||||
}
|
||||
|
||||
public function testBuildId()
|
||||
{
|
||||
$buildMeta = new BuildMeta();
|
||||
|
||||
$result = $buildMeta->setBuildId(200);
|
||||
self::assertEquals(true, $result);
|
||||
self::assertEquals(200, $buildMeta->getBuildId());
|
||||
|
||||
$result = $buildMeta->setBuildId(200);
|
||||
self::assertEquals(false, $result);
|
||||
}
|
||||
|
||||
public function testMetaKey()
|
||||
{
|
||||
$buildMeta = new BuildMeta();
|
||||
|
||||
$result = $buildMeta->setMetaKey('key');
|
||||
self::assertEquals(true, $result);
|
||||
self::assertEquals('key', $buildMeta->getMetaKey());
|
||||
|
||||
$result = $buildMeta->setMetaKey('key');
|
||||
self::assertEquals(false, $result);
|
||||
}
|
||||
|
||||
public function testMetaValue()
|
||||
{
|
||||
$buildMeta = new BuildMeta();
|
||||
|
||||
$result = $buildMeta->setMetaValue('value');
|
||||
self::assertEquals(true, $result);
|
||||
self::assertEquals('value', $buildMeta->getMetaValue());
|
||||
|
||||
$result = $buildMeta->setMetaValue('value');
|
||||
self::assertEquals(false, $result);
|
||||
}
|
||||
}
|
242
tests/src/Model/Base/BuildTest.php
Normal file
242
tests/src/Model/Base/BuildTest.php
Normal file
|
@ -0,0 +1,242 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\PHPCensor\Model\Base;
|
||||
|
||||
use PHPCensor\Model\Base\Build;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class BuildTest extends TestCase
|
||||
{
|
||||
public function testConstruct()
|
||||
{
|
||||
$build = new Build();
|
||||
|
||||
self::assertInstanceOf('PHPCensor\Model', $build);
|
||||
self::assertInstanceOf('PHPCensor\Model\Base\Build', $build);
|
||||
|
||||
self::assertEquals([
|
||||
'id' => null,
|
||||
'project_id' => null,
|
||||
'commit_id' => null,
|
||||
'status' => null,
|
||||
'log' => null,
|
||||
'branch' => null,
|
||||
'tag' => null,
|
||||
'create_date' => null,
|
||||
'start_date' => null,
|
||||
'finish_date' => null,
|
||||
'committer_email' => null,
|
||||
'commit_message' => null,
|
||||
'extra' => null,
|
||||
'environment' => null,
|
||||
'source' => Build::SOURCE_UNKNOWN,
|
||||
'user_id' => 0,
|
||||
], $build->getDataArray());
|
||||
}
|
||||
|
||||
public function testId()
|
||||
{
|
||||
$build = new Build();
|
||||
|
||||
$result = $build->setId(100);
|
||||
self::assertEquals(true, $result);
|
||||
self::assertEquals(100, $build->getId());
|
||||
|
||||
$result = $build->setId(100);
|
||||
self::assertEquals(false, $result);
|
||||
}
|
||||
|
||||
public function testProjectId()
|
||||
{
|
||||
$build = new Build();
|
||||
|
||||
$result = $build->setProjectId(200);
|
||||
self::assertEquals(true, $result);
|
||||
self::assertEquals(200, $build->getProjectId());
|
||||
|
||||
$result = $build->setProjectId(200);
|
||||
self::assertEquals(false, $result);
|
||||
}
|
||||
|
||||
public function testCommitId()
|
||||
{
|
||||
$build = new Build();
|
||||
|
||||
$result = $build->setCommitId('commit');
|
||||
self::assertEquals(true, $result);
|
||||
self::assertEquals('commit', $build->getCommitId());
|
||||
|
||||
$result = $build->setCommitId('commit');
|
||||
self::assertEquals(false, $result);
|
||||
}
|
||||
|
||||
public function testStatus()
|
||||
{
|
||||
$build = new Build();
|
||||
|
||||
$result = $build->setStatus(Build::STATUS_FAILED);
|
||||
self::assertEquals(true, $result);
|
||||
self::assertEquals(Build::STATUS_FAILED, $build->getStatus());
|
||||
|
||||
$result = $build->setStatus(Build::STATUS_FAILED);
|
||||
self::assertEquals(false, $result);
|
||||
}
|
||||
|
||||
public function testLog()
|
||||
{
|
||||
$build = new Build();
|
||||
|
||||
$result = $build->setLog('log');
|
||||
self::assertEquals(true, $result);
|
||||
self::assertEquals('log', $build->getLog());
|
||||
|
||||
$result = $build->setLog('log');
|
||||
self::assertEquals(false, $result);
|
||||
}
|
||||
|
||||
public function testBranch()
|
||||
{
|
||||
$build = new Build();
|
||||
|
||||
$result = $build->setBranch('branch');
|
||||
self::assertEquals(true, $result);
|
||||
self::assertEquals('branch', $build->getBranch());
|
||||
|
||||
$result = $build->setBranch('branch');
|
||||
self::assertEquals(false, $result);
|
||||
}
|
||||
|
||||
public function testTag()
|
||||
{
|
||||
$build = new Build();
|
||||
|
||||
$result = $build->setTag('tag');
|
||||
self::assertEquals(true, $result);
|
||||
self::assertEquals('tag', $build->getTag());
|
||||
|
||||
$result = $build->setTag('tag');
|
||||
self::assertEquals(false, $result);
|
||||
}
|
||||
|
||||
public function testCreateDate()
|
||||
{
|
||||
$build = new Build();
|
||||
self::assertEquals(null, $build->getCreateDate());
|
||||
|
||||
$build = new Build();
|
||||
$createDate = new \DateTime();
|
||||
|
||||
$result = $build->setCreateDate($createDate);
|
||||
self::assertEquals(true, $result);
|
||||
self::assertEquals($createDate->getTimestamp(), $build->getCreateDate()->getTimestamp());
|
||||
|
||||
$result = $build->setCreateDate($createDate);
|
||||
self::assertEquals(false, $result);
|
||||
}
|
||||
|
||||
public function testStartDate()
|
||||
{
|
||||
$build = new Build();
|
||||
self::assertEquals(null, $build->getStartDate());
|
||||
|
||||
$build = new Build();
|
||||
$createDate = new \DateTime();
|
||||
|
||||
$result = $build->setStartDate($createDate);
|
||||
self::assertEquals(true, $result);
|
||||
self::assertEquals($createDate->getTimestamp(), $build->getStartDate()->getTimestamp());
|
||||
|
||||
$result = $build->setStartDate($createDate);
|
||||
self::assertEquals(false, $result);
|
||||
}
|
||||
|
||||
public function testFinishDate()
|
||||
{
|
||||
$build = new Build();
|
||||
self::assertEquals(null, $build->getFinishDate());
|
||||
|
||||
$build = new Build();
|
||||
$createDate = new \DateTime();
|
||||
|
||||
$result = $build->setFinishDate($createDate);
|
||||
self::assertEquals(true, $result);
|
||||
self::assertEquals($createDate->getTimestamp(), $build->getFinishDate()->getTimestamp());
|
||||
|
||||
$result = $build->setFinishDate($createDate);
|
||||
self::assertEquals(false, $result);
|
||||
}
|
||||
|
||||
public function testCommitterEmail()
|
||||
{
|
||||
$build = new Build();
|
||||
|
||||
$result = $build->setCommitterEmail('email@email.com');
|
||||
self::assertEquals(true, $result);
|
||||
self::assertEquals('email@email.com', $build->getCommitterEmail());
|
||||
|
||||
$result = $build->setCommitterEmail('email@email.com');
|
||||
self::assertEquals(false, $result);
|
||||
}
|
||||
|
||||
public function testCommitMessage()
|
||||
{
|
||||
$build = new Build();
|
||||
|
||||
$result = $build->setCommitMessage('message');
|
||||
self::assertEquals(true, $result);
|
||||
self::assertEquals('message', $build->getCommitMessage());
|
||||
|
||||
$result = $build->setCommitMessage('message');
|
||||
self::assertEquals(false, $result);
|
||||
}
|
||||
|
||||
public function testExtra()
|
||||
{
|
||||
$build = new Build();
|
||||
|
||||
$result = $build->setExtra(['key-1' => 'value-1', 'key-2' => 'value-2']);
|
||||
self::assertEquals(true, $result);
|
||||
self::assertEquals(['key-1' => 'value-1', 'key-2' => 'value-2'], $build->getExtra());
|
||||
self::assertEquals('value-1', $build->getExtra('key-1'));
|
||||
self::assertEquals(null, $build->getExtra('key-3'));
|
||||
|
||||
$result = $build->setExtra(['key-1' => 'value-1', 'key-2' => 'value-2']);
|
||||
self::assertEquals(false, $result);
|
||||
}
|
||||
|
||||
public function testEnvironment()
|
||||
{
|
||||
$build = new Build();
|
||||
|
||||
$result = $build->setEnvironment('environment');
|
||||
self::assertEquals(true, $result);
|
||||
self::assertEquals('environment', $build->getEnvironment());
|
||||
|
||||
$result = $build->setEnvironment('environment');
|
||||
self::assertEquals(false, $result);
|
||||
}
|
||||
|
||||
public function testSource()
|
||||
{
|
||||
$build = new Build();
|
||||
|
||||
$result = $build->setSource(Build::SOURCE_WEBHOOK_PULL_REQUEST);
|
||||
self::assertEquals(true, $result);
|
||||
self::assertEquals(Build::SOURCE_WEBHOOK_PULL_REQUEST, $build->getSource());
|
||||
|
||||
$result = $build->setSource(Build::SOURCE_WEBHOOK_PULL_REQUEST);
|
||||
self::assertEquals(false, $result);
|
||||
}
|
||||
|
||||
public function testUserId()
|
||||
{
|
||||
$build = new Build();
|
||||
|
||||
$result = $build->setUserId(300);
|
||||
self::assertEquals(true, $result);
|
||||
self::assertEquals(300, $build->getUserId());
|
||||
|
||||
$result = $build->setUserId(300);
|
||||
self::assertEquals(false, $result);
|
||||
}
|
||||
}
|
72
tests/src/Model/Base/EnvironmentTest.php
Normal file
72
tests/src/Model/Base/EnvironmentTest.php
Normal file
|
@ -0,0 +1,72 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\PHPCensor\Model\Base;
|
||||
|
||||
use PHPCensor\Model\Base\Environment;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class EnvironmentTest extends TestCase
|
||||
{
|
||||
public function testConstruct()
|
||||
{
|
||||
$environment = new Environment();
|
||||
|
||||
self::assertInstanceOf('PHPCensor\Model', $environment);
|
||||
self::assertInstanceOf('PHPCensor\Model\Base\Environment', $environment);
|
||||
|
||||
self::assertEquals([
|
||||
'id' => null,
|
||||
'project_id' => null,
|
||||
'name' => null,
|
||||
'branches' => null,
|
||||
], $environment->getDataArray());
|
||||
}
|
||||
|
||||
public function testId()
|
||||
{
|
||||
$environment = new Environment();
|
||||
|
||||
$result = $environment->setId(100);
|
||||
self::assertEquals(true, $result);
|
||||
self::assertEquals(100, $environment->getId());
|
||||
|
||||
$result = $environment->setId(100);
|
||||
self::assertEquals(false, $result);
|
||||
}
|
||||
|
||||
public function testProjectId()
|
||||
{
|
||||
$environment = new Environment();
|
||||
|
||||
$result = $environment->setProjectId(200);
|
||||
self::assertEquals(true, $result);
|
||||
self::assertEquals(200, $environment->getProjectId());
|
||||
|
||||
$result = $environment->setProjectId(200);
|
||||
self::assertEquals(false, $result);
|
||||
}
|
||||
|
||||
public function testName()
|
||||
{
|
||||
$environment = new Environment();
|
||||
|
||||
$result = $environment->setName('name');
|
||||
self::assertEquals(true, $result);
|
||||
self::assertEquals('name', $environment->getName());
|
||||
|
||||
$result = $environment->setName('name');
|
||||
self::assertEquals(false, $result);
|
||||
}
|
||||
|
||||
public function testBranches()
|
||||
{
|
||||
$environment = new Environment();
|
||||
|
||||
$result = $environment->setBranches(['branch-1', 'branch-2']);
|
||||
self::assertEquals(true, $result);
|
||||
self::assertEquals(['branch-1', 'branch-2'], $environment->getBranches());
|
||||
|
||||
$result = $environment->setBranches(['branch-1', 'branch-2']);
|
||||
self::assertEquals(false, $result);
|
||||
}
|
||||
}
|
76
tests/src/Model/Base/ProjectGroupTest.php
Normal file
76
tests/src/Model/Base/ProjectGroupTest.php
Normal file
|
@ -0,0 +1,76 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\PHPCensor\Model\Base;
|
||||
|
||||
use PHPCensor\Model\Base\ProjectGroup;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ProjectGroupTest extends TestCase
|
||||
{
|
||||
public function testConstruct()
|
||||
{
|
||||
$projectGroup = new ProjectGroup();
|
||||
|
||||
self::assertInstanceOf('PHPCensor\Model', $projectGroup);
|
||||
self::assertInstanceOf('PHPCensor\Model\Base\ProjectGroup', $projectGroup);
|
||||
|
||||
self::assertEquals([
|
||||
'id' => null,
|
||||
'title' => null,
|
||||
'create_date' => null,
|
||||
'user_id' => 0,
|
||||
], $projectGroup->getDataArray());
|
||||
}
|
||||
|
||||
public function testId()
|
||||
{
|
||||
$projectGroup = new ProjectGroup();
|
||||
|
||||
$result = $projectGroup->setId(100);
|
||||
self::assertEquals(true, $result);
|
||||
self::assertEquals(100, $projectGroup->getId());
|
||||
|
||||
$result = $projectGroup->setId(100);
|
||||
self::assertEquals(false, $result);
|
||||
}
|
||||
|
||||
public function testTitle()
|
||||
{
|
||||
$projectGroup = new ProjectGroup();
|
||||
|
||||
$result = $projectGroup->setTitle('title');
|
||||
self::assertEquals(true, $result);
|
||||
self::assertEquals('title', $projectGroup->getTitle());
|
||||
|
||||
$result = $projectGroup->setTitle('title');
|
||||
self::assertEquals(false, $result);
|
||||
}
|
||||
|
||||
public function testCreateDate()
|
||||
{
|
||||
$projectGroup = new ProjectGroup();
|
||||
self::assertEquals(null, $projectGroup->getCreateDate());
|
||||
|
||||
$projectGroup = new ProjectGroup();
|
||||
$createDate = new \DateTime();
|
||||
|
||||
$result = $projectGroup->setCreateDate($createDate);
|
||||
self::assertEquals(true, $result);
|
||||
self::assertEquals($createDate->getTimestamp(), $projectGroup->getCreateDate()->getTimestamp());
|
||||
|
||||
$result = $projectGroup->setCreateDate($createDate);
|
||||
self::assertEquals(false, $result);
|
||||
}
|
||||
|
||||
public function testUserId()
|
||||
{
|
||||
$projectGroup = new ProjectGroup();
|
||||
|
||||
$result = $projectGroup->setUserId(200);
|
||||
self::assertEquals(true, $result);
|
||||
self::assertEquals(200, $projectGroup->getUserId());
|
||||
|
||||
$result = $projectGroup->setUserId(200);
|
||||
self::assertEquals(false, $result);
|
||||
}
|
||||
}
|
245
tests/src/Model/Base/ProjectTest.php
Normal file
245
tests/src/Model/Base/ProjectTest.php
Normal file
|
@ -0,0 +1,245 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\PHPCensor\Model\Base;
|
||||
|
||||
use PHPCensor\Model\Base\Project;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ProjectTest extends TestCase
|
||||
{
|
||||
public function testConstruct()
|
||||
{
|
||||
$project = new Project();
|
||||
|
||||
self::assertInstanceOf('PHPCensor\Model', $project);
|
||||
self::assertInstanceOf('PHPCensor\Model\Base\Project', $project);
|
||||
|
||||
self::assertEquals([
|
||||
'id' => null,
|
||||
'title' => null,
|
||||
'reference' => null,
|
||||
'branch' => null,
|
||||
'default_branch_only' => null,
|
||||
'ssh_private_key' => null,
|
||||
'ssh_public_key' => null,
|
||||
'type' => null,
|
||||
'access_information' => null,
|
||||
'last_commit' => null,
|
||||
'build_config' => null,
|
||||
'allow_public_status' => null,
|
||||
'archived' => null,
|
||||
'group_id' => null,
|
||||
'create_date' => null,
|
||||
'user_id' => 0,
|
||||
], $project->getDataArray());
|
||||
}
|
||||
|
||||
public function testId()
|
||||
{
|
||||
$project = new Project();
|
||||
|
||||
$result = $project->setId(100);
|
||||
self::assertEquals(true, $result);
|
||||
self::assertEquals(100, $project->getId());
|
||||
|
||||
$result = $project->setId(100);
|
||||
self::assertEquals(false, $result);
|
||||
}
|
||||
|
||||
public function testTitle()
|
||||
{
|
||||
$project = new Project();
|
||||
|
||||
$result = $project->setTitle('title');
|
||||
self::assertEquals(true, $result);
|
||||
self::assertEquals('title', $project->getTitle());
|
||||
|
||||
$result = $project->setTitle('title');
|
||||
self::assertEquals(false, $result);
|
||||
}
|
||||
|
||||
public function testReference()
|
||||
{
|
||||
$project = new Project();
|
||||
|
||||
$result = $project->setReference('git://reference');
|
||||
self::assertEquals(true, $result);
|
||||
self::assertEquals('git://reference', $project->getReference());
|
||||
|
||||
$result = $project->setReference('git://reference');
|
||||
self::assertEquals(false, $result);
|
||||
}
|
||||
|
||||
public function testBranch()
|
||||
{
|
||||
$project = new Project();
|
||||
|
||||
self::assertEquals('master', $project->getBranch());
|
||||
|
||||
$project->setType('hg');
|
||||
self::assertEquals('default', $project->getBranch());
|
||||
|
||||
$project->setType('svn');
|
||||
self::assertEquals('trunk', $project->getBranch());
|
||||
|
||||
$project = new Project();
|
||||
|
||||
$result = $project->setBranch('branch');
|
||||
self::assertEquals(true, $result);
|
||||
self::assertEquals('branch', $project->getBranch());
|
||||
|
||||
$result = $project->setBranch('branch');
|
||||
self::assertEquals(false, $result);
|
||||
}
|
||||
|
||||
public function testDefaultBranchOnly()
|
||||
{
|
||||
$project = new Project();
|
||||
|
||||
$result = $project->setDefaultBranchOnly(true);
|
||||
self::assertEquals(true, $result);
|
||||
self::assertEquals(true, $project->getDefaultBranchOnly());
|
||||
|
||||
$result = $project->setDefaultBranchOnly(true);
|
||||
self::assertEquals(false, $result);
|
||||
}
|
||||
|
||||
public function testSshPrivateKey()
|
||||
{
|
||||
$project = new Project();
|
||||
|
||||
$result = $project->setSshPrivateKey('private-key');
|
||||
self::assertEquals(true, $result);
|
||||
self::assertEquals('private-key', $project->getSshPrivateKey());
|
||||
|
||||
$result = $project->setSshPrivateKey('private-key');
|
||||
self::assertEquals(false, $result);
|
||||
}
|
||||
|
||||
public function testSshPublicKey()
|
||||
{
|
||||
$project = new Project();
|
||||
|
||||
$result = $project->setSshPublicKey('public-key');
|
||||
self::assertEquals(true, $result);
|
||||
self::assertEquals('public-key', $project->getSshPublicKey());
|
||||
|
||||
$result = $project->setSshPublicKey('public-key');
|
||||
self::assertEquals(false, $result);
|
||||
}
|
||||
|
||||
public function testType()
|
||||
{
|
||||
$project = new Project();
|
||||
|
||||
$result = $project->setType('git');
|
||||
self::assertEquals(true, $result);
|
||||
self::assertEquals('git', $project->getType());
|
||||
|
||||
$result = $project->setType('git');
|
||||
self::assertEquals(false, $result);
|
||||
}
|
||||
|
||||
|
||||
public function testAccessInformation()
|
||||
{
|
||||
$project = new Project();
|
||||
|
||||
$result = $project->setAccessInformation(['key-1' => 'value-1', 'key-2' => 'value-2']);
|
||||
self::assertEquals(true, $result);
|
||||
self::assertEquals(['key-1' => 'value-1', 'key-2' => 'value-2'], $project->getAccessInformation());
|
||||
self::assertEquals('value-1', $project->getAccessInformation('key-1'));
|
||||
self::assertEquals(null, $project->getAccessInformation('key-3'));
|
||||
|
||||
$result = $project->setAccessInformation(['key-1' => 'value-1', 'key-2' => 'value-2']);
|
||||
self::assertEquals(false, $result);
|
||||
}
|
||||
|
||||
public function testLastCommit()
|
||||
{
|
||||
$project = new Project();
|
||||
|
||||
$result = $project->setLastCommit('commit');
|
||||
self::assertEquals(true, $result);
|
||||
self::assertEquals('commit', $project->getLastCommit());
|
||||
|
||||
$result = $project->setLastCommit('commit');
|
||||
self::assertEquals(false, $result);
|
||||
}
|
||||
|
||||
public function testBuildConfig()
|
||||
{
|
||||
$project = new Project();
|
||||
|
||||
$result = $project->setBuildConfig('config');
|
||||
self::assertEquals(true, $result);
|
||||
self::assertEquals('config', $project->getBuildConfig());
|
||||
|
||||
$result = $project->setBuildConfig('config');
|
||||
self::assertEquals(false, $result);
|
||||
}
|
||||
|
||||
public function testAllowPublicStatus()
|
||||
{
|
||||
$project = new Project();
|
||||
|
||||
$result = $project->setAllowPublicStatus(true);
|
||||
self::assertEquals(true, $result);
|
||||
self::assertEquals(true, $project->getAllowPublicStatus());
|
||||
|
||||
$result = $project->setAllowPublicStatus(true);
|
||||
self::assertEquals(false, $result);
|
||||
}
|
||||
|
||||
public function testArchived()
|
||||
{
|
||||
$project = new Project();
|
||||
|
||||
$result = $project->setArchived(true);
|
||||
self::assertEquals(true, $result);
|
||||
self::assertEquals(true, $project->getArchived());
|
||||
|
||||
$result = $project->setArchived(true);
|
||||
self::assertEquals(false, $result);
|
||||
}
|
||||
|
||||
public function testGroupId()
|
||||
{
|
||||
$project = new Project();
|
||||
|
||||
$result = $project->setGroupId(200);
|
||||
self::assertEquals(true, $result);
|
||||
self::assertEquals(200, $project->getGroupId());
|
||||
|
||||
$result = $project->setGroupId(200);
|
||||
self::assertEquals(false, $result);
|
||||
}
|
||||
|
||||
public function testCreateDate()
|
||||
{
|
||||
$project = new Project();
|
||||
self::assertEquals(null, $project->getCreateDate());
|
||||
|
||||
$project = new Project();
|
||||
$createDate = new \DateTime();
|
||||
|
||||
$result = $project->setCreateDate($createDate);
|
||||
self::assertEquals(true, $result);
|
||||
self::assertEquals($createDate->getTimestamp(), $project->getCreateDate()->getTimestamp());
|
||||
|
||||
$result = $project->setCreateDate($createDate);
|
||||
self::assertEquals(false, $result);
|
||||
}
|
||||
|
||||
public function testUserId()
|
||||
{
|
||||
$project = new Project();
|
||||
|
||||
$result = $project->setUserId(300);
|
||||
self::assertEquals(true, $result);
|
||||
self::assertEquals(300, $project->getUserId());
|
||||
|
||||
$result = $project->setUserId(300);
|
||||
self::assertEquals(false, $result);
|
||||
}
|
||||
}
|
152
tests/src/Model/Base/UserTest.php
Normal file
152
tests/src/Model/Base/UserTest.php
Normal file
|
@ -0,0 +1,152 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\PHPCensor\Model\Base;
|
||||
|
||||
use PHPCensor\Model\Base\User;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class UserTest extends TestCase
|
||||
{
|
||||
public function testConstruct()
|
||||
{
|
||||
$user = new User();
|
||||
|
||||
self::assertInstanceOf('PHPCensor\Model', $user);
|
||||
self::assertInstanceOf('PHPCensor\Model\Base\User', $user);
|
||||
|
||||
self::assertEquals([
|
||||
'id' => null,
|
||||
'email' => null,
|
||||
'hash' => null,
|
||||
'is_admin' => null,
|
||||
'name' => null,
|
||||
'language' => null,
|
||||
'per_page' => null,
|
||||
'provider_key' => null,
|
||||
'provider_data' => null,
|
||||
'remember_key' => null,
|
||||
], $user->getDataArray());
|
||||
}
|
||||
|
||||
public function testId()
|
||||
{
|
||||
$user = new User();
|
||||
|
||||
$result = $user->setId(100);
|
||||
self::assertEquals(true, $result);
|
||||
self::assertEquals(100, $user->getId());
|
||||
|
||||
$result = $user->setId(100);
|
||||
self::assertEquals(false, $result);
|
||||
}
|
||||
|
||||
public function testEmail()
|
||||
{
|
||||
$user = new User();
|
||||
|
||||
$result = $user->setEmail('email@email.com');
|
||||
self::assertEquals(true, $result);
|
||||
self::assertEquals('email@email.com', $user->getEmail());
|
||||
|
||||
$result = $user->setEmail('email@email.com');
|
||||
self::assertEquals(false, $result);
|
||||
}
|
||||
|
||||
public function testHash()
|
||||
{
|
||||
$user = new User();
|
||||
|
||||
$result = $user->setHash('hash');
|
||||
self::assertEquals(true, $result);
|
||||
self::assertEquals('hash', $user->getHash());
|
||||
|
||||
$result = $user->setHash('hash');
|
||||
self::assertEquals(false, $result);
|
||||
}
|
||||
|
||||
public function testIsAdmin()
|
||||
{
|
||||
$user = new User();
|
||||
|
||||
$result = $user->setIsAdmin(true);
|
||||
self::assertEquals(true, $result);
|
||||
self::assertEquals(true, $user->getIsAdmin());
|
||||
|
||||
$result = $user->setIsAdmin(true);
|
||||
self::assertEquals(false, $result);
|
||||
}
|
||||
|
||||
public function testName()
|
||||
{
|
||||
$user = new User();
|
||||
|
||||
$result = $user->setName('name');
|
||||
self::assertEquals(true, $result);
|
||||
self::assertEquals('name', $user->getName());
|
||||
|
||||
$result = $user->setName('name');
|
||||
self::assertEquals(false, $result);
|
||||
}
|
||||
|
||||
public function testLanguage()
|
||||
{
|
||||
$user = new User();
|
||||
|
||||
$result = $user->setLanguage('la');
|
||||
self::assertEquals(true, $result);
|
||||
self::assertEquals('la', $user->getLanguage());
|
||||
|
||||
$result = $user->setLanguage('la');
|
||||
self::assertEquals(false, $result);
|
||||
}
|
||||
|
||||
public function testPerPage()
|
||||
{
|
||||
$user = new User();
|
||||
|
||||
$result = $user->setPerPage(10);
|
||||
self::assertEquals(true, $result);
|
||||
self::assertEquals(10, $user->getPerPage());
|
||||
|
||||
$result = $user->setPerPage(10);
|
||||
self::assertEquals(false, $result);
|
||||
}
|
||||
|
||||
public function testProviderKey()
|
||||
{
|
||||
$user = new User();
|
||||
|
||||
$result = $user->setProviderKey('key');
|
||||
self::assertEquals(true, $result);
|
||||
self::assertEquals('key', $user->getProviderKey());
|
||||
|
||||
$result = $user->setProviderKey('key');
|
||||
self::assertEquals(false, $result);
|
||||
}
|
||||
|
||||
public function testProviderData()
|
||||
{
|
||||
$user = new User();
|
||||
|
||||
$result = $user->setProviderData(['key-1' => 'value-1', 'key-2' => 'value-2']);
|
||||
self::assertEquals(true, $result);
|
||||
self::assertEquals(['key-1' => 'value-1', 'key-2' => 'value-2'], $user->getProviderData());
|
||||
self::assertEquals('value-1', $user->getProviderData('key-1'));
|
||||
self::assertEquals(null, $user->getProviderData('key-3'));
|
||||
|
||||
$result = $user->setProviderData(['key-1' => 'value-1', 'key-2' => 'value-2']);
|
||||
self::assertEquals(false, $result);
|
||||
}
|
||||
|
||||
public function testRememberKey()
|
||||
{
|
||||
$user = new User();
|
||||
|
||||
$result = $user->setRememberKey('remember');
|
||||
self::assertEquals(true, $result);
|
||||
self::assertEquals('remember', $user->getRememberKey());
|
||||
|
||||
$result = $user->setRememberKey('remember');
|
||||
self::assertEquals(false, $result);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue