Skip to content

Commit

Permalink
Doing some tweaks to CakeTestSuiteDispatcher to make CLI testing easier.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Jun 26, 2010
1 parent 3ebbaf1 commit 0baab93
Showing 1 changed file with 34 additions and 13 deletions.
47 changes: 34 additions & 13 deletions cake/tests/lib/cake_test_suite_dispatcher.php
Expand Up @@ -68,6 +68,13 @@ class CakeTestSuiteDispatcher {
*/
protected $_baseDir;

/**
* boolean to set auto parsing of params.
*
* @var boolean
*/
protected $_paramsParsed = false;

/**
* reporter instance used for the request
*
Expand Down Expand Up @@ -96,13 +103,14 @@ function dispatch() {
$this->_parseParams();

if ($this->params['case']) {
$this->_runTestCase();
$value = $this->_runTestCase();
} else {
$this->_testCaseList();
$value = $this->_testCaseList();
}

$output = ob_get_clean();
echo $output;
return $value;
}

/**
Expand Down Expand Up @@ -202,23 +210,36 @@ function &getReporter() {
return self::$_Reporter;
}

/**
* Sets the params, calling this will bypass the auto parameter parsing.
*
* @param array $params Array of parameters for the dispatcher
* @return void
*/
public function setParams($params) {
$this->params = $params;
$this->_paramsParsed = true;
}

/**
* Parse url params into a 'request'
*
* @return void
*/
function _parseParams() {
if (!isset($_SERVER['SERVER_NAME'])) {
$_SERVER['SERVER_NAME'] = '';
}
foreach ($this->params as $key => $value) {
if (isset($_GET[$key])) {
$this->params[$key] = $_GET[$key];
if (!$this->_paramsParsed) {
if (!isset($_SERVER['SERVER_NAME'])) {
$_SERVER['SERVER_NAME'] = '';
}
foreach ($this->params as $key => $value) {
if (isset($_GET[$key])) {
$this->params[$key] = $_GET[$key];
}
}
if (isset($_GET['code_coverage'])) {
$this->params['codeCoverage'] = true;
$this->_checkXdebug();
}
}
if (isset($_GET['code_coverage'])) {
$this->params['codeCoverage'] = true;
$this->_checkXdebug();
}
$this->params['baseUrl'] = $this->_baseUrl;
$this->params['baseDir'] = $this->_baseDir;
Expand All @@ -232,6 +253,6 @@ function _parseParams() {
*/
function _runTestCase() {
$Reporter = CakeTestSuiteDispatcher::getReporter();
$this->Manager->runTestCase($this->params['case'], $Reporter, $this->params['codeCoverage']);
return $this->Manager->runTestCase($this->params['case'], $Reporter, $this->params['codeCoverage']);
}
}

0 comments on commit 0baab93

Please sign in to comment.