From 00d04a1c30e581453e414702cf521d34408d1e1a Mon Sep 17 00:00:00 2001 From: Klimov Paul Date: Sat, 11 May 2013 16:26:16 +0300 Subject: [PATCH] Method "YiiRequirementChecker::check()" has been refactored to be used in method chain. Methods "YiiRequirementChecker::getResults()" and "YiiRequirementChecker::render()" have been added. --- .../requirements/YiiRequirementCheckerTest.php | 2 +- yii/requirements/YiiRequirementChecker.php | 28 +++++++++++++++++++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/tests/unit/framework/requirements/YiiRequirementCheckerTest.php b/tests/unit/framework/requirements/YiiRequirementCheckerTest.php index 79eafb7..9661738 100644 --- a/tests/unit/framework/requirements/YiiRequirementCheckerTest.php +++ b/tests/unit/framework/requirements/YiiRequirementCheckerTest.php @@ -38,7 +38,7 @@ class YiiRequirementCheckerTest extends TestCase ), ); - $checkResult = $requirementsChecker->check($requirements); + $checkResult = $requirementsChecker->check($requirements)->getResult(); $summary = $checkResult['summary']; $this->assertEquals(count($requirements), $summary['total'], 'Wrong summary total!'); diff --git a/yii/requirements/YiiRequirementChecker.php b/yii/requirements/YiiRequirementChecker.php index fb4e42e..46fe106 100644 --- a/yii/requirements/YiiRequirementChecker.php +++ b/yii/requirements/YiiRequirementChecker.php @@ -49,7 +49,33 @@ class YiiRequirementChecker 'summary' => $summary, 'requirements' => $requirements, ); - return $result; + $this->result = $result; + return $this; + } + + /** + * Return the check results. + * @return array|null check results. + */ + function getResult() + { + if (isset($this->result)) { + return $this->result; + } else { + return null; + } + } + + /** + * Renders the requirements check result. + * The output will vary depending is a script running from web or from console. + */ + function render() + { + if (isset($this->result)) { + $this->usageError('Nothing to render!'); + } + // @todo render } /**