From 31beb233e3abd5bfcaf4d802571ee0e79908c194 Mon Sep 17 00:00:00 2001 From: Dmitry Khomutov Date: Mon, 3 Apr 2017 21:19:51 +0700 Subject: [PATCH] Separated Build status constants and Plugin status constants --- src/PHPCensor/Model/Build.php | 1 - src/PHPCensor/Plugin.php | 5 +++++ src/PHPCensor/Plugin/Util/Executor.php | 13 +++++++------ src/PHPCensor/View/Home/ajax-timeline.phtml | 17 +++++++++++------ src/PHPCensor/View/Home/index.phtml | 17 +++++++++++------ 5 files changed, 34 insertions(+), 19 deletions(-) diff --git a/src/PHPCensor/Model/Build.php b/src/PHPCensor/Model/Build.php index e110475d..0847847c 100644 --- a/src/PHPCensor/Model/Build.php +++ b/src/PHPCensor/Model/Build.php @@ -25,7 +25,6 @@ class Build extends Model const STATUS_RUNNING = 1; const STATUS_SUCCESS = 2; const STATUS_FAILED = 3; - const STATUS_FAILED_ALLOWED = 4; /** * @var array diff --git a/src/PHPCensor/Plugin.php b/src/PHPCensor/Plugin.php index 4b3088d3..d53f4c8c 100644 --- a/src/PHPCensor/Plugin.php +++ b/src/PHPCensor/Plugin.php @@ -11,6 +11,11 @@ use PHPCensor\Model\Build; */ abstract class Plugin { + const STATUS_PENDING = 0; + const STATUS_RUNNING = 1; + const STATUS_SUCCESS = 2; + const STATUS_FAILED = 3; + const STATUS_FAILED_ALLOWED = 4; /** * @var \PHPCensor\Builder */ diff --git a/src/PHPCensor/Plugin/Util/Executor.php b/src/PHPCensor/Plugin/Util/Executor.php index 3dc6fbdf..a6448783 100644 --- a/src/PHPCensor/Plugin/Util/Executor.php +++ b/src/PHPCensor/Plugin/Util/Executor.php @@ -7,6 +7,7 @@ use Exception; use PHPCensor\Helper\Lang; use PHPCensor\Logging\BuildLogger; use PHPCensor\Model\Build; +use PHPCensor\Plugin; use PHPCensor\Store\BuildStore; /** @@ -138,15 +139,15 @@ class Executor 'Stage' . ': ' . ucfirst($stage) . ')' ); - $this->setPluginStatus($stage, $plugin, Build::STATUS_RUNNING); + $this->setPluginStatus($stage, $plugin, Plugin::STATUS_RUNNING); // Try and execute it if ($this->executePlugin($plugin, $options)) { // Execution was successful $this->logger->logSuccess('PLUGIN: SUCCESS'); - $this->setPluginStatus($stage, $plugin, Build::STATUS_SUCCESS); + $this->setPluginStatus($stage, $plugin, Plugin::STATUS_SUCCESS); } else { - $status = Build::STATUS_FAILED; + $status = Plugin::STATUS_FAILED; if ($stage === Build::STAGE_SETUP) { $this->logger->logFailure('PLUGIN: FAILED'); @@ -163,7 +164,7 @@ class Executor $this->logger->logFailure('PLUGIN: FAILED'); $success = false; } else { - $status = Build::STATUS_FAILED_ALLOWED; + $status = Plugin::STATUS_FAILED_ALLOWED; $this->logger->logFailure('PLUGIN: FAILED (ALLOWED)'); } @@ -223,9 +224,9 @@ class Executor $summary[$stage][$plugin]['status'] = $status; - if ($status === Build::STATUS_RUNNING) { + if ($status === Plugin::STATUS_RUNNING) { $summary[$stage][$plugin]['started'] = time(); - } elseif ($status >= Build::STATUS_SUCCESS) { + } elseif ($status >= Plugin::STATUS_SUCCESS) { $summary[$stage][$plugin]['ended'] = time(); } diff --git a/src/PHPCensor/View/Home/ajax-timeline.phtml b/src/PHPCensor/View/Home/ajax-timeline.phtml index 2b3e9a40..07bfc58c 100644 --- a/src/PHPCensor/View/Home/ajax-timeline.phtml +++ b/src/PHPCensor/View/Home/ajax-timeline.phtml @@ -1,4 +1,9 @@ - +