Merge branch 'master' into 2.4

Conflicts:
	lib/Cake/Test/Case/Network/CakeRequestTest.php
This commit is contained in:
mark_story 2013-07-03 14:21:09 -04:00
commit c597855fe4
59 changed files with 484 additions and 421 deletions

View file

@ -82,7 +82,7 @@ class AclShell extends AppShell {
$out .= __d('cake_console', 'Current ACL Classname: %s', $class) . "\n";
$out .= "--------------------------------------------------\n";
$this->err($out);
$this->_stop();
return $this->_stop();
}
if ($this->command) {

View file

@ -100,7 +100,7 @@ class ApiShell extends AppShell {
if (isset($this->params['method'])) {
if (!isset($parsed[$this->params['method']])) {
$this->err(__d('cake_console', '%s::%s() could not be found', $class, $this->params['method']));
$this->_stop();
return $this->_stop();
}
$method = $parsed[$this->params['method']];
$this->out($class . '::' . $method['method'] . $method['parameters']);

View file

@ -123,8 +123,7 @@ class BakeShell extends AppShell {
$this->Test->execute();
break;
case 'Q':
exit(0);
break;
return $this->_stop();
default:
$this->out(__d('cake_console', 'You have made an invalid selection. Please choose a type of class to Bake by entering D, M, V, F, T, or C.'));
}

View file

@ -345,7 +345,6 @@ class ConsoleShell extends AppShell {
default:
$this->out(__d('cake_console', "Invalid command"));
$this->out();
break;
}
$command = '';
}

View file

@ -84,8 +84,7 @@ class I18nShell extends AppShell {
$this->out($this->OptionParser->help());
break;
case 'q':
exit(0);
break;
return $this->_stop();
default:
$this->out(__d('cake_console', 'You have made an invalid selection. Please choose a command to execute by entering E, I, H, or Q.'));
}

View file

@ -106,12 +106,11 @@ class SchemaShell extends AppShell {
$File = new File($this->Schema->path . DS . $this->params['file']);
if ($File->exists()) {
$this->out($File->read());
$this->_stop();
} else {
return $this->_stop();
}
$file = $this->Schema->path . DS . $this->params['file'];
$this->err(__d('cake_console', 'Schema file (%s) could not be found.', $file));
$this->_stop();
}
return $this->_stop();
}
/**
@ -191,11 +190,10 @@ class SchemaShell extends AppShell {
if ($this->Schema->write($content)) {
$this->out(__d('cake_console', 'Schema file: %s generated', $content['file']));
$this->_stop();
} else {
$this->err(__d('cake_console', 'Schema file: %s generated'));
$this->_stop();
return $this->_stop();
}
$this->err(__d('cake_console', 'Schema file: %s generated'));
return $this->_stop();
}
/**
@ -212,7 +210,7 @@ class SchemaShell extends AppShell {
$Schema = $this->Schema->load();
if (!$Schema) {
$this->err(__d('cake_console', 'Schema could not be loaded'));
$this->_stop();
return $this->_stop();
}
if (!empty($this->params['write'])) {
if ($this->params['write'] == 1) {
@ -236,10 +234,10 @@ class SchemaShell extends AppShell {
if ($File->write($contents)) {
$this->out(__d('cake_console', 'SQL dump file created in %s', $File->pwd()));
$this->_stop();
return $this->_stop();
} else {
$this->err(__d('cake_console', 'SQL dump could not be created'));
$this->_stop();
return $this->_stop();
}
}
$this->out($contents);
@ -297,7 +295,7 @@ class SchemaShell extends AppShell {
$this->err(__d('cake_console', 'The chosen schema could not be loaded. Attempted to load:'));
$this->err(__d('cake_console', 'File: %s', $this->Schema->path . DS . $this->Schema->file));
$this->err(__d('cake_console', 'Name: %s', $this->Schema->name));
$this->_stop();
return $this->_stop();
}
$table = null;
if (isset($this->args[1])) {
@ -330,13 +328,13 @@ class SchemaShell extends AppShell {
}
if (empty($drop) || empty($create)) {
$this->out(__d('cake_console', 'Schema is up to date.'));
$this->_stop();
return $this->_stop();
}
$this->out("\n" . __d('cake_console', 'The following table(s) will be dropped.'));
$this->out(array_keys($drop));
if ('y' == $this->in(__d('cake_console', 'Are you sure you want to drop the table(s)?'), array('y', 'n'), 'n')) {
if ($this->in(__d('cake_console', 'Are you sure you want to drop the table(s)?'), array('y', 'n'), 'n') === 'y') {
$this->out(__d('cake_console', 'Dropping table(s).'));
$this->_run($drop, 'drop', $Schema);
}
@ -344,7 +342,7 @@ class SchemaShell extends AppShell {
$this->out("\n" . __d('cake_console', 'The following table(s) will be created.'));
$this->out(array_keys($create));
if ('y' == $this->in(__d('cake_console', 'Are you sure you want to create the table(s)?'), array('y', 'n'), 'y')) {
if ($this->in(__d('cake_console', 'Are you sure you want to create the table(s)?'), array('y', 'n'), 'y') === 'y') {
$this->out(__d('cake_console', 'Creating table(s).'));
$this->_run($create, 'create', $Schema);
}
@ -390,12 +388,12 @@ class SchemaShell extends AppShell {
if (empty($contents)) {
$this->out(__d('cake_console', 'Schema is up to date.'));
$this->_stop();
return $this->_stop();
}
$this->out("\n" . __d('cake_console', 'The following statements will run.'));
$this->out(array_map('trim', $contents));
if ('y' == $this->in(__d('cake_console', 'Are you sure you want to alter the tables?'), array('y', 'n'), 'n')) {
if ($this->in(__d('cake_console', 'Are you sure you want to alter the tables?'), array('y', 'n'), 'n') === 'y') {
$this->out();
$this->out(__d('cake_console', 'Updating Database...'));
$this->_run($contents, 'update', $Schema);

View file

@ -289,7 +289,7 @@ class ControllerTask extends BakeTask {
App::uses($modelImport, $plugin . 'Model');
if (!class_exists($modelImport)) {
$this->err(__d('cake_console', 'You must have a model for this class to build basic methods. Please try again.'));
$this->_stop();
return $this->_stop();
}
$modelObj = ClassRegistry::init($currentModelName);

View file

@ -77,7 +77,7 @@ class DbConfigTask extends AppShell {
public function execute() {
if (empty($this->args)) {
$this->_interactive();
$this->_stop();
return $this->_stop();
}
}

View file

@ -207,7 +207,7 @@ class ExtractTask extends AppShell {
$response = $this->in($message, null, rtrim($this->_paths[0], DS) . DS . 'Locale');
if (strtoupper($response) === 'Q') {
$this->out(__d('cake_console', 'Extract Aborted'));
$this->_stop();
return $this->_stop();
} elseif ($this->_isPathUsable($response)) {
$this->_output = $response . DS;
break;

View file

@ -681,7 +681,7 @@ class ModelTask extends BakeTask {
$prompt = "{$model->name} {$type} {$assoc['alias']}?";
$response = $this->in($prompt, array('y', 'n'), 'y');
if ('n' == strtolower($response)) {
if (strtolower($response) === 'n') {
unset($associations[$type][$i]);
} elseif ($type === 'hasMany') {
unset($associations['hasOne'][$i]);
@ -938,7 +938,7 @@ class ModelTask extends BakeTask {
}
if (empty($tables)) {
$this->err(__d('cake_console', 'Your database does not have any tables.'));
$this->_stop();
return $this->_stop();
}
return $tables;
}
@ -960,7 +960,7 @@ class ModelTask extends BakeTask {
if ($enteredModel === 'q') {
$this->out(__d('cake_console', 'Exit'));
$this->_stop();
return $this->_stop();
}
if (!$enteredModel || intval($enteredModel) > count($this->_modelNames)) {

View file

@ -65,9 +65,8 @@ class PluginTask extends AppShell {
$this->out(__d('cake_console', 'Plugin: %s already exists, no action taken', $plugin));
$this->out(__d('cake_console', 'Path: %s', $pluginPath));
return false;
} else {
$this->_interactive($plugin);
}
$this->_interactive($plugin);
} else {
return $this->_interactive();
}

View file

@ -368,12 +368,9 @@ class ProjectTask extends AppShell {
if ($File->write($result)) {
Configure::write('Routing.prefixes', array($name));
return true;
} else {
return false;
}
} else {
return false;
}
return false;
}
/**
@ -417,7 +414,7 @@ class ProjectTask extends AppShell {
$this->out(__d('cake_console', 'You need to enable %s in %s to use prefix routing.',
'Configure::write(\'Routing.prefixes\', array(\'admin\'))',
'/app/Config/core.php'));
$this->_stop();
return $this->_stop();
}
return $admin . '_';
}

View file

@ -267,7 +267,7 @@ class ViewTask extends BakeTask {
if (!class_exists($controllerClassName)) {
$file = $controllerClassName . '.php';
$this->err(__d('cake_console', "The file '%s' could not be found.\nIn order to bake a view, you'll need to first create the controller.", $file));
$this->_stop();
return $this->_stop();
}
$controllerObj = new $controllerClassName();
$controllerObj->plugin = $this->plugin;
@ -334,10 +334,9 @@ class ViewTask extends BakeTask {
$looksGood = $this->in(__d('cake_console', 'Look okay?'), array('y', 'n'), 'y');
if (strtolower($looksGood) === 'y') {
$this->bake($action, ' ');
$this->_stop();
} else {
$this->out(__d('cake_console', 'Bake Aborted.'));
return $this->_stop();
}
$this->out(__d('cake_console', 'Bake Aborted.'));
}
/**

View file

@ -60,7 +60,7 @@ class ConsoleErrorHandler {
$exception->getMessage(),
$exception->getTraceAsString()
));
$this->_stop($exception->getCode() ? $exception->getCode() : 1);
return $this->_stop($exception->getCode() ? $exception->getCode() : 1);
}
/**
@ -88,7 +88,7 @@ class ConsoleErrorHandler {
}
if ($log === LOG_ERR) {
$this->_stop(1);
return $this->_stop(1);
}
}

View file

@ -547,7 +547,7 @@ class Shell extends Object {
$result = $this->stdin->read();
if ($result === false) {
$this->_stop(1);
return $this->_stop(1);
}
$result = trim($result);
@ -661,7 +661,7 @@ class Shell extends Object {
if (!empty($message)) {
$this->err($message);
}
$this->_stop(1);
return $this->_stop(1);
}
/**
@ -699,7 +699,7 @@ class Shell extends Object {
if (strtolower($key) === 'q') {
$this->out(__d('cake_console', '<error>Quitting</error>.'), 2);
$this->_stop();
return $this->_stop();
} elseif (strtolower($key) !== 'y') {
$this->out(__d('cake_console', 'Skip `%s`', $path), 2);
return false;

View file

@ -65,7 +65,7 @@ class ShellDispatcher {
*/
public static function run($argv) {
$dispatcher = new ShellDispatcher($argv);
$dispatcher->_stop($dispatcher->dispatch() === false ? 1 : 0);
return $dispatcher->_stop($dispatcher->dispatch() === false ? 1 : 0);
}
/**

View file

@ -61,7 +61,7 @@ class FormAuthenticate extends BaseAuthenticate {
/**
* Authenticates the identity contained in a request. Will use the `settings.userModel`, and `settings.fields`
* to find POST data that is used to find a matching record in the `settings.userModel`. Will return false if
* there is no post data, either username or password is missing, of if the scope conditions have not been met.
* there is no post data, either username or password is missing, or if the scope conditions have not been met.
*
* @param CakeRequest $request The request that contains login information.
* @param CakeResponse $response Unused response object.

View file

@ -250,15 +250,13 @@ class Scaffold {
$success
);
return $this->_sendMessage($message);
} else {
}
return $this->controller->afterScaffoldSaveError($action);
}
} else {
if ($this->_validSession) {
$this->controller->Session->setFlash(__d('cake', 'Please correct errors below.'));
}
}
}
if (empty($request->data)) {
if ($this->ScaffoldModel->id) {
@ -309,14 +307,13 @@ class Scaffold {
if ($this->ScaffoldModel->delete()) {
$message = __d('cake', 'The %1$s with id: %2$s has been deleted.', Inflector::humanize($this->modelClass), $id);
return $this->_sendMessage($message);
} else {
}
$message = __d('cake',
'There was an error deleting the %1$s with id: %2$s',
Inflector::humanize($this->modelClass),
$id
);
return $this->_sendMessage($message);
}
} elseif ($this->controller->scaffoldError('delete') === false) {
return $this->_scaffoldError();
}

View file

@ -535,6 +535,9 @@ class App {
if (!isset(self::$_classMap[$className])) {
return false;
}
if (strpos($className, '..') !== false) {
return false;
}
$parts = explode('.', self::$_classMap[$className], 2);
list($plugin, $package) = count($parts) > 1 ? $parts : array(null, current($parts));

View file

@ -219,7 +219,7 @@ class ErrorHandler {
'path' => Debugger::trimPath($file)
);
return Debugger::getInstance()->outputError($data);
} else {
}
$message = $error . ' (' . $code . '): ' . $description . ' in [' . $file . ', line ' . $line . ']';
if (!empty($errorConfig['trace'])) {
$trace = Debugger::trace(array('start' => 1, 'format' => 'log'));
@ -227,7 +227,6 @@ class ErrorHandler {
}
return CakeLog::write($log, $message);
}
}
/**
* Generate an error page when some fatal error happens.

View file

@ -822,7 +822,7 @@ class TreeBehavior extends ModelBehavior {
array($Model->escapeField() => $id)
);
return $Model->delete($id);
} else {
}
$edge = $this->_getMax($Model, $scope, $right, $recursive);
if ($node[$right] == $edge) {
$edge = $edge - 2;
@ -833,7 +833,6 @@ class TreeBehavior extends ModelBehavior {
array('callbacks' => false, 'validate' => false)
);
}
}
/**
* Check if the current tree is valid.

View file

@ -200,7 +200,7 @@ class Mysql extends DboSource {
if (!$result) {
$result->closeCursor();
return array();
} else {
}
$tables = array();
while ($line = $result->fetch(PDO::FETCH_NUM)) {
@ -211,7 +211,6 @@ class Mysql extends DboSource {
parent::listSources($tables);
return $tables;
}
}
/**
* Builds a map of the columns contained in a result
@ -684,7 +683,7 @@ class Mysql extends DboSource {
if (!$result) {
$result->closeCursor();
return array();
} else {
}
$tables = array();
foreach ($result as $row) {
$tables[$row['Name']] = (array)$row;
@ -702,7 +701,6 @@ class Mysql extends DboSource {
}
return $tables;
}
}
/**
* Converts database-layer column types to basic types

View file

@ -305,9 +305,8 @@ class Postgres extends DboSource {
}
if (isset($this->_sequenceMap[$table][$field])) {
return $this->_sequenceMap[$table][$field];
} else {
return "{$table}_{$field}_seq";
}
return "{$table}_{$field}_seq";
}
/**
@ -760,15 +759,13 @@ class Postgres extends DboSource {
break;
default:
$resultRow[$table][$column] = $row[$index];
break;
}
}
return $resultRow;
} else {
}
$this->_result->closeCursor();
return false;
}
}
/**
* Translates between PHP boolean values and PostgreSQL boolean values
@ -793,7 +790,6 @@ class Postgres extends DboSource {
break;
default:
$result = (bool)$data;
break;
}
if ($quote) {

View file

@ -362,11 +362,10 @@ class Sqlite extends DboSource {
}
}
return $resultRow;
} else {
}
$this->_result->closeCursor();
return false;
}
}
/**
* Returns a limit statement in the correct format for the particular database.

View file

@ -172,7 +172,7 @@ class Sqlserver extends DboSource {
if (!$result) {
$result->closeCursor();
return array();
} else {
}
$tables = array();
while ($line = $result->fetch(PDO::FETCH_NUM)) {
@ -183,7 +183,6 @@ class Sqlserver extends DboSource {
parent::listSources($tables);
return $tables;
}
}
/**
* Returns an array of the fields in given table name.
@ -318,9 +317,8 @@ class Sqlserver extends DboSource {
$result[] = $prepend . $fields[$i];
}
return $result;
} else {
return $fields;
}
return $fields;
}
/**
@ -539,10 +537,8 @@ class Sqlserver extends DboSource {
";
} elseif (strpos($limit, 'FETCH') !== false) {
return "SELECT {$fields} FROM {$table} {$alias} {$joins} {$conditions} {$group} {$order} {$limit}";
} else {
return "SELECT {$limit} {$fields} FROM {$table} {$alias} {$joins} {$conditions} {$group} {$order}";
}
break;
return "SELECT {$limit} {$fields} FROM {$table} {$alias} {$joins} {$conditions} {$group} {$order}";
case "schema":
extract($data);

View file

@ -592,13 +592,12 @@ class DboSource extends DataSource {
$recursive = $params[5 + $off];
}
return $args[2]->find('all', compact('conditions', 'fields', 'order', 'limit', 'page', 'recursive'));
} else {
}
if (isset($params[3 + $off])) {
$recursive = $params[3 + $off];
}
return $args[2]->find('first', compact('conditions', 'fields', 'order', 'recursive'));
}
} else {
if (isset($args[1]) && $args[1] === true) {
return $this->fetchAll($args[0], true);
} elseif (isset($args[1]) && !is_array($args[1])) {
@ -612,7 +611,6 @@ class DboSource extends DataSource {
return $this->fetchAll($args[0], $args[1], array('cache' => $cache));
}
}
}
/**
* Returns a row from current resultset as an array
@ -632,9 +630,8 @@ class DboSource extends DataSource {
$this->fetchVirtualField($resultRow);
}
return $resultRow;
} else {
return null;
}
return null;
}
/**

View file

@ -1255,11 +1255,11 @@ class Model extends Object implements CakeEventListener {
isset($data['meridian']) &&
!empty($data['hour']) &&
$data['hour'] != 12 &&
'pm' == $data['meridian']
$data['meridian'] === 'pm'
) {
$data['hour'] = $data['hour'] + 12;
}
if (isset($data['hour']) && isset($data['meridian']) && $data['hour'] == 12 && 'am' == $data['meridian']) {
if (isset($data['hour']) && isset($data['meridian']) && $data['hour'] == 12 && $data['meridian'] === 'am') {
$data['hour'] = '00';
}
if ($type === 'time') {

View file

@ -123,7 +123,7 @@ class Permission extends AppModel {
if (empty($perms)) {
continue;
} else {
}
$perms = Hash::extract($perms, '{n}.' . $this->alias);
foreach ($perms as $perm) {
if ($action === '*') {
@ -153,7 +153,6 @@ class Permission extends AppModel {
}
}
}
}
return false;
}

View file

@ -148,9 +148,8 @@ class CakeValidationRule {
if (in_array($this->required, array('create', 'update'), true)) {
if ($this->required === 'create' && !$this->isUpdate() || $this->required === 'update' && $this->isUpdate()) {
return true;
} else {
return false;
}
return false;
}
return $this->required;

View file

@ -257,7 +257,15 @@ class CakeRequest implements ArrayAccess {
list($uri) = explode('?', $uri, 2);
}
if (empty($uri) || $uri === '/' || $uri === '//' || $uri === '/index.php') {
return '/';
$uri = '/';
}
$endsWithIndex = '/webroot/index.php';
$endsWithLength = strlen($endsWithIndex);
if (
strlen($uri) >= $endsWithLength &&
substr($uri, -$endsWithLength) === $endsWithIndex
) {
$uri = '/';
}
return $uri;
}
@ -265,7 +273,12 @@ class CakeRequest implements ArrayAccess {
/**
* Returns a base URL and sets the proper webroot
*
* If CakePHP is called with index.php in the URL even though
* URL Rewriting is activated (and thus not needed) it swallows
* the unnecessary part from $base to prevent issue #3318.
*
* @return string Base URL
* @link https://cakephp.lighthouseapp.com/projects/42648-cakephp/tickets/3318
*/
protected function _base() {
$dir = $webroot = null;
@ -283,6 +296,10 @@ class CakeRequest implements ArrayAccess {
if (!$baseUrl) {
$base = dirname(env('PHP_SELF'));
$indexPos = strpos($base, '/webroot/index.php');
if ($indexPos !== false) {
$base = substr($base, 0, $indexPos) . '/webroot';
}
if ($webroot === 'webroot' && $webroot === basename($base)) {
$base = dirname($base);
}
@ -295,6 +312,7 @@ class CakeRequest implements ArrayAccess {
}
$base = implode('/', array_map('rawurlencode', explode('/', $base)));
$this->webroot = $base . '/';
return $this->base = $base;
}

View file

@ -382,11 +382,10 @@ class CakeSocket {
if ($enableCryptoResult === true) {
$this->encrypted = $enable;
return true;
} else {
}
$errorMessage = __d('cake_dev', 'Unable to perform enableCrypto operation on CakeSocket');
$this->setLastError(null, $errorMessage);
throw new SocketException($errorMessage);
}
}
}

View file

@ -1092,8 +1092,6 @@ class CakeEmail {
$content = implode("\n", $content) . "\n";
}
$this->_textMessage = $this->_htmlMessage = '';
$this->_createBoundary();
$this->_message = $this->_render($this->_wrap($content));
$contents = $this->transportClass()->send($this);
@ -1477,9 +1475,12 @@ class CakeEmail {
* @return array Email body ready to be sent
*/
protected function _render($content) {
$this->_textMessage = $this->_htmlMessage = '';
$content = implode("\n", $content);
$rendered = $this->_renderTemplates($content);
$this->_createBoundary();
$msg = array();
$contentIds = array_filter((array)Hash::extract($this->_attachments, '{s}.contentId'));
@ -1649,9 +1650,8 @@ class CakeEmail {
$charset = strtoupper($this->charset);
if (array_key_exists($charset, $this->_contentTypeCharset)) {
return strtoupper($this->_contentTypeCharset[$charset]);
} else {
return strtoupper($this->charset);
}
return strtoupper($this->charset);
}
}

View file

@ -87,9 +87,8 @@ class AclPerson extends CakeTestModel {
}
if (!$motherId) {
return null;
} else {
return array('AclPerson' => array('id' => $motherId));
}
return array('AclPerson' => array('id' => $motherId));
}
}

