mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
remove inherited logic
This commit is contained in:
parent
2e547cad19
commit
25ce1cc823
1 changed files with 2 additions and 126 deletions
|
@ -18,10 +18,7 @@
|
|||
* @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.
|
||||
|
@ -29,14 +26,7 @@ App::uses('CakeTestLoader', 'TestSuite');
|
|||
*
|
||||
* @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.
|
||||
|
@ -164,20 +154,6 @@ class TestsuiteShell extends Shell {
|
|||
return $parser;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
|
@ -210,34 +186,6 @@ class TestsuiteShell extends Shell {
|
|||
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();
|
||||
$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
|
||||
*
|
||||
|
@ -255,76 +203,4 @@ class TestsuiteShell extends Shell {
|
|||
|
||||
$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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue