Permalink
Browse files

Removing duplicate method calls, and doing some refactoring of Report…

…er retrieval. Adding Manager instance var to help make subclassing more flexible in regards to TestManagers.
  • Loading branch information...
1 parent 9a62fd5 commit 48e1c4d08af920b5dabae284d2543e18607dcd42 @markstory markstory committed Jan 5, 2010
Showing with 27 additions and 10 deletions.
  1. +27 −10 cake/tests/lib/cake_test_suite_dispatcher.php
@@ -42,6 +42,20 @@ class CakeTestSuiteDispatcher {
);
/**
+ * The classname for the TestManager being used
+ *
+ * @var string
+ */
+ var $_managerClass;
+
+/**
+ * The Instance of the Manager being used.
+ *
+ * @var TestManager subclass
+ */
+ var $Manager;
+
+/**
* Runs the actions required by the URL parameters.
*
* @return void
@@ -75,7 +89,6 @@ function dispatch() {
*/
function _checkSimpleTest() {
if (!App::import('Vendor', 'simpletest' . DS . 'reporter')) {
- CakeTestMenu::testHeader();
include CAKE_TESTS_LIB . 'simpletest.php';
CakeTestMenu::footer();
exit();
@@ -90,7 +103,6 @@ function _checkSimpleTest() {
*/
function _checkXdebug() {
if (!extension_loaded('xdebug')) {
- CakeTestMenu::testHeader();
include CAKE_TESTS_LIB . 'xdebug.php';
CakeTestMenu::footer();
exit();
@@ -106,11 +118,14 @@ function _checkXdebug() {
function getManager() {
$className = ucwords($this->params['output']) . 'TestManager';
if (class_exists($className)) {
- $this->_manager = $className;
- return;
+ $this->_managerClass = $className;
} else {
- $this->_manager = 'TextTestManager';
+ $this->_managerClass = 'TextTestManager';
+ }
+ if (empty($this->Manager)) {
+ $this->Manager = new $this->_managerClass();
}
+ return $this->Manager;
}
/**
@@ -163,13 +178,14 @@ function _parseParams() {
* @return void
*/
function _runGroupTest() {
+ $Reporter =& CakeTestSuiteDispatcher::getReporter();
if ('all' == $this->params['group']) {
- TestManager::runAllTests(CakeTestsGetReporter());
+ TestManager::runAllTests($Reporter);
} else {
if ($this->params['codeCoverage']) {
- CodeCoverageManager::start($this->params['group'], CakeTestSuiteDispatcher::getReporter());
+ CodeCoverageManager::start($this->params['group'], $Reporter);
}
- TestManager::runGroupTest(ucfirst($this->params['group']), CakeTestSuiteDispatcher::getReporter());
+ TestManager::runGroupTest(ucfirst($this->params['group']), $Reporter);
if ($this->params['codeCoverage']) {
CodeCoverageManager::report();
}
@@ -184,11 +200,12 @@ function _runGroupTest() {
* @return void
*/
function _runTestCase() {
+ $Reporter =& CakeTestSuiteDispatcher::getReporter();
if ($this->params['codeCoverage']) {
- CodeCoverageManager::start($_GET['case'], CakeTestSuiteDispatcher::getReporter());
+ CodeCoverageManager::start($_GET['case'], $Reporter);
}
- TestManager::runTestCase($_GET['case'], CakeTestSuiteDispatcher::getReporter());
+ TestManager::runTestCase($_GET['case'], $Reporter);
if ($this->params['codeCoverage']) {
CodeCoverageManager::report();

0 comments on commit 48e1c4d

Please sign in to comment.