From a3ef15b488ea96043b5a237eace6db82deb9feef Mon Sep 17 00:00:00 2001 From: Dmitry Khomutov Date: Sat, 1 Apr 2017 11:32:39 +0700 Subject: [PATCH] Fixed debug build from GUI for environments --- src/PHPCensor/Model/Build.php | 41 +++++++++++----------- src/PHPCensor/Model/Environment.php | 2 +- src/PHPCensor/Service/BuildService.php | 5 +-- src/PHPCensor/View/Project/view.phtml | 48 +++++++++++++------------- tests/PHPCensor/Model/BuildTest.php | 21 +++++++++++ 5 files changed, 69 insertions(+), 48 deletions(-) diff --git a/src/PHPCensor/Model/Build.php b/src/PHPCensor/Model/Build.php index 4bf2a830..18ad7d8f 100644 --- a/src/PHPCensor/Model/Build.php +++ b/src/PHPCensor/Model/Build.php @@ -570,7 +570,6 @@ class Build extends Model /** * Set the values of Extra / extra. * - * @param $name string * @param $values mixed */ public function setExtraValues($values) @@ -583,6 +582,26 @@ class Build extends Model $this->setExtra(json_encode($extra)); } + /** + * Return a value from the build's "extra" JSON array. + * @param null $key + * @return mixed|null|string + */ + public function getExtra($key = null) + { + $data = json_decode($this->data['extra'], true); + + if (is_null($key)) { + $rtn = $data; + } elseif (isset($data[$key])) { + $rtn = $data[$key]; + } else { + $rtn = null; + } + + return $rtn; + } + /** * Get the Project model for this Build by Id. * @@ -801,26 +820,6 @@ class Build extends Model return $config; } - /** - * Return a value from the build's "extra" JSON array. - * @param null $key - * @return mixed|null|string - */ - public function getExtra($key = null) - { - $data = json_decode($this->data['extra'], true); - - if (is_null($key)) { - $rtn = $data; - } elseif (isset($data[$key])) { - $rtn = $data[$key]; - } else { - $rtn = null; - } - - return $rtn; - } - /** * Returns the commit message for this build. * @return string diff --git a/src/PHPCensor/Model/Environment.php b/src/PHPCensor/Model/Environment.php index 2ae92ec5..4645010c 100644 --- a/src/PHPCensor/Model/Environment.php +++ b/src/PHPCensor/Model/Environment.php @@ -142,7 +142,7 @@ class Environment extends Model /** * Get the value of Title / title. * - * @return string + * @return array */ public function getBranches() { diff --git a/src/PHPCensor/Service/BuildService.php b/src/PHPCensor/Service/BuildService.php index 332e4dc8..38aae3cf 100644 --- a/src/PHPCensor/Service/BuildService.php +++ b/src/PHPCensor/Service/BuildService.php @@ -34,13 +34,14 @@ class BuildService } /** - * @param Project $project - * @param string $environment + * @param Project $project + * @param string $environment * @param string|null $commitId * @param string|null $branch * @param string|null $committerEmail * @param string|null $commitMessage * @param string|null $extra + * * @return \PHPCensor\Model\Build */ public function createBuild( diff --git a/src/PHPCensor/View/Project/view.phtml b/src/PHPCensor/View/Project/view.phtml index c3f82950..b320cb8b 100644 --- a/src/PHPCensor/View/Project/view.phtml +++ b/src/PHPCensor/View/Project/view.phtml @@ -25,20 +25,20 @@