Skip to content

Commit

Permalink
Updating TestSuite shell to use refactored classes and methods in the…
Browse files Browse the repository at this point in the history
… TestSuite.
  • Loading branch information
markstory committed Jan 10, 2010
1 parent b58f03b commit 80670d8
Showing 1 changed file with 54 additions and 37 deletions.
91 changes: 54 additions & 37 deletions cake/console/libs/testsuite.php
Expand Up @@ -100,41 +100,64 @@ function initialize() {
foreach ($plugins as $p) {
$this->plugins[] = Inflector::underscore($p);
}
$this->parseArgs();
$this->getManager();
}

/**
* Main entry point to this shell
* Parse the arguments given into the Shell object properties.
*
* @return void
* @access public
*/
function main() {
$this->out($this->headline);
$this->hr();
function parseArgs() {
$this->category = $this->args[0];

if (count($this->args) > 0) {
$this->category = $this->args[0];
if (!in_array($this->category, array('app', 'core'))) {
$this->isPluginTest = true;
}

if (!in_array($this->category, array('app', 'core'))) {
$this->isPluginTest = true;
}
if (isset($this->args[1])) {
$this->type = $this->args[1];
}

if (isset($this->args[1])) {
$this->type = $this->args[1];
if (isset($this->args[2])) {
if ($this->args[2] == 'cov') {
$this->doCoverage = true;
} else {
$this->file = Inflector::underscore($this->args[2]);
}
}

if (isset($this->args[2])) {
if ($this->args[2] == 'cov') {
$this->doCoverage = true;
} else {
$this->file = Inflector::underscore($this->args[2]);
}
}
if (isset($this->args[3]) && $this->args[3] == 'cov') {
$this->doCoverage = true;
}
}

if (isset($this->args[3]) && $this->args[3] == 'cov') {
$this->doCoverage = true;
}
} else {
/**
* Gets a manager instance, and set the app/plugin properties.
*
* @return void
*/
function getManager() {
$this->Manager = new TestManager();
$this->Manager->appTest = ($this->category === 'app');
if ($this->isPluginTest) {
$this->Manager->pluginTest = $this->category;
}
}

/**
* Main entry point to this shell
*
* @return void
* @access public
*/
function main() {
$this->out($this->headline);
$this->hr();

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

Expand Down Expand Up @@ -252,11 +275,10 @@ function __canRun() {
* @access private
*/
function __run() {
$reporter = new CLIReporter();
$this->__setGetVars();
$Reporter = new CakeCliReporter();

if ($this->type == 'all') {
return TestManager::runAllTests($reporter);
return $this->Manager->runAllTests($Reporter);
}

if ($this->doCoverage) {
Expand All @@ -278,9 +300,9 @@ function __run() {

if ($this->doCoverage) {
require_once CAKE . 'tests' . DS . 'lib' . DS . 'code_coverage_manager.php';
CodeCoverageManager::start($ucFirstGroup, $reporter);
CodeCoverageManager::start($ucFirstGroup, $Reporter);
}
$result = TestManager::runGroupTest($ucFirstGroup, $reporter);
$result = $this->Manager->runGroupTest($ucFirstGroup, $Reporter);
if ($this->doCoverage) {
CodeCoverageManager::report();
}
Expand All @@ -301,10 +323,10 @@ function __run() {

if ($this->doCoverage) {
require_once CAKE . 'tests' . DS . 'lib' . DS . 'code_coverage_manager.php';
CodeCoverageManager::start($case, $reporter);
CodeCoverageManager::start($case, $Reporter);
}

$result = TestManager::runTestCase($case, $reporter);
$result = $this->Manager->runTestCase($case, $Reporter);
if ($this->doCoverage) {
CodeCoverageManager::report();
}
Expand All @@ -328,14 +350,9 @@ function __findFolderByCategory($category) {
if (array_key_exists($category, $paths)) {
$folder = $paths[$category] . 'tests';
} else {
$scoredCategory = Inflector::underscore($category);
$folder = APP . 'plugins' . DS . $scoredCategory . DS;
$pluginPaths = App::path('plugins');
foreach ($pluginPaths as $path) {
if (file_exists($path . $scoredCategory . DS . 'tests')) {
$folder = $path . $scoredCategory . DS . 'tests';
break;
}
$pluginPath = App::pluginPath($category);
if (is_dir($pluginPath . 'tests')) {
$folder = $pluginPath . 'tests' . DS;
}
}
return $folder;
Expand Down

0 comments on commit 80670d8

Please sign in to comment.