Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Removing CakeTestsGetReporter global function.

Starting to move Reporter/Manager decision making to CakeTestSuiteDispatcher, also affording the ability to use custom reporters/managers for generating test suite output.
  • Loading branch information...
commit dd5a886f3af0ce5a31713a92154dca3777add175 1 parent 33cb8ee
@markstory markstory authored
View
46 cake/tests/lib/cake_test_suite_dispatcher.php
@@ -40,6 +40,7 @@ class CakeTestSuiteDispatcher {
'output' => 'html',
'show' => 'groups'
);
+
/**
* Runs the actions required by the URL parameters.
*
@@ -97,6 +98,46 @@ function _checkXdebug() {
}
/**
+ * Sets the Manager to use for the request.
+ *
+ * @return string The manager class name
+ * @static
+ */
+ function getManager() {
+ $className = ucwords($this->params['output']) . 'TestManager';
+ if (class_exists($className)) {
+ $this->_manager = $className;
+ return;
+ } else {
+ $this->_manager = 'TextTestManager';
+ }
+ }
+
+/**
+ * Gets the reporter based on the request parameters
+ *
+ * @return void
+ */
+ function &getReporter() {
+ static $Reporter = NULL;
+ if (!$Reporter) {
+ $coreClass = 'Cake' . $this->params['output'] . 'Reporter';
+ $coreFile = CAKE_TESTS_LIB . 'cake_' . strtolower($this->params['output']) . '_reporter.php';
+
+ $appClass = $this->params['output'] . 'Reporter';
+ $appFile = APPLIBS . 'test_suite' . DS . strtolower($this->params['output']) . '_reporter.php';
+ if (file_exists($coreFile)) {
+ require_once $coreFile;
+ $Reporter =& new $coreClass();
+ } elseif (file_exists($appFile)) {
+ require_once $appFile;
+ $Reporter =& new $appClass();
+ }
+ }
+ return $Reporter;
+ }
+
+/**
* Parse url params into a 'request'
*
* @return void
@@ -115,6 +156,7 @@ function _parseParams() {
require_once CAKE_TESTS_LIB . 'code_coverage_manager.php';
$this->_checkXdebug();
}
+ $this->getManager();
}
/**
@@ -127,9 +169,9 @@ function _runGroupTest() {
TestManager::runAllTests(CakeTestsGetReporter());
} else {
if ($this->params['codeCoverage']) {
- CodeCoverageManager::start($this->params['group'], CakeTestsGetReporter());
+ CodeCoverageManager::start($this->params['group'], CakeTestSuiteDispatcher::getReporter());
}
- TestManager::runGroupTest(ucfirst($this->params['group']), CakeTestsGetReporter());
+ TestManager::runGroupTest(ucfirst($this->params['group']), CakeTestSuiteDispatcher::getReporter());
if ($this->params['codeCoverage']) {
CodeCoverageManager::report();
}
View
30 cake/tests/lib/test_manager.php
@@ -641,34 +641,4 @@ function &getTestCaseList() {
return $buffer;
}
}
-
-if (function_exists('caketestsgetreporter')) {
- echo "You need a new test.php. \n";
- echo "Try this one: " . dirname(CONSOLE_LIBS) . "templates" . DS . "skel" . DS . "webroot" . DS . "test.php";
- exit();
-} else {
-
-/**
- * Returns an object of the currently needed reporter
- *
- * @access public
- */
- function &CakeTestsGetReporter() {
- static $Reporter = NULL;
- if (!$Reporter) {
- switch (CAKE_TEST_OUTPUT) {
- case CAKE_TEST_OUTPUT_HTML:
- require_once CAKE_TESTS_LIB . 'cake_reporter.php';
- $Reporter =& new CakeHtmlReporter();
- break;
- default:
- require_once CAKE_TESTS_LIB . 'cake_text_reporter.php';
- $Reporter =& new CakeTextReporter();
- break;
- }
- }
- return $Reporter;
- }
-
-}
?>

0 comments on commit dd5a886

Please sign in to comment.
Something went wrong with that request. Please try again.