Browse files

remove inherited logic

  • Loading branch information...
1 parent 2e547ca commit 25ce1cc82396eefb829cb97b07eea39c52f06560 @AD7six AD7six committed Oct 18, 2011
Showing with 2 additions and 126 deletions.
  1. +2 −126 lib/Cake/Console/Command/TestsuiteShell.php
View
128 lib/Cake/Console/Command/TestsuiteShell.php
@@ -18,25 +18,15 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-App::uses('Shell', 'Console');
-App::uses('CakeTestSuiteDispatcher', 'TestSuite');
-App::uses('CakeTestSuiteCommand', 'TestSuite');
-App::uses('CakeTestLoader', 'TestSuite');
+App::uses('TestShell', 'Console/Command');
/**
* Provides a CakePHP wrapper around PHPUnit.
* Adds in CakePHP's fixtures and gives access to plugin, app and core test cases
*
* @package Cake.Console.Command
*/
-class TestsuiteShell extends Shell {
-
-/**
- * Dispatcher object for the run.
- *
- * @var CakeTestDispatcher
- */
- protected $_dispatcher = null;
+class TestsuiteShell extends TestShell {
/**
* get the option parser for the test suite.
@@ -165,20 +155,6 @@ public function getOptionParser() {
}
/**
- * Initialization method installs PHPUnit and loads all plugins
- *
- * @return void
- * @throws Exception
- */
- public function initialize() {
- $this->_dispatcher = new CakeTestSuiteDispatcher();
- $sucess = $this->_dispatcher->loadTestFramework();
- if (!$sucess) {
- throw new Exception(__d('cake_dev', 'Please install PHPUnit framework <info>(http://www.phpunit.de)</info>'));
- }
- }
-
-/**
* Parse the CLI options into an array CakeTestDispatcher can use.
*
* @return array Array of params for CakeTestDispatcher
@@ -211,34 +187,6 @@ protected function _parseArgs() {
}
/**
- * 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();
- $params = $this->params;
- unset($params['help']);
-
- if (!empty($params['no-colors'])) {
- unset($params['no-colors'], $params['colors']);
- } else {
- $params['colors'] = true;
- }
-
- foreach ($params as $param => $value) {
- if ($value === false) {
- continue;
- }
- $options[] = '--' . $param;
- if (is_string($value)) {
- $options[] = $value;
- }
- }
- return $options;
- }
-
-/**
* Main entry point to this shell
*
* @return void
@@ -255,76 +203,4 @@ public function main() {
$this->_run($args, $this->_runnerOptions());
}
-
-/**
- * Runs the test case from $runnerArgs
- *
- * @param array $runnerArgs list of arguments as obtained from _parseArgs()
- * @param array $options list of options as constructed by _runnerOptions()
- * @return void
- */
- protected function _run($runnerArgs, $options = array()) {
- restore_error_handler();
- restore_error_handler();
-
- $testCli = new CakeTestSuiteCommand('CakeTestLoader', $runnerArgs);
- $testCli->run($options);
- }
-
-/**
- * Shows a list of available test cases and gives the option to run one of them
- *
- * @return void
- */
- public function available() {
- $params = $this->_parseArgs();
- $testCases = CakeTestLoader::generateTestList($params);
- $app = $params['app'];
- $plugin = $params['plugin'];
-
- $title = "Core Test Cases:";
- $category = 'core';
- if ($app) {
- $title = "App Test Cases:";
- $category = 'app';
- } elseif ($plugin) {
- $title = Inflector::humanize($plugin) . " Test Cases:";
- $category = $plugin;
- }
-
- if (empty($testCases)) {
- $this->out(__d('cake_console', "No test cases available \n\n"));
- return $this->out($this->OptionParser->help());
- }
-
- $this->out($title);
- $i = 1;
- $cases = array();
- foreach ($testCases as $testCaseFile => $testCase) {
- $case = str_replace('Test.php', '', $testCase);
- $this->out("[$i] $case");
- $cases[$i] = $case;
- $i++;
- }
-
- while ($choice = $this->in(__d('cake_console', 'What test case would you like to run?'), null, 'q')) {
- if (is_numeric($choice) && isset($cases[$choice])) {
- $this->args[0] = $category;
- $this->args[1] = $cases[$choice];
- $this->_run($this->_parseArgs(), $this->_runnerOptions());
- break;
- }
-
- if (is_string($choice) && in_array($choice, $cases)) {
- $this->args[0] = $category;
- $this->args[1] = $choice;
- $this->_run($this->_parseArgs(), $this->_runnerOptions());
- break;
- }
-
- if ($choice == 'q') {
- break;
- }
- }
- }
}

0 comments on commit 25ce1cc

Please sign in to comment.