View file

@ -3672,12 +3672,11 @@ class ContainableBehaviorTest extends CakeTestCase {
if (!is_array($Model)) {
$result = $Model->containments($contain);
return $this->_containments($result['models']);
} else {
}
$result = $Model;
foreach ($result as $i => $containment) {
$result[$i] = array_diff_key($containment, array('instance' => true));
}
}
return $result;
}

View file

@ -29,6 +29,12 @@ App::uses('CakeRequest', 'Network');
*/
class TestCakeRequest extends CakeRequest {
/**
* reConstruct method
*
* @param string $url
* @param bool $parseEnvironment
*/
public function reConstruct($url = 'some/path', $parseEnvironment = true) {
$this->_base();
if (empty($url)) {
@ -49,10 +55,13 @@ class TestCakeRequest extends CakeRequest {
}
/**
* Class CakeRequestTest
*/
class CakeRequestTest extends CakeTestCase {
/**
* setup callback
* Setup callback
*
* @return void
*/
@ -69,7 +78,7 @@ class CakeRequestTest extends CakeTestCase {
}
/**
* tearDown
* TearDown
*
* @return void
*/
@ -82,7 +91,7 @@ class CakeRequestTest extends CakeTestCase {
}
/**
* test that the autoparse = false constructor works.
* Test that the autoparse = false constructor works.
*
* @return void
*/
@ -95,7 +104,7 @@ class CakeRequestTest extends CakeTestCase {
}
/**
* test construction
* Test construction
*
* @return void
*/
@ -153,7 +162,7 @@ class CakeRequestTest extends CakeTestCase {
}
/**
* test addParams() method
* Test addParams() method
*
* @return void
*/
@ -170,7 +179,7 @@ class CakeRequestTest extends CakeTestCase {
}
/**
* test splicing in paths.
* Test splicing in paths.
*
* @return void
*/
@ -190,7 +199,7 @@ class CakeRequestTest extends CakeTestCase {
}
/**
* test parsing POST data into the object.
* Test parsing POST data into the object.
*
* @return void
*/
@ -241,7 +250,7 @@ class CakeRequestTest extends CakeTestCase {
}
/**
* test parsing PUT data into the object.
* Test parsing PUT data into the object.
*
* @return void
*/
@ -315,7 +324,7 @@ class CakeRequestTest extends CakeTestCase {
}
/**
* test parsing json PUT data into the object.
* Test parsing json PUT data into the object.
*
* @return void
*/
@ -332,7 +341,7 @@ class CakeRequestTest extends CakeTestCase {
}
/**
* test parsing of FILES array
* Test parsing of FILES array
*
* @return void
*/
@ -621,7 +630,7 @@ class CakeRequestTest extends CakeTestCase {
}
/**
* test method overrides coming in from POST data.
* Test method overrides coming in from POST data.
*
* @return void
*/
@ -640,7 +649,7 @@ class CakeRequestTest extends CakeTestCase {
}
/**
* test the clientIp method.
* Test the clientIp method.
*
* @return void
*/
@ -663,7 +672,7 @@ class CakeRequestTest extends CakeTestCase {
}
/**
* test the referer function.
* Test the referrer function.
*
* @return void
*/
@ -782,7 +791,7 @@ class CakeRequestTest extends CakeTestCase {
}
/**
* test the method() method.
* Test the method() method.
*
* @return void
*/
@ -794,7 +803,7 @@ class CakeRequestTest extends CakeTestCase {
}
/**
* test host retrieval.
* Test host retrieval.
*
* @return void
*/
@ -806,7 +815,7 @@ class CakeRequestTest extends CakeTestCase {
}
/**
* test domain retrieval.
* Test domain retrieval.
*
* @return void
*/
@ -821,7 +830,7 @@ class CakeRequestTest extends CakeTestCase {
}
/**
* test getting subdomains for a host.
* Test getting subdomains for a host.
*
* @return void
*/
@ -842,7 +851,7 @@ class CakeRequestTest extends CakeTestCase {
}
/**
* test ajax, flash and friends
* Test ajax, flash and friends
*
* @return void
*/
@ -876,7 +885,7 @@ class CakeRequestTest extends CakeTestCase {
}
/**
* test __call expcetions
* Test __call exceptions
*
* @expectedException CakeException
* @return void
@ -887,7 +896,7 @@ class CakeRequestTest extends CakeTestCase {
}
/**
* test is(ssl)
* Test is(ssl)
*
* @return void
*/
@ -920,7 +929,7 @@ class CakeRequestTest extends CakeTestCase {
}
/**
* test getting request params with object properties.
* Test getting request params with object properties.
*
* @return void
*/
@ -955,7 +964,7 @@ class CakeRequestTest extends CakeTestCase {
}
/**
* test the array access implementation
* Test the array access implementation
*
* @return void
*/
@ -986,7 +995,7 @@ class CakeRequestTest extends CakeTestCase {
}
/**
* test adding detectors and having them work.
* Test adding detectors and having them work.
*
* @return void
*/
@ -1043,16 +1052,17 @@ class CakeRequestTest extends CakeTestCase {
}
/**
* helper function for testing callbacks.
* Helper function for testing callbacks.
*
* @return void
* @param $request
* @return bool
*/
public function detectCallback($request) {
return (bool)$request->return;
}
/**
* test getting headers
* Test getting headers
*
* @return void
*/
@ -1066,7 +1076,7 @@ class CakeRequestTest extends CakeTestCase {
}
/**
* test accepts() with and without parameters
* Test accepts() with and without parameters
*
* @return void
*/
@ -1151,7 +1161,7 @@ class CakeRequestTest extends CakeTestCase {
}
/**
* testBaseUrlAndWebrootWithModRewrite method
* Test baseUrl and webroot with ModRewrite
*
* @return void
*/
@ -1220,7 +1230,7 @@ class CakeRequestTest extends CakeTestCase {
}
/**
* testBaseUrlwithModRewriteAlias method
* Test baseUrl with ModRewrite alias
*
* @return void
*/
@ -1248,7 +1258,71 @@ class CakeRequestTest extends CakeTestCase {
}
/**
* test base, webroot, and url parsing when there is no url rewriting
* Test base, webroot, url and here parsing when there is url rewriting but
* CakePHP gets called with index.php in url nonetheless.
*
* Tests uri with
* - index.php/
* - index.php/
* - index.php/apples/
* - index.php/bananas/eat/tasty_banana
*
* @link https://cakephp.lighthouseapp.com/projects/42648-cakephp/tickets/3318
*/
public function testBaseUrlWithModRewriteAndIndexPhp() {
$_SERVER['REQUEST_URI'] = '/cakephp/app/webroot/index.php';
$_SERVER['PHP_SELF'] = '/cakephp/app/webroot/index.php';
unset($_SERVER['PATH_INFO']);
$request = new CakeRequest();
$this->assertEquals('/cakephp', $request->base);
$this->assertEquals('/cakephp/', $request->webroot);
$this->assertEquals('', $request->url);
$this->assertEquals('/cakephp/', $request->here);
$_SERVER['REQUEST_URI'] = '/cakephp/app/webroot/index.php/';
$_SERVER['PHP_SELF'] = '/cakephp/app/webroot/index.php/';
$_SERVER['PATH_INFO'] = '/';
$request = new CakeRequest();
$this->assertEquals('/cakephp', $request->base);
$this->assertEquals('/cakephp/', $request->webroot);
$this->assertEquals('', $request->url);
$this->assertEquals('/cakephp/', $request->here);
$_SERVER['REQUEST_URI'] = '/cakephp/app/webroot/index.php/apples';
$_SERVER['PHP_SELF'] = '/cakephp/app/webroot/index.php/apples';
$_SERVER['PATH_INFO'] = '/apples';
$request = new CakeRequest();
$this->assertEquals('/cakephp', $request->base);
$this->assertEquals('/cakephp/', $request->webroot);
$this->assertEquals('apples', $request->url);
$this->assertEquals('/cakephp/apples', $request->here);
$_SERVER['REQUEST_URI'] = '/cakephp/app/webroot/index.php/melons/share/';
$_SERVER['PHP_SELF'] = '/cakephp/app/webroot/index.php/melons/share/';
$_SERVER['PATH_INFO'] = '/melons/share/';
$request = new CakeRequest();
$this->assertEquals('/cakephp', $request->base);
$this->assertEquals('/cakephp/', $request->webroot);
$this->assertEquals('melons/share/', $request->url);
$this->assertEquals('/cakephp/melons/share/', $request->here);
$_SERVER['REQUEST_URI'] = '/cakephp/app/webroot/index.php/bananas/eat/tasty_banana';
$_SERVER['PHP_SELF'] = '/cakephp/app/webroot/index.php/bananas/eat/tasty_banana';
$_SERVER['PATH_INFO'] = '/bananas/eat/tasty_banana';
$request = new CakeRequest();
$this->assertEquals('/cakephp', $request->base);
$this->assertEquals('/cakephp/', $request->webroot);
$this->assertEquals('bananas/eat/tasty_banana', $request->url);
$this->assertEquals('/cakephp/bananas/eat/tasty_banana', $request->here);
}
/**
* Test base, webroot, and url parsing when there is no url rewriting
*
* @return void
*/
@ -1272,7 +1346,7 @@ class CakeRequestTest extends CakeTestCase {
}
/**
* testBaseUrlAndWebrootWithBaseUrl method
* Test baseUrl and webroot with baseUrl
*
* @return void
*/
@ -1321,7 +1395,7 @@ class CakeRequestTest extends CakeTestCase {
}
/**
* test baseUrl with no rewrite and using the top level index.php.
* Test baseUrl with no rewrite and using the top level index.php.
*
* @return void
*/
@ -1359,7 +1433,7 @@ class CakeRequestTest extends CakeTestCase {
}
/**
* test baseUrl with no rewrite, and using the app/webroot/index.php file as is normal with virtual hosts.
* Test baseUrl with no rewrite, and using the app/webroot/index.php file as is normal with virtual hosts.
*
* @return void
*/
@ -1405,9 +1479,9 @@ class CakeRequestTest extends CakeTestCase {
}
/**
* generator for environment configurations
* Generator for environment configurations
*
* @return void
* @return array Environment array
*/
public static function environmentGenerator() {
return array(
@ -1779,9 +1853,12 @@ class CakeRequestTest extends CakeTestCase {
}
/**
* testEnvironmentDetection method
* Test environment detection
*
* @dataProvider environmentGenerator
* @param $name
* @param $env
* @param $expected
* @return void
*/
public function testEnvironmentDetection($name, $env, $expected) {
@ -1798,7 +1875,7 @@ class CakeRequestTest extends CakeTestCase {
}
/**
* test the query() method
* Test the query() method
*
* @return void
*/
@ -1816,7 +1893,7 @@ class CakeRequestTest extends CakeTestCase {
}
/**
* test the query() method with arrays passed via $_GET
* Test the query() method with arrays passed via $_GET
*
* @return void
*/
@ -1857,7 +1934,7 @@ class CakeRequestTest extends CakeTestCase {
}
/**
* test the data() method reading
* Test the data() method reading
*
* @return void
*/
@ -1876,7 +1953,7 @@ class CakeRequestTest extends CakeTestCase {
}
/**
* test writing with data()
* Test writing with data()
*
* @return void
*/
@ -1898,7 +1975,7 @@ class CakeRequestTest extends CakeTestCase {
}
/**
* test writing falsey values.
* Test writing falsey values.
*
* @return void
*/
@ -1919,7 +1996,7 @@ class CakeRequestTest extends CakeTestCase {
}
/**
* test accept language
* Test accept language
*
* @return void
*/
@ -1962,7 +2039,7 @@ class CakeRequestTest extends CakeTestCase {
}
/**
* test the here() method
* Test the here() method
*
* @return void
*/
@ -2065,7 +2142,7 @@ XML;
}
/**
* TestOnlyAllow
* Test onlyAllow method
*
* @return void
*/
@ -2080,7 +2157,7 @@ XML;
}
/**
* TestOnlyAllow throwing exception
* Test onlyAllow throwing exception
*
*/
public function testOnlyAllowException() {

View file

@ -65,6 +65,14 @@ class TestCakeEmail extends CakeEmail {
return $this->_encode($text);
}
/**
* Render to protected method
*
*/
public function render($content) {
return $this->_render($content);
}
}
/*
@ -1578,6 +1586,22 @@ class CakeEmailTest extends CakeTestCase {
$this->assertSame($expected, $result);
}
/**
* testRender method
*
* @return void
*/
public function testRenderWithLayoutAndAttachment() {
$this->CakeEmail->emailFormat('html');
$this->CakeEmail->template('html', 'default');
$this->CakeEmail->attachments(array(CAKE . 'basics.php'));
$result = $this->CakeEmail->render(array());
$this->assertNotEmpty($result);
$result = $this->CakeEmail->getBoundary();
$this->assertNotEmpty($result);
}
/**
* testConstructWithConfigArray method
*

View file

@ -122,9 +122,8 @@ class CakeTestSuiteCommand extends PHPUnit_TextUI_Command {
exit(PHPUnit_TextUI_TestRunner::SUCCESS_EXIT);
} elseif (!isset($result) || $result->errorCount() > 0) {
exit(PHPUnit_TextUI_TestRunner::EXCEPTION_EXIT);
} else {
exit(PHPUnit_TextUI_TestRunner::FAILURE_EXIT);
}
exit(PHPUnit_TextUI_TestRunner::FAILURE_EXIT);
}
}

View file

@ -50,7 +50,6 @@ class CakeTestModel extends Model {
break;
default:
$queryData['order'] = array($this->alias . '.' . $this->primaryKey => 'ASC');
break;
}
return $queryData;
}

View file

@ -97,14 +97,13 @@ class CakeTime {
*
* @param string $name Variable name
* @param mixes $value Variable value
* @return void
*/
public function __set($name, $value) {
switch ($name) {
case 'niceFormat':
self::${$name} = $value;
break;
default:
break;
}
}

View file

@ -516,13 +516,12 @@ class Folder {
umask($old);
$this->_messages[] = __d('cake_dev', '%s created', $pathname);
return true;
} else {
}
umask($old);
$this->_errors[] = __d('cake_dev', '%s NOT created', $pathname);
return false;
}
}
}
return false;
}
@ -810,9 +809,8 @@ class Folder {
if (!empty($newparts)) {
array_pop($newparts);
continue;
} else {
return false;
}
return false;
}
$newparts[] = $part;
}

