Skip to content

Commit

Permalink
Making necessary changes to use the PHPUnit cli tool in testsuite shell
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo committed Jul 7, 2010
1 parent f8ed997 commit 1b97af2
Showing 1 changed file with 22 additions and 17 deletions.
39 changes: 22 additions & 17 deletions cake/console/libs/testsuite.php
Expand Up @@ -59,9 +59,6 @@ protected function parseArgs() {
'app' => false,
'plugin' => null,
'output' => 'text',
'codeCoverage' => false,
'filter' => false,
'case' => null
);

$category = $this->args[0];
Expand All @@ -73,20 +70,35 @@ protected function parseArgs() {
}

if (isset($this->args[1])) {
$params['case'] = Inflector::underscore($this->args[1]) . '.test.php';
$params['case'] = Inflector::underscore($this->args[1]);
}
if (isset($this->args[2]) && $this->args[2] == 'cov') {
$params['codeCoverage'] = true;
}
if (isset($this->params['filter'])) {
$params['filter'] = $this->params['filter'];
}
if (isset($this->params['coverage'])) {
$params['codeCoverage'] = true;
}
return $params;
}

/**
* Converts the options passed to the shell as options for the PHPUnit cli runner
*
* @return array Array of params for CakeTestDispatcher
*/
protected function runnerOptions() {
$options = array();
foreach ($this->params as $param => $value) {
if ($param[0] === '-') {
$options[] = '-' . $param;
if (is_string($value)) {
$options[] = $value;
}
}
}
return $options;
}

/**
* Main entry point to this shell
*
Expand All @@ -96,16 +108,9 @@ public function main() {
$this->out(__('CakePHP Test Shell'));
$this->hr();

if (count($this->args) == 0) {
$this->error(__('Sorry, you did not pass any arguments!'));
}

$result = $this->_dispatcher->dispatch();
$exit = 0;
if ($result instanceof PHPUnit_Framework_TestResult) {
$exit = ($result->errorCount() + $result->failureCount()) > 0;
}
$this->_stop($exit);
require_once CAKE . 'tests' . DS . 'lib' . DS . 'test_runner.php';
$testCli = new TestRunner($this->parseArgs());
$testCli->run($this->runnerOptions());
}

/**
Expand Down

0 comments on commit 1b97af2

Please sign in to comment.