From 1b97af2e343dbd402a0bcf7dcf26637fd5862116 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Wed, 7 Jul 2010 00:11:06 -0430 Subject: [PATCH] Making necessary changes to use the PHPUnit cli tool in testsuite shell --- cake/console/libs/testsuite.php | 39 +++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/cake/console/libs/testsuite.php b/cake/console/libs/testsuite.php index 0da9c662681..54df3adbdf6 100644 --- a/cake/console/libs/testsuite.php +++ b/cake/console/libs/testsuite.php @@ -59,9 +59,6 @@ protected function parseArgs() { 'app' => false, 'plugin' => null, 'output' => 'text', - 'codeCoverage' => false, - 'filter' => false, - 'case' => null ); $category = $this->args[0]; @@ -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 * @@ -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()); } /**