View file

@ -54,7 +54,6 @@ class Hash {
} else {
return null;
}
}
return $data;
}

View file

@ -334,7 +334,6 @@ class Inflector {
}
}
self::${$var}['rules'] = $rules + self::${$var}['rules'];
break;
}
}

View file

@ -255,7 +255,6 @@ class Validation {
break;
default:
self::$errors[] = __d('cake_dev', 'You must define the $operator parameter for Validation::comparison()');
break;
}
return false;
}
@ -822,9 +821,8 @@ class Validation {
protected static function _check($check, $regex) {
if (is_string($regex) && preg_match($regex, $check)) {
return true;
} else {
return false;
}
return false;
}
/**

View file

@ -665,15 +665,13 @@ class Helper extends Object {
break;
default:
$name = 'data[' . implode('][', $this->entity()) . ']';
break;
}
if (is_array($options)) {
$options[$key] = $name;
return $options;
} else {
return $name;
}
return $name;
}
/**
@ -729,9 +727,8 @@ class Helper extends Object {
if (is_array($options)) {
$options[$key] = $result;
return $options;
} else {
return $result;
}
return $result;
}
/**
@ -920,7 +917,7 @@ class Helper extends Object {
do {
$oldstring = $this->_cleaned;
$this->_cleaned = preg_replace('#</*(applet|meta|xml|blink|link|style|script|embed|object|iframe|frame|frameset|ilayer|layer|bgsound|title|base)[^>]*>#i', "", $this->_cleaned);
} while ($oldstring != $this->_cleaned);
} while ($oldstring !== $this->_cleaned);
$this->_cleaned = str_replace(array("&amp;", "&lt;", "&gt;"), array("&amp;amp;", "&amp;lt;", "&amp;gt;"), $this->_cleaned);
}

View file

@ -205,9 +205,8 @@ class FormHelper extends AppHelper {
return $this->fieldset[$model]['fields'];
} elseif (isset($this->fieldset[$model]['fields'][$field])) {
return $this->fieldset[$model]['fields'][$field];
} else {
return isset($object->hasAndBelongsToMany[$field]) ? array('type' => 'multiple') : null;
}
return isset($object->hasAndBelongsToMany[$field]) ? array('type' => 'multiple') : null;
}
if ($key === 'errors' && !isset($this->validationErrors[$model])) {
@ -232,12 +231,11 @@ class FormHelper extends AppHelper {
if ($key === 'validates') {
if (empty($field)) {
return $this->fieldset[$model]['validates'];
} else {
}
return isset($this->fieldset[$model]['validates'][$field]) ?
$this->fieldset[$model]['validates'] : null;
}
}
}
/**
* Returns if a field is required to be filled based on validation properties from the validating object.
@ -420,7 +418,6 @@ class FormHelper extends AppHelper {
));
default:
$htmlAttributes['method'] = 'post';
break;
}
$this->requestType = strtolower($options['type']);
@ -734,9 +731,8 @@ class FormHelper extends AppHelper {
$tag = is_string($options['wrap']) ? $options['wrap'] : 'div';
unset($options['wrap']);
return $this->Html->tag($tag, $error, $options);
} else {
return $error;
}
return $error;
}
/**
@ -2581,9 +2577,8 @@ class FormHelper extends AppHelper {
if (is_array($options)) {
$options[$key] = $name;
return $options;
} else {
return $name;
}
return $name;
}
return parent::_name($options, $field, $key);
}

View file

@ -289,9 +289,8 @@ class HtmlHelper extends AppHelper {
if (empty($options['block'])) {
return $out;
} else {
$this->_View->append($options['block'], $out);
}
$this->_View->append($options['block'], $out);
}
/**
@ -473,9 +472,8 @@ class HtmlHelper extends AppHelper {
if (empty($options['block'])) {
return $out;
} else {
$this->_View->append($options['block'], $out);
}
$this->_View->append($options['block'], $out);
}
/**
@ -696,9 +694,8 @@ class HtmlHelper extends AppHelper {
}
}
return implode($separator, $out);
} else {
return null;
}
return null;
}
/**

View file

@ -165,7 +165,6 @@ abstract class JsBaseEngineHelper extends AppHelper {
if ($quoteString) {
$val = '"' . $val . '"';
}
break;
}
return $val;
}

View file

@ -507,7 +507,7 @@ class PaginatorHelper extends AppHelper {
}
$link = $this->link($title, $url, compact('escape', 'model') + $options);
return $this->Html->tag($tag, $link, compact('class'));
} else {
}
unset($options['rel']);
if (!$tag) {
if ($disabledTag) {
@ -523,7 +523,6 @@ class PaginatorHelper extends AppHelper {
}
return $this->Html->tag($tag, $title, compact('escape', 'class') + $options);
}
}
/**
* Returns true if the given result set is not at the first page
@ -664,7 +663,6 @@ class PaginatorHelper extends AppHelper {
'{:page}', '{:pages}', '{:current}', '{:count}', '{:start}', '{:end}', '{:model}'
);
$out = str_replace($newKeys, array_values($map), $out);
break;
}
return $out;
}

View file

@ -78,7 +78,6 @@ class TimeHelper extends AppHelper {
break;
default:
$this->{$name} = $value;
break;
}
}

View file

@ -564,9 +564,8 @@ class View extends Object {
//@codingStandardsIgnoreEnd
unset($out);
return false;
} else {
return substr($out, strlen($match[0]));
}
return substr($out, strlen($match[0]));
}
}

View file

@ -480,7 +480,7 @@ if (!function_exists('clearCache')) {
}
}
return true;
} else {
}
$cache = array(
CACHE . $type . DS . '*' . $params . $ext,
CACHE . $type . DS . '*' . $params . '_*' . $ext
@ -503,7 +503,7 @@ if (!function_exists('clearCache')) {
}
}
return true;
}
} elseif (is_array($params)) {
foreach ($params as $file) {
clearCache($file, $type, $ext);