Upgrade CakePHP from 2.2.5 to 2.9.5

This commit is contained in:
Brm Ko 2017-02-26 15:29:44 +01:00
parent 5a580df460
commit 235a541597
793 changed files with 60746 additions and 23753 deletions

View file

@ -4,18 +4,17 @@
*
* This Shell allows the running of test suites via the cake command line
*
* PHP 5
*
* CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice
*
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://book.cakephp.org/2.0/en/development/testing.html
* @since CakePHP(tm) v 1.2.0.4433
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
App::uses('Shell', 'Console');
@ -39,20 +38,21 @@ class TestShell extends Shell {
protected $_dispatcher = null;
/**
* get the option parser for the test suite.
* Gets the option parser instance and configures it.
*
* @return void
* @return ConsoleOptionParser
*/
public function getOptionParser() {
$parser = new ConsoleOptionParser($this->name);
$parser->description(array(
__d('cake_console', 'The CakePHP Testsuite allows you to run test cases from the command line'),
))->addArgument('category', array(
$parser->description(
__d('cake_console', 'The CakePHP Testsuite allows you to run test cases from the command line')
)->addArgument('category', array(
'help' => __d('cake_console', 'The category for the test, or test file, to test.'),
'required' => false,
'required' => false
))->addArgument('file', array(
'help' => __d('cake_console', 'The path to the file, or test file, to test.'),
'required' => false,
'required' => false
))->addOption('log-junit', array(
'help' => __d('cake_console', '<file> Log test execution in JUnit XML format to file.'),
'default' => false
@ -71,6 +71,9 @@ class TestShell extends Shell {
))->addOption('coverage-clover', array(
'help' => __d('cake_console', '<file> Write code coverage data in Clover XML format.'),
'default' => false
))->addOption('coverage-text', array(
'help' => __d('cake_console', 'Output code coverage report in Text format.'),
'boolean' => true
))->addOption('testdox-html', array(
'help' => __d('cake_console', '<file> Write agile documentation in HTML format to file.'),
'default' => false
@ -152,11 +155,12 @@ class TestShell extends Shell {
'default' => false
))->addOption('directive', array(
'help' => __d('cake_console', 'key[=value] Sets a php.ini value.'),
'short' => 'd',
'default' => false
))->addOption('fixture', array(
'help' => __d('cake_console', 'Choose a custom fixture manager.'),
'help' => __d('cake_console', 'Choose a custom fixture manager.')
))->addOption('debug', array(
'help' => __d('cake_console', 'More verbose output.'),
'help' => __d('cake_console', 'More verbose output.')
));
return $parser;
@ -170,20 +174,20 @@ class TestShell extends Shell {
*/
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>'));
$success = $this->_dispatcher->loadTestFramework();
if (!$success) {
throw new Exception(__d('cake_dev', 'Please install PHPUnit framework v3.7 <info>(http://www.phpunit.de)</info>'));
}
}
/**
* Parse the CLI options into an array CakeTestDispatcher can use.
*
* @return array Array of params for CakeTestDispatcher
* @return array|null Array of params for CakeTestDispatcher or null.
*/
protected function _parseArgs() {
if (empty($this->args)) {
return;
return null;
}
$params = array(
'core' => false,
@ -222,6 +226,7 @@ class TestShell extends Shell {
$options = array();
$params = $this->params;
unset($params['help']);
unset($params['quiet']);
if (!empty($params['no-colors'])) {
unset($params['no-colors'], $params['colors']);
@ -233,7 +238,11 @@ class TestShell extends Shell {
if ($value === false) {
continue;
}
$options[] = '--' . $param;
if ($param === 'directive') {
$options[] = '-d';
} else {
$options[] = '--' . $param;
}
if (is_string($value)) {
$options[] = $value;
}
@ -303,7 +312,7 @@ class TestShell extends Shell {
$this->out($title);
$i = 1;
$cases = array();
foreach ($testCases as $testCaseFile => $testCase) {
foreach ($testCases as $testCase) {
$case = str_replace('Test.php', '', $testCase);
$this->out("[$i] $case");
$cases[$i] = $case;
@ -325,7 +334,7 @@ class TestShell extends Shell {
break;
}
if ($choice == 'q') {
if ($choice === 'q') {
break;
}
}
@ -334,11 +343,10 @@ class TestShell extends Shell {
/**
* Find the test case for the passed file. The file could itself be a test.
*
* @param string $file
* @param string $category
* @param boolean $throwOnMissingFile
* @access protected
* @return array(type, case)
* @param string $file The file to map.
* @param string $category The test file category.
* @param bool $throwOnMissingFile Whether or not to throw an exception.
* @return array array(type, case)
* @throws Exception
*/
protected function _mapFileToCase($file, $category, $throwOnMissingFile = true) {
@ -412,8 +420,7 @@ class TestShell extends Shell {
/**
* For the given file, what category of test is it? returns app, core or the name of the plugin
*
* @param string $file
* @access protected
* @param string $file The file to map.
* @return string
*/
protected function _mapFileToCategory($file) {