Merge branch '2.0' into 2.1

Conflicts:
	lib/Cake/Config/config.php
	lib/Cake/Console/Command/Task/ModelTask.php
	lib/Cake/Console/Command/TestsuiteShell.php
	lib/Cake/Model/CakeSchema.php
	lib/Cake/Model/Datasource/Database/Sqlite.php
	lib/Cake/Test/Case/Model/ModelTestBase.php
	lib/Cake/Test/Case/Routing/DispatcherTest.php
	lib/Cake/Test/Case/Utility/FileTest.php
	lib/Cake/VERSION.txt
This commit is contained in:
mark_story 2011-12-03 13:45:28 -05:00
commit 6d269ce25d
168 changed files with 1504 additions and 765 deletions

View file

@ -24,7 +24,7 @@ App::uses('Debugger', 'Utility');
<p>For updates and important announcements, visit http://cakefest.org</p>
</iframe>
<h2><?php echo __d('cake_dev', 'Release Notes for CakePHP %s.', Configure::version()); ?></h2>
<a href="http://cakephp.org/changelogs/2.0.3"><?php __d('cake_dev', 'Read the changelog'); ?> </a>
<a href="http://cakephp.org/changelogs/2.0.4"><?php __d('cake_dev', 'Read the changelog'); ?> </a>
<?php
if (Configure::read('debug') > 0):
Debugger::checkSecurityKeys();

View file

@ -285,7 +285,7 @@ class Cache {
$settings = self::settings($config);
if (empty($settings)) {
return null;
return false;
}
if (!self::isInitialized($config)) {
return false;
@ -335,7 +335,7 @@ class Cache {
$settings = self::settings($config);
if (empty($settings)) {
return null;
return false;
}
if (!self::isInitialized($config)) {
return false;
@ -360,7 +360,7 @@ class Cache {
$settings = self::settings($config);
if (empty($settings)) {
return null;
return false;
}
if (!self::isInitialized($config)) {
return false;
@ -387,7 +387,7 @@ class Cache {
$settings = self::settings($config);
if (empty($settings)) {
return null;
return false;
}
if (!self::isInitialized($config)) {
return false;
@ -422,7 +422,7 @@ class Cache {
$settings = self::settings($config);
if (empty($settings)) {
return null;
return false;
}
if (!self::isInitialized($config)) {
return false;
@ -505,7 +505,7 @@ abstract class CacheEngine {
*/
public function init($settings = array()) {
$this->settings = array_merge(
array('prefix' => 'cake_', 'duration'=> 3600, 'probability'=> 100),
array('prefix' => 'cake_', 'duration' => 3600, 'probability' => 100),
$this->settings,
$settings
);

View file

@ -66,8 +66,8 @@ class FileEngine extends CacheEngine {
public function init($settings = array()) {
parent::init(array_merge(
array(
'engine' => 'File', 'path' => CACHE, 'prefix'=> 'cake_', 'lock'=> true,
'serialize'=> true, 'isWindows' => false, 'mask' => 0664
'engine' => 'File', 'path' => CACHE, 'prefix' => 'cake_', 'lock' => true,
'serialize' => true, 'isWindows' => false, 'mask' => 0664
),
$settings
));
@ -84,7 +84,7 @@ class FileEngine extends CacheEngine {
/**
* Garbage collection. Permanently remove all expired and deleted data
*
* @return boolean True if garbage collection was succesful, false on failure
* @return boolean True if garbage collection was successful, false on failure
*/
public function gc() {
return $this->clear(true);
@ -273,7 +273,7 @@ class FileEngine extends CacheEngine {
/**
* Sets the current cache key this class is managing, and creates a writable SplFileObject
* for the cache file the key is refering to.
* for the cache file the key is referring to.
*
* @param string $key The key
* @param boolean $createKey Whether the key should be created if it doesn't exists, or not

View file

@ -59,10 +59,10 @@ class MemcacheEngine extends CacheEngine {
return false;
}
parent::init(array_merge(array(
'engine'=> 'Memcache',
'engine' => 'Memcache',
'prefix' => Inflector::slug(APP_DIR) . '_',
'servers' => array('127.0.0.1'),
'compress'=> false,
'compress' => false,
'persistent' => true
), $settings)
);

View file

@ -15,6 +15,8 @@
* @since CakePHP(tm) v 1.2.0.5012
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::uses('AppShell', 'Console/Command');
App::uses('ComponentCollection', 'Controller');
App::uses('AclComponent', 'Controller/Component');
App::uses('DbAcl', 'Model');
@ -25,7 +27,7 @@ App::uses('DbAcl', 'Model');
*
* @package Cake.Console.Command
*/
class AclShell extends Shell {
class AclShell extends AppShell {
/**
* Contains instance of AclComponent

View file

@ -17,6 +17,8 @@
* @since CakePHP(tm) v 1.2.0.5012
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::uses('AppShell', 'Console/Command');
App::uses('File', 'Utility');
/**
@ -24,7 +26,7 @@ App::uses('File', 'Utility');
*
* @package Cake.Console.Command
*/
class ApiShell extends Shell {
class ApiShell extends AppShell {
/**
* Map between short name for paths and real paths.

View file

@ -16,6 +16,8 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::uses('Shell', 'Console');
/**
* This is a placeholder class.
* Create the same file in app/Console/Command/AppShell.php

View file

@ -20,6 +20,7 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::uses('AppShell', 'Console/Command');
App::uses('Model', 'Model');
/**
@ -28,7 +29,7 @@ App::uses('Model', 'Model');
* @package Cake.Console.Command
* @link http://book.cakephp.org/2.0/en/console-and-shells/code-generation-with-bake.html
*/
class BakeShell extends Shell {
class BakeShell extends AppShell {
/**
* Contains tasks to load and instantiate
@ -184,7 +185,7 @@ class BakeShell extends Shell {
}
App::uses($controller . 'Controller', 'Controller');
if (class_exists($controller . 'Controller')) {
$this->View->args = array($controller);
$this->View->args = array($name);
$this->View->execute();
}
$this->out('', 1, Shell::QUIET);

View file

@ -17,6 +17,7 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::uses('AppShell', 'Console/Command');
App::uses('Inflector', 'Utility');
/**
@ -24,7 +25,7 @@ App::uses('Inflector', 'Utility');
*
* @package Cake.Console.Command
*/
class CommandListShell extends Shell {
class CommandListShell extends AppShell {
/**
* startup
@ -80,13 +81,15 @@ class CommandListShell extends Shell {
*/
protected function _getShellList() {
$shellList = array();
$skipFiles = array('AppShell');
$corePath = App::core('Console/Command');
$shells = App::objects('file', $corePath[0]);
$shells = array_diff($shells, $skipFiles);
$shellList = $this->_appendShells('CORE', $shells, $shellList);
$appShells = App::objects('Console/Command', null, false);
$appShells = array_diff($appShells, $shells);
$appShells = array_diff($appShells, $shells, $skipFiles);
$shellList = $this->_appendShells('app', $appShells, $shellList);
$plugins = CakePlugin::loaded();

View file

@ -16,12 +16,14 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::uses('AppShell', 'Console/Command');
/**
* Provides a very basic 'interactive' console for CakePHP apps.
*
* @package Cake.Console.Command
*/
class ConsoleShell extends Shell {
class ConsoleShell extends AppShell {
/**
* Available binding types
@ -86,7 +88,7 @@ class ConsoleShell extends Shell {
$out .= "\n";
$out .= 'To dynamically set associations, you can do the following:';
$out .= "\tModelA bind <association> ModelB";
$out .= "where the supported assocations are hasOne, hasMany, belongsTo, hasAndBelongsToMany";
$out .= "where the supported associations are hasOne, hasMany, belongsTo, hasAndBelongsToMany";
$out .= "\n";
$out .= 'To dynamically remove associations, you can do the following:';
$out .= "\t ModelA unbind <association> ModelB";
@ -115,7 +117,7 @@ class ConsoleShell extends Shell {
$out .= "\n";
$out .= "will return something like the following:";
$out .= "\n";
$out .= "\tarray (";
$out .= "\tarray(";
$out .= "\t [...]";
$out .= "\t 'controller' => 'posts',";
$out .= "\t 'action' => 'view',";

View file

@ -16,12 +16,14 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::uses('AppShell', 'Console/Command');
/**
* Shell for I18N management.
*
* @package Cake.Console.Command
*/
class I18nShell extends Shell {
class I18nShell extends AppShell {
/**
* Contains database source to use

View file

@ -18,6 +18,8 @@
* @since CakePHP(tm) v 1.2.0.5550
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::uses('AppShell', 'Console/Command');
App::uses('File', 'Utility');
App::uses('Folder', 'Utility');
App::uses('CakeSchema', 'Model');
@ -28,7 +30,7 @@ App::uses('CakeSchema', 'Model');
* @package Cake.Console.Command
* @link http://book.cakephp.org/2.0/en/console-and-shells/schema-management-and-migrations.html
*/
class SchemaShell extends Shell {
class SchemaShell extends AppShell {
/**
* Schema class being used.
@ -64,7 +66,7 @@ class SchemaShell extends Shell {
$name = $path = $connection = $plugin = null;
if (!empty($this->params['name'])) {
$name = $this->params['name'];
} elseif (!empty($this->args[0])) {
} elseif (!empty($this->args[0]) && $this->args[0] !== 'snapshot') {
$name = $this->params['name'] = $this->args[0];
}
@ -158,6 +160,7 @@ class SchemaShell extends Shell {
Configure::write('Cache.disable', $cacheDisable);
if ($snapshot === true) {
$fileName = rtrim($this->params['file'], '.php');
$Folder = new Folder($this->Schema->path);
$result = $Folder->read();
@ -169,7 +172,7 @@ class SchemaShell extends Shell {
$count = 0;
if (!empty($result[1])) {
foreach ($result[1] as $file) {
if (preg_match('/schema(?:[_\d]*)?\.php$/', $file)) {
if (preg_match('/'.preg_quote($fileName).'(?:[_\d]*)?\.php$/', $file)) {
$count++;
}
}
@ -181,7 +184,6 @@ class SchemaShell extends Shell {
}
}
$fileName = rtrim($this->params['file'], '.php');
$content['file'] = $fileName . '_' . $count . '.php';
}

View file

@ -16,13 +16,14 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::uses('Shell', 'Console');
App::uses('AppShell', 'Console/Command');
/**
* Base class for Bake Tasks.
*
* @package Cake.Console.Command.Task
*/
class BakeTask extends Shell {
class BakeTask extends AppShell {
/**
* Name of plugin
@ -78,7 +79,7 @@ class BakeTask extends Shell {
* @return void
*/
public function execute() {
foreach($this->args as $i => $arg) {
foreach ($this->args as $i => $arg) {
if (strpos($arg, '.')) {
list($this->params['plugin'], $this->args[$i]) = pluginSplit($arg);
break;

View file

@ -16,6 +16,7 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::uses('AppShell', 'Console/Command');
App::uses('BakeTask', 'Console/Command/Task');
App::uses('AppModel', 'Model');

View file

@ -16,12 +16,14 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::uses('AppShell', 'Console/Command');
/**
* Task class for creating and updating the database configuration file.
*
* @package Cake.Console.Command.Task
*/
class DbConfigTask extends Shell {
class DbConfigTask extends AppShell {
/**
* path to CONFIG directory
@ -37,14 +39,14 @@ class DbConfigTask extends Shell {
*/
protected $_defaultConfig = array(
'name' => 'default',
'datasource'=> 'Database/Mysql',
'persistent'=> 'false',
'host'=> 'localhost',
'login'=> 'root',
'password'=> 'password',
'database'=> 'project_name',
'schema'=> null,
'prefix'=> null,
'datasource' => 'Database/Mysql',
'persistent' => 'false',
'host' => 'localhost',
'login' => 'root',
'password' => 'password',
'database' => 'project_name',
'schema' => null,
'prefix' => null,
'encoding' => null,
'port' => null
);

View file

@ -15,6 +15,8 @@
* @since CakePHP(tm) v 1.2.0.5012
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::uses('AppShell', 'Console/Command');
App::uses('File', 'Utility');
App::uses('Folder', 'Utility');
@ -23,7 +25,7 @@ App::uses('Folder', 'Utility');
*
* @package Cake.Console.Command.Task
*/
class ExtractTask extends Shell {
class ExtractTask extends AppShell {
/**
* Paths to use when looking for strings
@ -162,7 +164,7 @@ class ExtractTask extends Shell {
} else {
$message = __d('cake_console', "What is the path you would like to output?\n[Q]uit", $this->_paths[0] . DS . 'Locale');
while (true) {
$response = $this->in($message, null, $this->_paths[0] . DS . 'Locale');
$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();
@ -187,6 +189,7 @@ class ExtractTask extends Shell {
if (empty($this->_files)) {
$this->_searchFiles();
}
$this->_output = rtrim($this->_output, DS) . DS;
$this->_extract();
}

View file

@ -16,6 +16,7 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::uses('AppShell', 'Console/Command');
App::uses('BakeTask', 'Console/Command/Task');
App::uses('Model', 'Model');
@ -90,7 +91,7 @@ class FixtureTask extends BakeTask {
/**
* Execution method always used for tasks
* Handles dispatching to interactive, named, or all processeses.
* Handles dispatching to interactive, named, or all processes.
*
* @return void
*/
@ -279,7 +280,7 @@ class FixtureTask extends BakeTask {
*/
protected function _generateSchema($tableInfo) {
$schema = $this->_Schema->generateTable('f', $tableInfo);
return substr($schema, 10, -2);
return substr($schema, 13, -2);
}
/**

View file

@ -16,6 +16,7 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::uses('AppShell', 'Console/Command');
App::uses('BakeTask', 'Console/Command/Task');
App::uses('ConnectionManager', 'Model');
App::uses('Model', 'Model');
@ -56,6 +57,13 @@ class ModelTask extends BakeTask {
*/
protected $_tables = array();
/**
* Holds the model names
*
* @var array
*/
protected $_modelNames = array();
/**
* Holds validation method map.
*
@ -117,9 +125,9 @@ class ModelTask extends BakeTask {
}
$modelClass = Inflector::classify($table);
$this->out(__d('cake_console', 'Baking %s', $modelClass));
$object = $this->_getModelObject($modelClass);
$object = $this->_getModelObject($modelClass, $table);
if ($this->bake($object, false) && $unitTestExists) {
$this->bakeFixture($modelClass);
$this->bakeFixture($modelClass, $table);
$this->bakeTest($modelClass);
}
}
@ -132,11 +140,18 @@ class ModelTask extends BakeTask {
* @param string $table Table name
* @return Model Model instance
*/
protected function &_getModelObject($className, $table = null) {
protected function _getModelObject($className, $table = null) {
if (!$table) {
$table = Inflector::tableize($className);
}
$object = new Model(array('name' => $className, 'table' => $table, 'ds' => $this->connection));
$fields = $object->schema(true);
foreach ($fields as $name => $field) {
if (isset($field['key']) && $field['key'] == 'primary') {
$object->primaryKey = $name;
break;
}
}
return $object;
}
@ -254,7 +269,7 @@ class ModelTask extends BakeTask {
}
$this->hr();
$looksGood = $this->in(__d('cake_console', 'Look okay?'), array('y','n'), 'y');
$looksGood = $this->in(__d('cake_console', 'Look okay?'), array('y', 'n'), 'y');
if (strtolower($looksGood) == 'y') {
$vars = compact('associations', 'validate', 'primaryKey', 'useTable', 'displayField');
@ -294,6 +309,7 @@ class ModelTask extends BakeTask {
* @return string Name of field that is a primary key.
*/
public function findPrimaryKey($fields) {
$name = 'id';
foreach ($fields as $name => $field) {
if (isset($field['key']) && $field['key'] == 'primary') {
break;
@ -462,7 +478,7 @@ class ModelTask extends BakeTask {
* Handles associations
*
* @param Model $model
* @return array $assocaitons
* @return array $associations
*/
public function doAssociations($model) {
if (!is_object($model)) {
@ -474,7 +490,7 @@ class ModelTask extends BakeTask {
$fields = $model->schema(true);
if (empty($fields)) {
return false;
return array();
}
if (empty($this->_tables)) {
@ -482,7 +498,7 @@ class ModelTask extends BakeTask {
}
$associations = array(
'belongsTo' => array(), 'hasMany' => array(), 'hasOne'=> array(), 'hasAndBelongsToMany' => array()
'belongsTo' => array(), 'hasMany' => array(), 'hasOne' => array(), 'hasAndBelongsToMany' => array()
);
$associations = $this->findBelongsTo($model, $associations);
@ -511,7 +527,7 @@ class ModelTask extends BakeTask {
* Find belongsTo relations and add them to the associations list.
*
* @param Model $model Model instance of model being generated.
* @param array $associations Array of inprogress associations
* @param array $associations Array of in progress associations
* @return array $associations with belongsTo added in.
*/
public function findBelongsTo($model, $associations) {
@ -540,7 +556,7 @@ class ModelTask extends BakeTask {
* Find the hasOne and HasMany relations and add them to associations list
*
* @param Model $model Model instance being generated
* @param array $associations Array of inprogress associations
* @param array $associations Array of in progress associations
* @return array $associations with hasOne and hasMany added in.
*/
public function findHasOneAndMany($model, $associations) {
@ -631,7 +647,7 @@ class ModelTask extends BakeTask {
if (!empty($associations[$type])) {
foreach ($associations[$type] as $i => $assoc) {
$prompt = "{$model->name} {$type} {$assoc['alias']}?";
$response = $this->in($prompt, array('y','n'), 'y');
$response = $this->in($prompt, array('y', 'n'), 'y');
if ('n' == strtolower($response)) {
unset($associations[$type][$i]);
@ -654,7 +670,7 @@ class ModelTask extends BakeTask {
*/
public function doMoreAssociations($model, $associations) {
$prompt = __d('cake_console', 'Would you like to define some additional model associations?');
$wannaDoMoreAssoc = $this->in($prompt, array('y','n'), 'n');
$wannaDoMoreAssoc = $this->in($prompt, array('y', 'n'), 'n');
$possibleKeys = $this->_generatePossibleKeys();
while (strtolower($wannaDoMoreAssoc) == 'y') {
$assocs = array('belongsTo', 'hasOne', 'hasMany', 'hasAndBelongsToMany');
@ -715,7 +731,7 @@ class ModelTask extends BakeTask {
$associations[$assocs[$assocType]][$i]['associationForeignKey'] = $associationForeignKey;
$associations[$assocs[$assocType]][$i]['joinTable'] = $joinTable;
}
$wannaDoMoreAssoc = $this->in(__d('cake_console', 'Define another association?'), array('y','n'), 'y');
$wannaDoMoreAssoc = $this->in(__d('cake_console', 'Define another association?'), array('y', 'n'), 'y');
}
return $associations;
}
@ -749,8 +765,8 @@ class ModelTask extends BakeTask {
public function bake($name, $data = array()) {
if (is_object($name)) {
if ($data == false) {
$data = $associations = array();
$data['associations'] = $this->doAssociations($name, $associations);
$data = array();
$data['associations'] = $this->doAssociations($name);
$data['validate'] = $this->doValidation($name);
}
$data['primaryKey'] = $name->primaryKey;
@ -832,13 +848,17 @@ class ModelTask extends BakeTask {
$db = ConnectionManager::getDataSource($useDbConfig);
$useTable = Inflector::tableize($modelName);
if (in_array($modelName, $this->_modelNames)) {
$modelNames = array_flip($this->_modelNames);
$useTable = $this->_tables[$modelNames[$modelName]];
}
$fullTableName = $db->fullTableName($useTable, false);
$tableIsGood = false;
if (array_search($useTable, $this->_tables) === false) {
$this->out();
$this->out(__d('cake_console', "Given your model named '%s',\nCake would expect a database table named '%s'", $modelName, $fullTableName));
$tableIsGood = $this->in(__d('cake_console', 'Do you want to use this table?'), array('y','n'), 'y');
$tableIsGood = $this->in(__d('cake_console', 'Do you want to use this table?'), array('y', 'n'), 'y');
}
if (strtolower($tableIsGood) == 'n') {
$useTable = $this->in(__d('cake_console', 'What is the name of the table?'));

View file

@ -16,6 +16,7 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::uses('AppShell', 'Console/Command');
App::uses('File', 'Utility');
App::uses('Folder', 'Utility');
@ -24,7 +25,7 @@ App::uses('Folder', 'Utility');
*
* @package Cake.Console.Command.Task
*/
class PluginTask extends Shell {
class PluginTask extends AppShell {
/**
* path to plugins directory
@ -74,7 +75,7 @@ class PluginTask extends Shell {
}
if (!$this->bake($plugin)) {
$this->error(__d('cake_console', "An error occured trying to bake: %s in %s", $plugin, $this->path . $plugin));
$this->error(__d('cake_console', "An error occurred trying to bake: %s in %s", $plugin, $this->path . $plugin));
}
}
@ -158,8 +159,8 @@ class PluginTask extends Shell {
*/
public function findPath($pathOptions) {
$valid = false;
foreach ($pathOptions as $i =>$path) {
if(!is_dir($path)) {
foreach ($pathOptions as $i => $path) {
if (!is_dir($path)) {
array_splice($pathOptions, $i, 1);
}
}

View file

@ -17,6 +17,7 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::uses('AppShell', 'Console/Command');
App::uses('File', 'Utility');
App::uses('Folder', 'Utility');
App::uses('String', 'Utility');
@ -27,7 +28,7 @@ App::uses('Security', 'Utility');
*
* @package Cake.Console.Command.Task
*/
class ProjectTask extends Shell {
class ProjectTask extends AppShell {
/**
* configs path (used in testing).
@ -61,7 +62,7 @@ class ProjectTask extends Shell {
$response = false;
while ($response == false && is_dir($project) === true && file_exists($project . 'Config' . 'core.php')) {
$prompt = __d('cake_console', '<warning>A project already exists in this location:</warning> %s Overwrite?', $project);
$response = $this->in($prompt, array('y','n'), 'n');
$response = $this->in($prompt, array('y', 'n'), 'n');
if (strtolower($response) === 'n') {
$response = $project = false;
}

View file

@ -16,14 +16,16 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::uses('AppShell', 'Console/Command');
App::uses('Folder', 'Utility');
/**
* Template Task can generate templated output Used in other Tasks.
* Acts like a simplified View class.
*
* @package Cake.Console.Command.Task
*/
class TemplateTask extends Shell {
class TemplateTask extends AppShell {
/**
* variables to add to template scope
@ -57,7 +59,7 @@ class TemplateTask extends Shell {
* @return array Array of bake themes that are installed.
*/
protected function _findThemes() {
$paths = App::path('Console');
$paths = array();
$core = current(App::core('Console'));
$separator = DS === '/' ? '/' : '\\\\';
$core = preg_replace('#shells' . $separator . '$#', '', $core);
@ -68,10 +70,12 @@ class TemplateTask extends Shell {
$themeFolders = $contents[0];
$plugins = App::objects('plugin');
$paths[] = $core;
foreach ($plugins as $plugin) {
$paths[] = $this->_pluginPath($plugin) . 'Console' . DS;
}
$paths[] = $core;
$paths = array_merge($paths, App::path('Console'));
// TEMPORARY TODO remove when all paths are DS terminated
foreach ($paths as $i => $path) {

View file

@ -16,6 +16,7 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::uses('AppShell', 'Console/Command');
App::uses('BakeTask', 'Console/Command/Task');
App::uses('ClassRegistry', 'Utility');
@ -405,7 +406,7 @@ class TestTask extends BakeTask {
* @return array Array of fixtures the user wants to add.
*/
public function getUserFixtures() {
$proceed = $this->in(__d('cake_console', 'Bake could not detect fixtures, would you like to add some?'), array('y','n'), 'n');
$proceed = $this->in(__d('cake_console', 'Bake could not detect fixtures, would you like to add some?'), array('y', 'n'), 'n');
$fixtures = array();
if (strtolower($proceed) == 'y') {
$fixtureList = $this->in(__d('cake_console', "Please provide a comma separated list of the fixtures names you'd like to use.\nExample: 'app.comment, app.post, plugin.forums.post'"));
@ -476,7 +477,7 @@ class TestTask extends BakeTask {
->addArgument('type', array(
'help' => __d('cake_console', 'Type of class to bake, can be any of the following: controller, model, helper, component or behavior.'),
'choices' => array(
'Controller', 'controller',
'Controller', 'controller',
'Model', 'model',
'Helper', 'helper',
'Component', 'component',

View file

@ -16,6 +16,7 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::uses('AppShell', 'Console/Command');
App::uses('Controller', 'Controller');
App::uses('BakeTask', 'Console/Command/Task');
@ -214,9 +215,9 @@ class ViewTask extends BakeTask {
}
$prompt = __d('cake_console', "Would you like to create some CRUD views\n(index, add, view, edit) for this controller?\nNOTE: Before doing so, you'll need to create your controller\nand model classes (including associated models).");
$wannaDoScaffold = $this->in($prompt, array('y','n'), 'y');
$wannaDoScaffold = $this->in($prompt, array('y', 'n'), 'y');
$wannaDoAdmin = $this->in(__d('cake_console', "Would you like to create the views for admin routing?"), array('y','n'), 'n');
$wannaDoAdmin = $this->in(__d('cake_console', "Would you like to create the views for admin routing?"), array('y', 'n'), 'n');
if (strtolower($wannaDoScaffold) == 'y' || strtolower($wannaDoAdmin) == 'y') {
$vars = $this->_loadController();
@ -291,7 +292,7 @@ class ViewTask extends BakeTask {
$pluralHumanName = $this->_pluralHumanName($this->controllerName);
return compact('modelClass', 'schema', 'primaryKey', 'displayField', 'singularVar', 'pluralVar',
'singularHumanName', 'pluralHumanName', 'fields','associations');
'singularHumanName', 'pluralHumanName', 'fields', 'associations');
}
/**
@ -329,7 +330,7 @@ class ViewTask extends BakeTask {
$this->out(__d('cake_console', 'Action Name: %s', $action));
$this->out(__d('cake_console', 'Path: %s', $this->getPath() . $this->controllerName . DS . Inflector::underscore($action) . ".ctp"));
$this->hr();
$looksGood = $this->in(__d('cake_console', 'Look okay?'), array('y','n'), 'y');
$looksGood = $this->in(__d('cake_console', 'Look okay?'), array('y', 'n'), 'y');
if (strtolower($looksGood) == 'y') {
$this->bake($action, ' ');
$this->_stop();

View file

@ -19,6 +19,10 @@
*/
App::uses('TestShell', 'Console/Command');
App::uses('AppShell', 'Console/Command');
App::uses('CakeTestSuiteDispatcher', 'TestSuite');
App::uses('CakeTestSuiteCommand', 'TestSuite');
App::uses('CakeTestLoader', 'TestSuite');
/**
* Provides a CakePHP wrapper around PHPUnit.
@ -26,7 +30,18 @@ App::uses('TestShell', 'Console/Command');
*
* @package Cake.Console.Command
*/
<<<<<<< HEAD
class TestsuiteShell extends TestShell {
=======
class TestsuiteShell extends AppShell {
/**
* Dispatcher object for the run.
*
* @var CakeTestDispatcher
*/
protected $_dispatcher = null;
>>>>>>> 2.0
/**
* get the option parser for the test suite.

View file

@ -17,6 +17,7 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::uses('AppShell', 'Console/Command');
App::uses('Folder', 'Utility');
/**
@ -24,7 +25,7 @@ App::uses('Folder', 'Utility');
*
* @package Cake.Console.Command
*/
class UpgradeShell extends Shell {
class UpgradeShell extends AppShell {
/**
* Files
@ -82,7 +83,7 @@ class UpgradeShell extends Shell {
* @return void
*/
public function all() {
foreach($this->OptionParser->subcommands() as $command) {
foreach ($this->OptionParser->subcommands() as $command) {
$name = $command->name();
if ($name === 'all') {
continue;
@ -134,7 +135,7 @@ class UpgradeShell extends Shell {
if (is_dir('plugins')) {
$Folder = new Folder('plugins');
list($plugins) = $Folder->read();
foreach($plugins as $plugin) {
foreach ($plugins as $plugin) {
chdir($cwd . DS . 'plugins' . DS . $plugin);
$this->locations();
}
@ -154,7 +155,7 @@ class UpgradeShell extends Shell {
'Test' . DS . 'fixtures' => 'Test' . DS . 'Fixture',
'vendors' . DS . 'shells' . DS . 'templates' => 'Console' . DS . 'Templates',
);
foreach($moves as $old => $new) {
foreach ($moves as $old => $new) {
if (is_dir($old)) {
$this->out(__d('cake_console', 'Moving %s to %s', $old, $new));
if (!$this->params['dry-run']) {
@ -189,7 +190,7 @@ class UpgradeShell extends Shell {
'checkFolder' => true,
'regex' => '@class (\S*) .*{@i'
);
foreach($sourceDirs as $dir => $options) {
foreach ($sourceDirs as $dir => $options) {
if (is_numeric($dir)) {
$dir = $options;
$options = array();
@ -613,7 +614,7 @@ class UpgradeShell extends Shell {
$this->_findFiles('php');
} else {
$this->_files = scandir($path);
foreach($this->_files as $i => $file) {
foreach ($this->_files as $i => $file) {
if (strlen($file) < 5 || substr($file, -4) !== '.php') {
unset($this->_files[$i]);
}
@ -763,7 +764,7 @@ class UpgradeShell extends Shell {
'help' => __d('cake_console', 'Use git command for moving files around.'),
'boolean' => true
),
'dry-run'=> array(
'dry-run' => array(
'short' => 'd',
'help' => __d('cake_console', 'Dry run the update, no files will actually be modified.'),
'boolean' => true

View file

@ -140,7 +140,7 @@ class HelpFormatter {
foreach ($this->_parser->options() as $option) {
$options[] = $option->usage();
}
if (count($options) > $this->_maxOptions){
if (count($options) > $this->_maxOptions) {
$options = array('[options]');
}
$usage = array_merge($usage, $options);

View file

@ -83,6 +83,7 @@ class Shell extends Object {
* Contains tasks to load and instantiate
*
* @var array
* @link http://book.cakephp.org/2.0/en/console-and-shells.html#Shell::$tasks
*/
public $tasks = array();
@ -97,6 +98,7 @@ class Shell extends Object {
* Contains models to load and instantiate
*
* @var array
* @link http://book.cakephp.org/2.0/en/console-and-shells.html#Shell::$uses
*/
public $uses = array();
@ -141,6 +143,7 @@ class Shell extends Object {
* @param ConsoleOutput $stdout A ConsoleOutput object for stdout.
* @param ConsoleOutput $stderr A ConsoleOutput object for stderr.
* @param ConsoleInput $stdin A ConsoleInput object for stdin.
* @link http://book.cakephp.org/2.0/en/console-and-shells.html#Shell
*/
public function __construct($stdout = null, $stderr = null, $stdin = null) {
if ($this->name == null) {
@ -176,6 +179,7 @@ class Shell extends Object {
* allows configuration of tasks prior to shell execution
*
* @return void
* @link http://book.cakephp.org/2.0/en/console-and-shells.html#Shell::initialize
*/
public function initialize() {
$this->_loadModels();
@ -189,6 +193,7 @@ class Shell extends Object {
* or otherwise modify the pre-command flow.
*
* @return void
* @link http://book.cakephp.org/2.0/en/console-and-shells.html#Shell::startup
*/
public function startup() {
$this->_welcome();
@ -261,6 +266,7 @@ class Shell extends Object {
*
* @param string $task The task name to check.
* @return boolean Success
* @link http://book.cakephp.org/2.0/en/console-and-shells.html#Shell::hasTask
*/
public function hasTask($task) {
return isset($this->_taskMap[Inflector::camelize($task)]);
@ -271,6 +277,7 @@ class Shell extends Object {
*
* @param string $name The method name to check.
* @return boolean
* @link http://book.cakephp.org/2.0/en/console-and-shells.html#Shell::hasMethod
*/
public function hasMethod($name) {
try {
@ -306,6 +313,7 @@ class Shell extends Object {
* `return $this->dispatchShell('schema', 'create', 'i18n', '--dry');`
*
* @return mixed The return of the other shell.
* @link http://book.cakephp.org/2.0/en/console-and-shells.html#Shell::dispatchShell
*/
public function dispatchShell() {
$args = func_get_args();
@ -334,6 +342,7 @@ class Shell extends Object {
* and the shell has a `main()` method, that will be called instead.
* @param array $argv Array of arguments to run the shell with. This array should be missing the shell name.
* @return void
* @link http://book.cakephp.org/2.0/en/console-and-shells.html#Shell::runCommand
*/
public function runCommand($command, $argv) {
$isTask = $this->hasTask($command);
@ -357,7 +366,7 @@ class Shell extends Object {
return $this->_displayHelp($command);
}
if (($isTask || $isMethod || $isMain) && $command !== 'execute' ) {
if (($isTask || $isMethod || $isMain) && $command !== 'execute') {
$this->startup();
}
@ -397,6 +406,7 @@ class Shell extends Object {
* By overriding this method you can configure the ConsoleOptionParser before returning it.
*
* @return ConsoleOptionParser
* @link http://book.cakephp.org/2.0/en/console-and-shells.html#Shell::getOptionParser
*/
public function getOptionParser() {
$parser = new ConsoleOptionParser($this->name);
@ -428,6 +438,7 @@ class Shell extends Object {
* @param mixed $options Array or string of options.
* @param string $default Default input value.
* @return mixed Either the default value, or the user-provided input.
* @link http://book.cakephp.org/2.0/en/console-and-shells.html#Shell::in
*/
public function in($prompt, $options = null, $default = null) {
if (!$this->interactive) {
@ -499,6 +510,7 @@ class Shell extends Object {
* @param mixed $options Array of options to use, or an integer to wrap the text to.
* @return string Wrapped / indented text
* @see String::wrap()
* @link http://book.cakephp.org/2.0/en/console-and-shells.html#Shell::wrapText
*/
public function wrapText($text, $options = array()) {
return String::wrap($text, $options);
@ -519,6 +531,7 @@ class Shell extends Object {
* @param integer $newlines Number of newlines to append
* @param integer $level The message's output level, see above.
* @return integer|boolean Returns the number of bytes returned from writing to stdout.
* @link http://book.cakephp.org/2.0/en/console-and-shells.html#Shell::out
*/
public function out($message = null, $newlines = 1, $level = Shell::NORMAL) {
$currentLevel = Shell::NORMAL;
@ -541,6 +554,7 @@ class Shell extends Object {
* @param mixed $message A string or a an array of strings to output
* @param integer $newlines Number of newlines to append
* @return void
* @link http://book.cakephp.org/2.0/en/console-and-shells.html#Shell::err
*/
public function err($message = null, $newlines = 1) {
$this->stderr->write($message, $newlines);
@ -551,6 +565,7 @@ class Shell extends Object {
*
* @param integer $multiplier Number of times the linefeed sequence should be repeated
* @return string
* @link http://book.cakephp.org/2.0/en/console-and-shells.html#Shell::nl
*/
public function nl($multiplier = 1) {
return str_repeat(ConsoleOutput::LF, $multiplier);
@ -562,6 +577,7 @@ class Shell extends Object {
* @param integer $newlines Number of newlines to pre- and append
* @param integer $width Width of the line, defaults to 63
* @return void
* @link http://book.cakephp.org/2.0/en/console-and-shells.html#Shell::hr
*/
public function hr($newlines = 0, $width = 63) {
$this->out(null, $newlines);
@ -576,6 +592,7 @@ class Shell extends Object {
* @param string $title Title of the error
* @param string $message An optional error message
* @return void
* @link http://book.cakephp.org/2.0/en/console-and-shells.html#Shell::error
*/
public function error($title, $message = null) {
$this->err(__d('cake_console', '<error>Error:</error> %s', $title));
@ -590,6 +607,7 @@ class Shell extends Object {
* Clear the console
*
* @return void
* @link http://book.cakephp.org/2.0/en/console-and-shells.html#Shell::clear
*/
public function clear() {
if (empty($this->params['noclear'])) {
@ -607,6 +625,7 @@ class Shell extends Object {
* @param string $path Where to put the file.
* @param string $contents Content to put in the file.
* @return boolean Success
* @link http://book.cakephp.org/2.0/en/console-and-shells.html#Shell::createFile
*/
public function createFile($path, $contents) {
$path = str_replace(DS . DS, DS, $path);
@ -653,7 +672,7 @@ class Shell extends Object {
return true;
}
$prompt = __d('cake_console', 'PHPUnit is not installed. Do you want to bake unit test files anyway?');
$unitTest = $this->in($prompt, array('y','n'), 'y');
$unitTest = $this->in($prompt, array('y', 'n'), 'y');
$result = strtolower($unitTest) == 'y' || strtolower($unitTest) == 'yes';
if ($result) {
@ -668,6 +687,7 @@ class Shell extends Object {
*
* @param string $file Absolute file path
* @return string short path
* @link http://book.cakephp.org/2.0/en/console-and-shells.html#Shell::shortPath
*/
public function shortPath($file) {
$shortPath = str_replace(ROOT, null, $file);

View file

@ -210,7 +210,7 @@ class ShellDispatcher {
$class = Inflector::camelize($shell) . 'Shell';
App::uses('Shell', 'Console');
App::uses('AppShell', 'Console');
App::uses('AppShell', 'Console/Command');
App::uses($class, $plugin . 'Console/Command');
if (!class_exists($class)) {

View file

@ -143,7 +143,7 @@
if ($this-><?php echo $currentModelName; ?>->delete()) {
<?php if ($wannaUseSession): ?>
$this->Session->setFlash(__('<?php echo ucfirst(strtolower($singularHumanName)); ?> deleted'));
$this->redirect(array('action'=>'index'));
$this->redirect(array('action' => 'index'));
<?php else: ?>
$this->flash(__('<?php echo ucfirst(strtolower($singularHumanName)); ?> deleted'), array('action' => 'index'));
<?php endif; ?>

View file

@ -50,7 +50,7 @@ class <?php echo $controllerName; ?>Controller extends <?php echo $plugin; ?>App
<?php
if (count($helpers)):
echo "/**\n * Helpers\n *\n * @var array\n */\n";
echo "\tvar \$helpers = array(";
echo "\tpublic \$helpers = array(";
for ($i = 0, $len = count($helpers); $i < $len; $i++):
if ($i != $len - 1):
echo "'" . Inflector::camelize($helpers[$i]) . "', ";

View file

@ -27,7 +27,6 @@
</tr>
<?php
echo "<?php
\$i = 0;
foreach (\${$pluralVar} as \${$singularVar}): ?>\n";
echo "\t<tr>\n";
foreach ($fields as $field) {

View file

@ -39,35 +39,35 @@ class DbAclSchema extends CakeSchema {
}
public $acos = array(
'id' => array('type'=>'integer', 'null' => false, 'default' => NULL, 'length' => 10, 'key' => 'primary'),
'parent_id' => array('type'=>'integer', 'null' => true, 'default' => NULL, 'length' => 10),
'model' => array('type'=>'string', 'null' => true),
'foreign_key' => array('type'=>'integer', 'null' => true, 'default' => NULL, 'length' => 10),
'alias' => array('type'=>'string', 'null' => true),
'lft' => array('type'=>'integer', 'null' => true, 'default' => NULL, 'length' => 10),
'rght' => array('type'=>'integer', 'null' => true, 'default' => NULL, 'length' => 10),
'id' => array('type' => 'integer', 'null' => false, 'default' => NULL, 'length' => 10, 'key' => 'primary'),
'parent_id' => array('type' => 'integer', 'null' => true, 'default' => NULL, 'length' => 10),
'model' => array('type' => 'string', 'null' => true),
'foreign_key' => array('type' => 'integer', 'null' => true, 'default' => NULL, 'length' => 10),
'alias' => array('type' => 'string', 'null' => true),
'lft' => array('type' => 'integer', 'null' => true, 'default' => NULL, 'length' => 10),
'rght' => array('type' => 'integer', 'null' => true, 'default' => NULL, 'length' => 10),
'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => 1))
);
public $aros = array(
'id' => array('type'=>'integer', 'null' => false, 'default' => NULL, 'length' => 10, 'key' => 'primary'),
'parent_id' => array('type'=>'integer', 'null' => true, 'default' => NULL, 'length' => 10),
'model' => array('type'=>'string', 'null' => true),
'foreign_key' => array('type'=>'integer', 'null' => true, 'default' => NULL, 'length' => 10),
'alias' => array('type'=>'string', 'null' => true),
'lft' => array('type'=>'integer', 'null' => true, 'default' => NULL, 'length' => 10),
'rght' => array('type'=>'integer', 'null' => true, 'default' => NULL, 'length' => 10),
'id' => array('type' => 'integer', 'null' => false, 'default' => NULL, 'length' => 10, 'key' => 'primary'),
'parent_id' => array('type' => 'integer', 'null' => true, 'default' => NULL, 'length' => 10),
'model' => array('type' => 'string', 'null' => true),
'foreign_key' => array('type' => 'integer', 'null' => true, 'default' => NULL, 'length' => 10),
'alias' => array('type' => 'string', 'null' => true),
'lft' => array('type' => 'integer', 'null' => true, 'default' => NULL, 'length' => 10),
'rght' => array('type' => 'integer', 'null' => true, 'default' => NULL, 'length' => 10),
'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => 1))
);
public $aros_acos = array(
'id' => array('type'=>'integer', 'null' => false, 'default' => NULL, 'length' => 10, 'key' => 'primary'),
'aro_id' => array('type'=>'integer', 'null' => false, 'length' => 10, 'key' => 'index'),
'aco_id' => array('type'=>'integer', 'null' => false, 'length' => 10),
'_create' => array('type'=>'string', 'null' => false, 'default' => '0', 'length' => 2),
'_read' => array('type'=>'string', 'null' => false, 'default' => '0', 'length' => 2),
'_update' => array('type'=>'string', 'null' => false, 'default' => '0', 'length' => 2),
'_delete' => array('type'=>'string', 'null' => false, 'default' => '0', 'length' => 2),
'id' => array('type' => 'integer', 'null' => false, 'default' => NULL, 'length' => 10, 'key' => 'primary'),
'aro_id' => array('type' => 'integer', 'null' => false, 'length' => 10, 'key' => 'index'),
'aco_id' => array('type' => 'integer', 'null' => false, 'length' => 10),
'_create' => array('type' => 'string', 'null' => false, 'default' => '0', 'length' => 2),
'_read' => array('type' => 'string', 'null' => false, 'default' => '0', 'length' => 2),
'_update' => array('type' => 'string', 'null' => false, 'default' => '0', 'length' => 2),
'_delete' => array('type' => 'string', 'null' => false, 'default' => '0', 'length' => 2),
'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => 1), 'ARO_ACO_KEY' => array('column' => array('aro_id', 'aco_id'), 'unique' => 1))
);

View file

@ -39,12 +39,12 @@ class i18nSchema extends CakeSchema {
}
public $i18n = array(
'id' => array('type'=>'integer', 'null' => false, 'default' => NULL, 'length' => 10, 'key' => 'primary'),
'locale' => array('type'=>'string', 'null' => false, 'length' => 6, 'key' => 'index'),
'model' => array('type'=>'string', 'null' => false, 'key' => 'index'),
'foreign_key' => array('type'=>'integer', 'null' => false, 'length' => 10, 'key' => 'index'),
'field' => array('type'=>'string', 'null' => false, 'key' => 'index'),
'content' => array('type'=>'text', 'null' => true, 'default' => NULL),
'id' => array('type' => 'integer', 'null' => false, 'default' => NULL, 'length' => 10, 'key' => 'primary'),
'locale' => array('type' => 'string', 'null' => false, 'length' => 6, 'key' => 'index'),
'model' => array('type' => 'string', 'null' => false, 'key' => 'index'),
'foreign_key' => array('type' => 'integer', 'null' => false, 'length' => 10, 'key' => 'index'),
'field' => array('type' => 'string', 'null' => false, 'key' => 'index'),
'content' => array('type' => 'text', 'null' => true, 'default' => NULL),
'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => 1), 'locale' => array('column' => 'locale', 'unique' => 0), 'model' => array('column' => 'model', 'unique' => 0), 'row_id' => array('column' => 'foreign_key', 'unique' => 0), 'field' => array('column' => 'field', 'unique' => 0))
);

View file

@ -39,9 +39,9 @@ class SessionsSchema extends CakeSchema {
}
public $cake_sessions = array(
'id' => array('type'=>'string', 'null' => false, 'key' => 'primary'),
'data' => array('type'=>'text', 'null' => true, 'default' => NULL),
'expires' => array('type'=>'integer', 'null' => true, 'default' => NULL),
'id' => array('type' => 'string', 'null' => false, 'key' => 'primary'),
'data' => array('type' => 'text', 'null' => true, 'default' => NULL),
'expires' => array('type' => 'integer', 'null' => true, 'default' => NULL),
'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => 1))
);

View file

@ -239,8 +239,8 @@
*
* Cache::config('default', array(
* 'engine' => 'File', //[required]
* 'duration'=> 3600, //[optional]
* 'probability'=> 100, //[optional]
* 'duration' => 3600, //[optional]
* 'probability' => 100, //[optional]
* 'path' => CACHE, //[optional] use system tmp directory - remember to use absolute path
* 'prefix' => 'cake_', //[optional] prefix every cache file with this string
* 'lock' => false, //[optional] use file locking
@ -251,8 +251,8 @@
*
* Cache::config('default', array(
* 'engine' => 'Apc', //[required]
* 'duration'=> 3600, //[optional]
* 'probability'=> 100, //[optional]
* 'duration' => 3600, //[optional]
* 'probability' => 100, //[optional]
* 'prefix' => Inflector::slug(APP_DIR) . '_', //[optional] prefix every cache file with this string
* ));
*
@ -260,8 +260,8 @@
*
* Cache::config('default', array(
* 'engine' => 'Xcache', //[required]
* 'duration'=> 3600, //[optional]
* 'probability'=> 100, //[optional]
* 'duration' => 3600, //[optional]
* 'probability' => 100, //[optional]
* 'prefix' => Inflector::slug(APP_DIR) . '_', //[optional] prefix every cache file with this string
* 'user' => 'user', //user from xcache.admin.user settings
* 'password' => 'password', //plaintext password (xcache.admin.pass)
@ -271,8 +271,8 @@
*
* Cache::config('default', array(
* 'engine' => 'Memcache', //[required]
* 'duration'=> 3600, //[optional]
* 'probability'=> 100, //[optional]
* 'duration' => 3600, //[optional]
* 'probability' => 100, //[optional]
* 'prefix' => Inflector::slug(APP_DIR) . '_', //[optional] prefix every cache file with this string
* 'servers' => array(
* '127.0.0.1:11211' // localhost, default port 11211
@ -285,8 +285,8 @@
*
* Cache::config('default', array(
* 'engine' => 'Wincache', //[required]
* 'duration'=> 3600, //[optional]
* 'probability'=> 100, //[optional]
* 'duration' => 3600, //[optional]
* 'probability' => 100, //[optional]
* 'prefix' => Inflector::slug(APP_DIR) . '_', //[optional] prefix every cache file with this string
* ));
*/

View file

@ -46,7 +46,7 @@
</div>
<div id="footer">
<?php echo $this->Html->link(
$this->Html->image('cake.power.gif', array('alt'=> __('CakePHP: the rapid development php framework'), 'border' => '0')),
$this->Html->image('cake.power.gif', array('alt' => __('CakePHP: the rapid development php framework'), 'border' => '0')),
'http://www.cakephp.org/',
array('target' => '_blank', 'escape' => false)
);

View file

@ -16,16 +16,16 @@
*/
* {
margin:0;
padding:0;
margin: 0;
padding: 0;
}
/** General Style Info **/
body {
background: #003d4c;
color: #fff;
font-family:'lucida grande',verdana,helvetica,arial,sans-serif;
font-size:90%;
font-family: 'lucida grande', verdana, helvetica, arial, sans-serif;
font-size: 90%;
margin: 0;
}
a {
@ -35,29 +35,29 @@ a {
}
a:hover {
color: #367889;
text-decoration:none;
text-decoration: none;
}
a img {
border:none;
border: none;
}
h1, h2, h3, h4 {
font-weight: normal;
margin-bottom:0.5em;
margin-bottom: 0.5em;
}
h1 {
background:#fff;
background: #fff;
color: #003d4c;
font-size: 100%;
}
h2 {
background:#fff;
background: #fff;
color: #e32;
font-family:'Gill Sans','lucida grande', helvetica, arial, sans-serif;
font-family: 'Gill Sans', 'lucida grande', helvetica, arial, sans-serif;
font-size: 190%;
}
h3 {
color: #2c6877;
font-family:'Gill Sans','lucida grande', helvetica, arial, sans-serif;
font-family: 'Gill Sans', 'lucida grande', helvetica, arial, sans-serif;
font-size: 165%;
}
h4 {
@ -80,7 +80,7 @@ p {
padding: 10px 20px;
}
#header h1 {
line-height:20px;
line-height: 20px;
background: #003d4c url('../img/cake.icon.png') no-repeat left;
color: #fff;
padding: 0px 30px;
@ -113,35 +113,35 @@ p {
div.form,
div.index,
div.view {
float:right;
width:76%;
border-left:1px solid #666;
padding:10px 2%;
float: right;
width: 76%;
border-left: 1px solid #666;
padding: 10px 2%;
}
div.actions {
float:left;
width:16%;
padding:10px 1.5%;
float: left;
width: 16%;
padding: 10px 1.5%;
}
div.actions h3 {
padding-top:0;
color:#777;
padding-top: 0;
color: #777;
}
/** Tables **/
table {
border-right:0;
border-right: 0;
clear: both;
color: #333;
margin-bottom: 10px;
width: 100%;
}
th {
border:0;
border-bottom:2px solid #555;
border: 0;
border-bottom: 2px solid #555;
text-align: left;
padding:4px;
padding: 4px;
}
th a {
display: block;
@ -158,7 +158,7 @@ table tr td {
padding: 6px;
text-align: left;
vertical-align: top;
border-bottom:1px solid #ddd;
border-bottom: 1px solid #ddd;
}
table tr:nth-child(even) {
background: #f9f9f9;
@ -169,7 +169,7 @@ td.actions {
}
table td.actions a {
margin: 0px 6px;
padding:2px 5px;
padding: 2px 5px;
}
/* SQL log */
@ -182,15 +182,15 @@ table td.actions a {
font-family: Monaco, Consolas, "Courier New", monospaced;
}
.cake-sql-log caption {
color:#fff;
color: #fff;
}
/** Paging **/
.paging {
background:#fff;
background: #fff;
color: #ccc;
margin-top: 1em;
clear:both;
clear: both;
}
.paging .current,
.paging .disabled,
@ -296,7 +296,7 @@ form .required {
form .required label:after {
color: #e32;
content: '*';
display:inline;
display: inline;
}
form div.submit {
border: 0;
@ -306,14 +306,14 @@ form div.submit {
label {
display: block;
font-size: 110%;
margin-bottom:3px;
margin-bottom: 3px;
}
input, textarea {
clear: both;
font-size: 140%;
font-family: "frutiger linotype", "lucida grande", "verdana", sans-serif;
padding: 1%;
width:98%;
width: 98%;
}
select {
clear: both;
@ -337,8 +337,8 @@ div.checkbox label {
display: inline;
}
input[type=radio] {
float:left;
width:auto;
float: left;
width: auto;
margin: 6px 0;
padding: 0;
line-height: 26px;
@ -353,7 +353,7 @@ input[type=submit] {
width: auto;
}
form .submit input[type=submit] {
background:#62af56;
background: #62af56;
background-image: -webkit-gradient(linear, left top, left bottom, from(#76BF6B), to(#3B8230));
background-image: -webkit-linear-gradient(top, #76BF6B, #3B8230);
background-image: -moz-linear-gradient(top, #76BF6B, #3B8230);
@ -491,7 +491,7 @@ p.error em {
padding: 0;
}
.actions li {
margin:0 0 0.5em 0;
margin: 0 0 0.5em 0;
list-style-type: none;
white-space: nowrap;
padding: 0;
@ -506,7 +506,7 @@ p.error em {
input[type=submit],
.actions ul li a,
.actions a {
font-weight:normal;
font-weight: normal;
padding: 4px 8px;
background: #dcdcdc;
background-image: -webkit-gradient(linear, left top, left bottom, from(#fefefe), to(#dcdcdc));
@ -515,8 +515,8 @@ input[type=submit],
background-image: -ms-linear-gradient(top, #fefefe, #dcdcdc);
background-image: -o-linear-gradient(top, #fefefe, #dcdcdc);
background-image: linear-gradient(top, #fefefe, #dcdcdc);
color:#333;
border:1px solid #bbb;
color: #333;
border: 1px solid #bbb;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
@ -661,50 +661,50 @@ pre {
background-color: rgba(255, 255, 0, 0.5);
}
.code-coverage-results div.code-line {
padding-left:5px;
display:block;
margin-left:10px;
padding-left: 5px;
display: block;
margin-left: 10px;
}
.code-coverage-results div.uncovered span.content {
background:#ecc;
background: #ecc;
}
.code-coverage-results div.covered span.content {
background:#cec;
background: #cec;
}
.code-coverage-results div.ignored span.content {
color:#aaa;
color: #aaa;
}
.code-coverage-results span.line-num {
color:#666;
display:block;
float:left;
width:20px;
text-align:right;
margin-right:5px;
color: #666;
display: block;
float: left;
width: 20px;
text-align: right;
margin-right: 5px;
}
.code-coverage-results span.line-num strong {
color:#666;
color: #666;
}
.code-coverage-results div.start {
border:1px solid #aaa;
border-width:1px 1px 0px 1px;
margin-top:30px;
padding-top:5px;
border: 1px solid #aaa;
border-width: 1px 1px 0px 1px;
margin-top: 30px;
padding-top: 5px;
}
.code-coverage-results div.end {
border:1px solid #aaa;
border-width:0px 1px 1px 1px;
margin-bottom:30px;
padding-bottom:5px;
border: 1px solid #aaa;
border-width: 0px 1px 1px 1px;
margin-bottom: 30px;
padding-bottom: 5px;
}
.code-coverage-results div.realstart {
margin-top:0px;
margin-top: 0px;
}
.code-coverage-results p.note {
color:#bbb;
padding:5px;
margin:5px 0 10px;
font-size:10px;
color: #bbb;
padding: 5px;
margin: 5px 0 10px;
font-size: 10px;
}
.code-coverage-results span.result-bad {
color: #a00;
@ -718,5 +718,5 @@ pre {
/** Elements **/
#url-rewriting-warning {
display:none;
display: none;
}

View file

@ -63,7 +63,7 @@ class CakeErrorController extends AppController {
public function beforeRender() {
parent::beforeRender();
foreach ($this->viewVars as $key => $value) {
if (!is_object($value)){
if (!is_object($value)) {
$this->viewVars[$key] = h($value);
}
}

View file

@ -90,7 +90,7 @@ abstract class BaseAuthenticate {
}
/**
* Hash the plain text password so that it matches the hashed/encrytped password
* Hash the plain text password so that it matches the hashed/encrypted password
* in the datasource.
*
* @param string $password The plain text password.
@ -111,7 +111,7 @@ abstract class BaseAuthenticate {
/**
* Allows you to hook into AuthComponent::logout(),
* and implement specialized logout behaviour.
* and implement specialized logout behavior.
*
* All attached authentication objects will have this method
* called when a user logs out.

View file

@ -204,7 +204,7 @@ class AuthComponent extends Component {
/**
* Error to display when user attempts to access an object or action to which they do not have
* acccess.
* access.
*
* @var string
* @link http://book.cakephp.org/2.0/en/core-libraries/components/authentication.html#AuthComponent::$authError
@ -268,8 +268,8 @@ class AuthComponent extends Component {
return true;
}
$methods = array_flip($controller->methods);
$action = $controller->request->params['action'];
$methods = array_flip(array_map('strtolower', $controller->methods));
$action = strtolower($controller->request->params['action']);
$isMissingAction = (
$controller->scaffold === false &&
@ -296,7 +296,7 @@ class AuthComponent extends Component {
$allowedActions = $this->allowedActions;
$isAllowed = (
$this->allowedActions == array('*') ||
in_array($action, $allowedActions)
in_array($action, array_map('strtolower', $allowedActions))
);
if ($loginAction != $url && $isAllowed) {

View file

@ -198,6 +198,7 @@ class CookieComponent extends Component {
* @param boolean $encrypt Set to true to encrypt value, false otherwise
* @param string $expires Can be either Unix timestamp, or date string
* @return void
* @link http://book.cakephp.org/2.0/en/core-libraries/components/cookie.html#CookieComponent::write
*/
public function write($key, $value = null, $encrypt = true, $expires = null) {
if (is_null($encrypt)) {
@ -234,6 +235,7 @@ class CookieComponent extends Component {
*
* @param mixed $key Key of the value to be obtained. If none specified, obtain map key => values
* @return string or null, value for specified key
* @link http://book.cakephp.org/2.0/en/core-libraries/components/cookie.html#CookieComponent::read
*/
public function read($key = null) {
if (empty($this->_values) && isset($_COOKIE[$this->name])) {
@ -269,6 +271,7 @@ class CookieComponent extends Component {
*
* @param string $key Key of the value to be deleted
* @return void
* @link http://book.cakephp.org/2.0/en/core-libraries/components/cookie.html#CookieComponent::delete
*/
public function delete($key) {
if (empty($this->_values)) {
@ -298,6 +301,7 @@ class CookieComponent extends Component {
* Failure to do so will result in header already sent errors.
*
* @return void
* @link http://book.cakephp.org/2.0/en/core-libraries/components/cookie.html#CookieComponent::destroy
*/
public function destroy() {
if (isset($_COOKIE[$this->name])) {
@ -407,6 +411,7 @@ class CookieComponent extends Component {
protected function _setcookie($name, $value, $expire, $path, $domain, $secure, $httpOnly = false) {
setcookie($name, $value, $expire, $path, $domain, $secure, $httpOnly);
}
/**
* Encrypts $value using public $type method in Security class
*

View file

@ -93,8 +93,8 @@ class EmailComponent extends Component {
public $bcc = array();
/**
* The date to put in the Date: header. This should be a date
* conformant with the RFC2822 standard. Leave null, to have
* The date to put in the Date: header. This should be a date
* conforming with the RFC2822 standard. Leave null, to have
* today's date generated.
*
* @var string
@ -198,7 +198,7 @@ class EmailComponent extends Component {
public $xMailer = 'CakePHP Email Component';
/**
* The list of paths to search if an attachment isnt absolute
* The list of paths to search if an attachment isn't absolute
*
* @var array
*/
@ -465,7 +465,7 @@ class EmailComponent extends Component {
/**
* Remove certain elements (such as bcc:, to:, %0a) from given value.
* Helps prevent header injection / mainipulation on user content.
* Helps prevent header injection / manipulation on user content.
*
* @param string $value Value to strip
* @param boolean $message Set to true to indicate main message content

View file

@ -19,7 +19,7 @@
/**
* This component is used to handle automatic model data pagination. The primary way to use this
* component is to call the paginate() method. There is a convience wrapper on Controller as well.
* component is to call the paginate() method. There is a convenience wrapper on Controller as well.
*
* ### Configuring pagination
*

View file

@ -485,7 +485,7 @@ class RequestHandlerComponent extends Component {
* 'html', 'xml', 'js', etc.
* @return mixed If $type is null or not provided, the first content-type in the
* list, based on preference, is returned. If a single type is provided
* a boolean will be returnend if that type is preferred.
* a boolean will be returned if that type is preferred.
* If an array of types are provided then the first preferred type is returned.
* If no type is provided the first preferred type is returned.
* @see RequestHandlerComponent::setContent()

View file

@ -106,7 +106,7 @@ class App {
'view' => array('suffix' => 'View', 'extends' => null, 'core' => true),
'helper' => array('suffix' => 'Helper', 'extends' => 'AppHelper', 'core' => true),
'vendor' => array('extends' => null, 'core' => true),
'shell' => array('suffix' => 'Shell', 'extends' => 'Shell', 'core' => true),
'shell' => array('suffix' => 'Shell', 'extends' => 'AppShell', 'core' => true),
'plugin' => array('extends' => null, 'core' => true)
);
@ -819,7 +819,7 @@ class App {
/**
* Sets then returns the templates for each customizable package path
*
*
* @return array templates for each customizable package path
*/
protected static function _packageFormat() {

View file

@ -55,7 +55,7 @@ class Object {
* or tie plugins into a main application. requestAction can be used to return rendered views
* or fetch the return value from controller actions.
*
* Under the hood this method uses Router::reverse() to convert the $url parmeter into a string
* Under the hood this method uses Router::reverse() to convert the $url parameter into a string
* URL. You should use URL formats that are compatible with Router::reverse()
*
* #### Passing POST and GET data
@ -64,7 +64,7 @@ class Object {
* GET data. The `$extra['data']` parameter allows POST data simulation.
*
* @param mixed $url String or array-based url. Unlike other url arrays in CakePHP, this
* url will not automatically handle passed and named arguments in the $url paramenter.
* url will not automatically handle passed and named arguments in the $url parameter.
* @param array $extra if array includes the key "return" it sets the AutoRender to true. Can
* also be used to submit GET/POST data, and named/passed arguments.
* @return mixed Boolean true or false on success/failure, or contents
@ -144,7 +144,7 @@ class Object {
}
/**
* Convience method to write a message to CakeLog. See CakeLog::write()
* Convenience method to write a message to CakeLog. See CakeLog::write()
* for more information on writing to logs.
*
* @param string $msg Log message

View file

@ -511,7 +511,7 @@ class I18n {
continue;
}
$mustEscape = array($escape . ',' , $escape . ';', $escape . '<', $escape . '>', $escape . $escape);
$mustEscape = array($escape . ',', $escape . ';', $escape . '<', $escape . '>', $escape . $escape);
$replacements = array_map('crc32', $mustEscape);
$value = str_replace($mustEscape, $replacements, $value);
$value = explode(';', $value);

View file

@ -259,7 +259,7 @@ class ContainableBehavior extends ModelBehavior {
* @param Model $Model Model on which binding restriction is being applied
* @param array $contain Parameters to use for restricting this model
* @param array $containments Current set of containments
* @param boolean $throwErrors Wether unexisting bindings show throw errors
* @param boolean $throwErrors Whether non-existent bindings show throw errors
* @return array Containments
*/
public function containments($Model, $contain, $containments = array(), $throwErrors = null) {
@ -349,7 +349,7 @@ class ContainableBehavior extends ModelBehavior {
}
if (!isset($containments['models'][$Model->alias])) {
$containments['models'][$Model->alias] = array('keep' => array(),'instance' => &$Model);
$containments['models'][$Model->alias] = array('keep' => array(), 'instance' => &$Model);
}
$containments['models'][$Model->alias]['keep'] = array_merge($containments['models'][$Model->alias]['keep'], $keep);

View file

@ -38,7 +38,7 @@ class TranslateBehavior extends ModelBehavior {
* Callback
*
* $config for TranslateBehavior should be
* array( 'fields' => array('field_one',
* array('fields' => array('field_one',
* 'field_two' => 'FieldAssoc', 'field_three'))
*
* With above example only one permanent hasMany will be joined (for field_two

View file

@ -73,7 +73,7 @@ class TreeBehavior extends ModelBehavior {
/**
* After save method. Called after all saves
*
* Overriden to transparently manage setting the lft and rght fields if and only if the parent field is included in the
* Overridden to transparently manage setting the lft and rght fields if and only if the parent field is included in the
* parameters to be saved.
*
* @param Model $Model Model instance.
@ -125,7 +125,7 @@ class TreeBehavior extends ModelBehavior {
/**
* Before save method. Called before all saves
*
* Overriden to transparently manage setting the lft and rght fields if and only if the parent field is included in the
* Overridden to transparently manage setting the lft and rght fields if and only if the parent field is included in the
* parameters to be saved. For newly created nodes with NO parent the left and right field values are set directly by
* this method bypassing the setParent logic.
*
@ -562,7 +562,7 @@ class TreeBehavior extends ModelBehavior {
$Model->recursive = $recursive;
if ($mode == 'parent') {
$Model->bindModel(array('belongsTo' => array('VerifyParent' => array(
'className' => $Model->alias,
'className' => $Model->name,
'foreignKey' => $parent,
'fields' => array($Model->primaryKey, $left, $right, $parent),
))));
@ -624,7 +624,7 @@ class TreeBehavior extends ModelBehavior {
* Options:
*
* - 'id' id of record to use as top node for reordering
* - 'field' Which field to use in reordeing defaults to displayField
* - 'field' Which field to use in reordering defaults to displayField
* - 'order' Direction to order either DESC or ASC (defaults to ASC)
* - 'verify' Whether or not to verify the tree before reorder. defaults to true.
*
@ -770,7 +770,7 @@ class TreeBehavior extends ModelBehavior {
}
$Model->bindModel(array('belongsTo' => array('VerifyParent' => array(
'className' => $Model->alias,
'className' => $Model->name,
'foreignKey' => $parent,
'fields' => array($Model->primaryKey, $left, $right, $parent)
))));

View file

@ -207,7 +207,7 @@ class BehaviorCollection extends ObjectCollection {
/**
* Dispatches a behavior method. Will call either normal methods or mapped methods.
*
* If a method is not handeled by the BehaviorCollection, and $strict is false, a
* If a method is not handled by the BehaviorCollection, and $strict is false, a
* special return of `array('unhandled')` will be returned to signal the method was not found.
*
* @param Model $model The model the method was originally called on.
@ -252,8 +252,8 @@ class BehaviorCollection extends ObjectCollection {
*
* @param string $method The method to find.
* @param boolean $callback Return the callback for the method.
* @return mixed If $callback is false, a boolean will be returnned, if its true, an array
* containing callback information will be returnned. For mapped methods the array will have 3 elements.
* @return mixed If $callback is false, a boolean will be returned, if its true, an array
* containing callback information will be returned. For mapped methods the array will have 3 elements.
*/
public function hasMethod($method, $callback = false) {
if (isset($this->_methods[$method])) {

View file

@ -351,21 +351,21 @@ class CakeSchema extends Object {
get_object_vars($this), $options
));
$out = "class {$name}Schema extends CakeSchema {\n";
$out = "class {$name}Schema extends CakeSchema {\n\n";
if ($path !== $this->path) {
$out .= "\tvar \$path = '{$path}';\n\n";
$out .= "\tpublic \$path = '{$path}';\n\n";
}
if ($file !== $this->file) {
$out .= "\tvar \$file = '{$file}';\n\n";
$out .= "\tpublic \$file = '{$file}';\n\n";
}
if ($connection !== 'default') {
$out .= "\tvar \$connection = '{$connection}';\n\n";
$out .= "\tpublic \$connection = '{$connection}';\n\n";
}
$out .= "\tfunction before(\$event = array()) {\n\t\treturn true;\n\t}\n\n\tfunction after(\$event = array()) {\n\t}\n\n";
$out .= "\tpublic function before(\$event = array()) {\n\t\treturn true;\n\t}\n\n\tpublic function after(\$event = array()) {\n\t}\n\n";
if (empty($tables)) {
$this->read();
@ -395,14 +395,14 @@ class CakeSchema extends Object {
* @return string Variable declaration for a schema class
*/
public function generateTable($table, $fields) {
$out = "\tvar \${$table} = array(\n";
$out = "\tpublic \${$table} = array(\n";
if (is_array($fields)) {
$cols = array();
foreach ($fields as $field => $value) {
if ($field != 'indexes' && $field != 'tableParameters') {
if (is_string($value)) {
$type = $value;
$value = array('type'=> $type);
$value = array('type' => $type);
}
$col = "\t\t'{$field}' => array('type' => '" . $value['type'] . "', ";
unset($value['type']);

View file

@ -181,7 +181,7 @@ class Mysql extends DboSource {
* Returns an array of sources (tables) in the database.
*
* @param mixed $data
* @return array Array of tablenames in the database
* @return array Array of table names in the database
*/
public function listSources($data = null) {
$cache = parent::listSources();
@ -238,7 +238,7 @@ class Mysql extends DboSource {
* @return mixed array with results fetched and mapped to column names or false if there is no results left to fetch
*/
public function fetchResult() {
if ($row = $this->_result->fetch()) {
if ($row = $this->_result->fetch(PDO::FETCH_NUM)) {
$resultRow = array();
foreach ($this->map as $col => $meta) {
list($table, $column, $type) = $meta;
@ -543,11 +543,11 @@ class Mysql extends DboSource {
}
/**
* Generate MySQL table parameter alteration statementes for a table.
* Generate MySQL table parameter alteration statements for a table.
*
* @param string $table Table to alter parameters for.
* @param array $parameters Parameters to add & drop.
* @return array Array of table property alteration statementes.
* @return array Array of table property alteration statements.
* @todo Implement this method.
*/
protected function _alterTableParameters($table, $parameters) {
@ -567,7 +567,7 @@ class Mysql extends DboSource {
protected function _alterIndexes($table, $indexes) {
$alter = array();
if (isset($indexes['drop'])) {
foreach($indexes['drop'] as $name => $value) {
foreach ($indexes['drop'] as $name => $value) {
$out = 'DROP ';
if ($name == 'PRIMARY') {
$out .= 'PRIMARY KEY';
@ -603,7 +603,7 @@ class Mysql extends DboSource {
* Returns an detailed array of sources (tables) in the database.
*
* @param string $name Table name to get parameters
* @return array Array of tablenames in the database
* @return array Array of table names in the database
*/
public function listDetailedSources($name = null) {
$condition = '';

View file

@ -153,7 +153,7 @@ class Postgres extends DboSource {
* Returns an array of tables in the database. If there are no tables, an error is raised and the application exits.
*
* @param mixed $data
* @return array Array of tablenames in the database
* @return array Array of table names in the database
*/
public function listSources($data = null) {
$cache = parent::listSources();
@ -296,7 +296,7 @@ class Postgres extends DboSource {
* Deletes all the records in a table and drops all associated auto-increment sequences
*
* @param mixed $table A string or model class representing the table to be truncated
* @param boolean $reset true for resseting the sequence, false to leave it as is.
* @param boolean $reset true for resetting the sequence, false to leave it as is.
* and if 1, sequences are not modified
* @return boolean SQL TRUNCATE TABLE statement, false if not applicable.
*/
@ -338,7 +338,7 @@ class Postgres extends DboSource {
* Generates the fields list of an SQL query.
*
* @param Model $model
* @param string $alias Alias tablename
* @param string $alias Alias table name
* @param mixed $fields
* @param boolean $quote
* @return array
@ -398,7 +398,7 @@ class Postgres extends DboSource {
* Quotes the fields in a function call.
*
* @param string $match matched string
* @return string quoted strig
* @return string quoted string
*/
protected function _quoteFunctionField($match) {
$prepend = '';
@ -410,7 +410,7 @@ class Postgres extends DboSource {
if (!$constant && strpos($match[1], '.') === false) {
$match[1] = $this->name($match[1]);
} elseif (!$constant){
} elseif (!$constant) {
$parts = explode('.', $match[1]);
if (!Set::numeric($parts)) {
$match[1] = $this->name($match[1]);
@ -551,7 +551,7 @@ class Postgres extends DboSource {
protected function _alterIndexes($table, $indexes) {
$alter = array();
if (isset($indexes['drop'])) {
foreach($indexes['drop'] as $name => $value) {
foreach ($indexes['drop'] as $name => $value) {
$out = 'DROP ';
if ($name == 'PRIMARY') {
continue;
@ -708,7 +708,7 @@ class Postgres extends DboSource {
* @return array
*/
public function fetchResult() {
if ($row = $this->_result->fetch()) {
if ($row = $this->_result->fetch(PDO::FETCH_NUM)) {
$resultRow = array();
foreach ($this->map as $index => $meta) {
@ -738,7 +738,7 @@ class Postgres extends DboSource {
* Translates between PHP boolean values and PostgreSQL boolean values
*
* @param mixed $data Value to be translated
* @param boolean $quote true to quote a boolean to be used in a query, flase to return the boolean value
* @param boolean $quote true to quote a boolean to be used in a query, false to return the boolean value
* @return boolean Converted boolean value
*/
public function boolean($data, $quote = false) {

View file

@ -131,7 +131,7 @@ class Sqlite extends DboSource {
* Returns an array of tables in the database. If there are no tables, an error is raised and the application exits.
*
* @param mixed $data
* @return array Array of tablenames in the database
* @return array Array of table names in the database
*/
public function listSources($data = null) {
$cache = parent::listSources();
@ -286,9 +286,9 @@ class Sqlite extends DboSource {
}
} elseif (strpos($querystring, 'PRAGMA table_info') === 0) {
$selects = array('cid', 'name', 'type', 'notnull', 'dflt_value', 'pk');
} elseif(strpos($querystring, 'PRAGMA index_list') === 0) {
} elseif (strpos($querystring, 'PRAGMA index_list') === 0) {
$selects = array('seq', 'name', 'unique');
} elseif(strpos($querystring, 'PRAGMA index_info') === 0) {
} elseif (strpos($querystring, 'PRAGMA index_info') === 0) {
$selects = array('seqno', 'cid', 'name');
}
while ($j < $num_fields) {
@ -297,7 +297,7 @@ class Sqlite extends DboSource {
continue;
}
if (preg_match('/\bAS\s+(.*)/i', $selects[$j], $matches)) {
$columnName = trim($matches[1],'"');
$columnName = trim($matches[1], '"');
} else {
$columnName = trim(str_replace('"', '', $selects[$j]));
}
@ -330,7 +330,7 @@ class Sqlite extends DboSource {
* @return mixed array with results fetched and mapped to column names or false if there is no results left to fetch
*/
public function fetchResult() {
if ($row = $this->_result->fetch()) {
if ($row = $this->_result->fetch(PDO::FETCH_NUM)) {
$resultRow = array();
foreach ($this->map as $col => $meta) {
list($table, $column, $type) = $meta;
@ -460,7 +460,7 @@ class Sqlite extends DboSource {
}
/**
* Overrides DboSource::index to handle SQLite indexe introspection
* Overrides DboSource::index to handle SQLite index introspection
* Returns an array of the indexes in given table name.
*
* @param string $model Name of model to inspect

View file

@ -167,7 +167,7 @@ class Sqlserver extends DboSource {
* Returns an array of sources (tables) in the database.
*
* @param mixed $data
* @return array Array of tablenames in the database
* @return array Array of table names in the database
*/
public function listSources($data = null) {
$cache = parent::listSources();
@ -260,7 +260,7 @@ class Sqlserver extends DboSource {
* Generates the fields list of an SQL query.
*
* @param Model $model
* @param string $alias Alias tablename
* @param string $alias Alias table name
* @param array $fields
* @param boolean $quote
* @return array
@ -607,7 +607,7 @@ class Sqlserver extends DboSource {
* @return mixed
*/
public function fetchResult() {
if ($row = $this->_result->fetch()) {
if ($row = $this->_result->fetch(PDO::FETCH_NUM)) {
$resultRow = array();
foreach ($this->map as $col => $meta) {
list($table, $column, $type) = $meta;
@ -748,8 +748,8 @@ class Sqlserver extends DboSource {
* @param string $sql SQL statement
* @param array $params list of params to be bound to query (supported only in select)
* @param array $prepareOptions Options to be used in the prepare statement
* @return mixed PDOStatement if query executes with no problem, true as the result of a succesfull, false on error
* query returning no rows, suchs as a CREATE statement, false otherwise
* @return mixed PDOStatement if query executes with no problem, true as the result of a successful, false on error
* query returning no rows, such as a CREATE statement, false otherwise
*/
protected function _execute($sql, $params = array(), $prepareOptions = array()) {
$this->_lastAffected = false;

View file

@ -135,7 +135,7 @@ class DboSource extends DataSource {
protected $_queriesLogMax = 200;
/**
* Caches serialzed results of executed queries
* Caches serialized results of executed queries
*
* @var array Maximum number of queries in the queries log.
*/
@ -344,7 +344,7 @@ class DboSource extends DataSource {
/**
* Returns an object to represent a database identifier in a query. Expression objects
* are not sanitized or esacped.
* are not sanitized or escaped.
*
* @param string $identifier A SQL expression to be used as an identifier
* @return stdClass An object representing a database identifier to be used in a query
@ -358,7 +358,7 @@ class DboSource extends DataSource {
/**
* Returns an object to represent a database expression in a query. Expression objects
* are not sanitized or esacped.
* are not sanitized or escaped.
*
* @param string $expression An arbitrary SQL expression to be inserted into a query.
* @return stdClass An object representing a database expression to be used in a query
@ -418,7 +418,7 @@ class DboSource extends DataSource {
* @param array $params list of params to be bound to query
* @param array $prepareOptions Options to be used in the prepare statement
* @return mixed PDOStatement if query executes with no problem, true as the result of a successful, false on error
* query returning no rows, suchs as a CREATE statement, false otherwise
* query returning no rows, such as a CREATE statement, false otherwise
*/
protected function _execute($sql, $params = array(), $prepareOptions = array()) {
$sql = trim($sql);
@ -744,7 +744,7 @@ class DboSource extends DataSource {
* A read will either return the value or null.
*
* @param string $method Name of the method being cached.
* @param string $key The keyname for the cache operation.
* @param string $key The key name for the cache operation.
* @param mixed $value The value to cache into memory.
* @return mixed Either null on failure, or the value if its set.
*/
@ -1807,7 +1807,7 @@ class DboSource extends DataSource {
* @param array $fields
* @param boolean $quoteValues If values should be quoted, or treated as SQL snippets
* @param boolean $alias Include the model alias in the field name
* @return array Fields and values, quoted and preparted
* @return array Fields and values, quoted and prepared
*/
protected function _prepareUpdateFields($model, $fields, $quoteValues = true, $alias = false) {
$quotedAlias = $this->startQuote . $model->alias . $this->endQuote;
@ -1963,7 +1963,7 @@ class DboSource extends DataSource {
if (!isset($params[1])) {
$params[1] = 'count';
}
if (is_object($model) && $model->isVirtualField($params[0])){
if (is_object($model) && $model->isVirtualField($params[0])) {
$arg = $this->_quoteFields($model->getVirtualField($params[0]));
} else {
$arg = $this->name($params[0]);
@ -2064,7 +2064,7 @@ class DboSource extends DataSource {
*
* @param Model $model
* @param mixed $conditions Array of conditions, conditions string, null or false. If an array of conditions,
* or string conditions those conditions will be returned. With other values the model's existance will be checked.
* or string conditions those conditions will be returned. With other values the model's existence will be checked.
* If the model doesn't exist a null or false will be returned depending on the input value.
* @param boolean $useAlias Use model aliases rather than table names when generating conditions
* @return mixed Either null, false, $conditions or an array of default conditions to use.
@ -2126,7 +2126,7 @@ class DboSource extends DataSource {
* Converts model virtual fields into sql expressions to be fetched later
*
* @param Model $model
* @param string $alias Alias tablename
* @param string $alias Alias table name
* @param mixed $fields virtual fields to be used on query
* @return array
*/
@ -2144,7 +2144,7 @@ class DboSource extends DataSource {
* Generates the fields list of an SQL query.
*
* @param Model $model
* @param string $alias Alias tablename
* @param string $alias Alias table name
* @param mixed $fields
* @param boolean $quote If false, returns fields array unquoted
* @return array
@ -2207,7 +2207,7 @@ class DboSource extends DataSource {
}
if (is_object($fields[$i]) && isset($fields[$i]->type) && $fields[$i]->type === 'expression') {
$fields[$i] = $fields[$i]->value;
} elseif (preg_match('/^\(.*\)\s' . $this->alias . '.*/i', $fields[$i])){
} elseif (preg_match('/^\(.*\)\s' . $this->alias . '.*/i', $fields[$i])) {
continue;
} elseif (!preg_match('/^.+\\(.*\\)/', $fields[$i])) {
$prepend = '';
@ -2521,7 +2521,7 @@ class DboSource extends DataSource {
* Auxiliary function to quote matches `Model.fields` from a preg_replace_callback call
*
* @param string $match matched string
* @return string quoted strig
* @return string quoted string
*/
protected function _quoteMatchedField($match) {
if (is_numeric($match[0])) {
@ -2638,7 +2638,7 @@ class DboSource extends DataSource {
if (!is_array($group)) {
$group = array($group);
}
foreach($group as $index => $key) {
foreach ($group as $index => $key) {
if (is_object($model) && $model->isVirtualField($key)) {
$group[$index] = '(' . $model->getVirtualField($key) . ')';
}
@ -2893,7 +2893,7 @@ class DboSource extends DataSource {
/**
* Generate a database-native column schema string
*
* @param array $column An array structured like the following: array('name'=>'value', 'type'=>'value'[, options]),
* @param array $column An array structured like the following: array('name' => 'value', 'type' => 'value'[, options]),
* where options can be 'default', 'length', or 'key'.
* @return string
*/
@ -2927,7 +2927,7 @@ class DboSource extends DataSource {
$out .= '(' . $length . ')';
}
if (($column['type'] === 'integer' || $column['type'] === 'float' ) && isset($column['default']) && $column['default'] === '') {
if (($column['type'] === 'integer' || $column['type'] === 'float') && isset($column['default']) && $column['default'] === '') {
$column['default'] = null;
}
$out = $this->_buildFieldParameters($out, $column, 'beforeDefault');

View file

@ -47,13 +47,13 @@ class DatabaseSession implements CakeSessionHandlerInterface {
if (empty($modelName)) {
$settings = array(
'class' =>'Session',
'class' => 'Session',
'alias' => 'Session',
'table' => 'cake_sessions',
);
} else {
$settings = array(
'class' =>$modelName,
'class' => $modelName,
'alias' => 'Session',
);
}

View file

@ -25,6 +25,7 @@
App::uses('ClassRegistry', 'Utility');
App::uses('Validation', 'Utility');
App::uses('String', 'Utility');
App::uses('Set', 'Utility');
App::uses('BehaviorCollection', 'Model');
App::uses('ModelBehavior', 'Model');
App::uses('ConnectionManager', 'Model');
@ -544,7 +545,7 @@ class Model extends Object {
*/
protected $_associationKeys = array(
'belongsTo' => array('className', 'foreignKey', 'conditions', 'fields', 'order', 'counterCache'),
'hasOne' => array('className', 'foreignKey','conditions', 'fields','order', 'dependent'),
'hasOne' => array('className', 'foreignKey', 'conditions', 'fields', 'order', 'dependent'),
'hasMany' => array('className', 'foreignKey', 'conditions', 'fields', 'order', 'limit', 'offset', 'dependent', 'exclusive', 'finderQuery', 'counterQuery'),
'hasAndBelongsToMany' => array('className', 'joinTable', 'with', 'foreignKey', 'associationForeignKey', 'conditions', 'fields', 'order', 'limit', 'offset', 'unique', 'finderQuery', 'deleteQuery', 'insertQuery')
);
@ -732,7 +733,7 @@ class Model extends Object {
/**
* Handles the lazy loading of model associations by looking in the association arrays for the requested variable
*
* @param string $name variable tested for existance in class
* @param string $name variable tested for existence in class
* @return boolean true if the variable exists (if is a not loaded model association it will be created), false otherwise
*/
public function __isset($name) {
@ -1403,7 +1404,7 @@ class Model extends Object {
* Returns a list of fields from the database, and sets the current model
* data (Model::$data) with the record found.
*
* @param mixed $fields String of single fieldname, or an array of fieldnames.
* @param mixed $fields String of single field name, or an array of field names.
* @param mixed $id The ID of the record to read
* @return array Array of database fields, or false if not found
* @link http://book.cakephp.org/2.0/en/models/retrieving-your-data.html#model-read
@ -1866,7 +1867,7 @@ class Model extends Object {
}
/**
* Backwards compatible passtrough method for:
* Backwards compatible passthrough method for:
* saveMany(), validateMany(), saveAssociated() and validateAssociated()
*
* Saves multiple individual records for a single model; Also works with a single record, as well as
@ -2153,7 +2154,7 @@ class Model extends Object {
if (in_array($associations[$association], array('belongsTo', 'hasOne'))) {
$validates = $this->{$association}->create($values) && $this->{$association}->validates($options);
$return[$association][] = $validates;
} elseif($associations[$association] === 'hasMany') {
} elseif ($associations[$association] === 'hasMany') {
$validates = $this->{$association}->validateMany($values, $options);
$return[$association] = $validates;
}
@ -2266,11 +2267,17 @@ class Model extends Object {
if ($data['dependent'] === true) {
$model = $this->{$assoc};
$conditions = array($model->escapeField($data['foreignKey']) => $id);
if ($data['conditions']) {
$conditions = array_merge((array)$data['conditions'], $conditions);
if ($data['foreignKey'] === false && $data['conditions'] && in_array($this->name, $model->getAssociated('belongsTo'))) {
$model->recursive = 0;
$conditions = array($this->escapeField(null, $this->name) => $id);
} else {
$model->recursive = -1;
$conditions = array($model->escapeField($data['foreignKey']) => $id);
if ($data['conditions']) {
$conditions = array_merge((array)$data['conditions'], $conditions);
}
}
$model->recursive = -1;
if (isset($data['exclusive']) && $data['exclusive']) {
$model->deleteAll($conditions);

View file

@ -185,7 +185,7 @@ class CakeRequest implements ArrayAccess {
$query = $_GET;
}
unset($query['/' . $this->url]);
unset($query['/' . str_replace('.', '_', $this->url)]);
if (strpos($this->url, '?') !== false) {
list(, $querystr) = explode('?', $this->url);
parse_str($querystr, $queryArgs);
@ -279,10 +279,10 @@ class CakeRequest implements ArrayAccess {
$docRootContainsWebroot = strpos($docRoot, $dir . '/' . $webroot);
if (!empty($base) || !$docRootContainsWebroot) {
if (strpos($this->webroot, $dir) === false) {
if (strpos($this->webroot, '/' . $dir . '/') === false) {
$this->webroot .= $dir . '/' ;
}
if (strpos($this->webroot, $webroot) === false) {
if (strpos($this->webroot, '/' . $webroot . '/') === false) {
$this->webroot .= $webroot . '/';
}
}
@ -489,7 +489,7 @@ class CakeRequest implements ArrayAccess {
* ### Callback detectors
*
* Callback detectors allow you to provide a 'callback' type to handle the check. The callback will
* recieve the request object as its only parameter.
* receive the request object as its only parameter.
*
* e.g `addDetector('custom', array('callback' => array('SomeClass', 'somemethod')));`
*

View file

@ -423,7 +423,7 @@ class CakeResponse {
* will have the same effect as only doing `header('WWW-Authenticate: Not-Negotiate');`
*
* @param mixed $header. An array of header strings or a single header string
* - an assotiative array of "header name" => "header value" is also accepted
* - an associative array of "header name" => "header value" is also accepted
* - an array of string headers is also accepted
* @param mixed $value. The header value.
* @return array list of headers to be sent
@ -674,7 +674,7 @@ class CakeResponse {
}
/**
* Sets the correct headers to instruct the browser to dowload the response as a file.
* Sets the correct headers to instruct the browser to download the response as a file.
*
* @param string $filename the name of the file as the browser will download the response
* @return void

View file

@ -42,7 +42,7 @@ class DigestAuthentication {
}
/**
* Retrive information about the authetication
* Retrieve information about the authentication
*
* @param HttpSocket $http
* @param array $authInfo

View file

@ -74,7 +74,7 @@ class HttpResponse implements ArrayAccess {
public $raw = '';
/**
* Contructor
* Constructor
*
* @param string $message
*/
@ -177,7 +177,7 @@ class HttpResponse implements ArrayAccess {
* Generic function to decode a $body with a given $encoding. Returns either an array with the keys
* 'body' and 'header' or false on failure.
*
* @param string $body A string continaing the body to decode.
* @param string $body A string containing the body to decode.
* @param mixed $encoding Can be false in case no encoding is being used, or a string representing the encoding.
* @return mixed Array of response headers and body or false.
*/
@ -200,7 +200,7 @@ class HttpResponse implements ArrayAccess {
* Decodes a chunked message $body and returns either an array with the keys 'body' and 'header' or false as
* a result.
*
* @param string $body A string continaing the chunked body to decode.
* @param string $body A string containing the chunked body to decode.
* @return mixed Array of response headers and body or false.
* @throws SocketException
*/
@ -292,7 +292,7 @@ class HttpResponse implements ArrayAccess {
* Parses cookies in response headers.
*
* @param array $header Header array containing one ore more 'Set-Cookie' headers.
* @return mixed Either false on no cookies, or an array of cookies recieved.
* @return mixed Either false on no cookies, or an array of cookies received.
* @todo Make this 100% RFC 2965 confirm
*/
public function parseCookies($header) {
@ -420,7 +420,7 @@ class HttpResponse implements ArrayAccess {
}
/**
* ArrayAccess - 0ffset Set
* ArrayAccess - Offset Set
*
* @param mixed $offset
* @param mixed $value

View file

@ -618,7 +618,7 @@ class HttpSocket extends CakeSocket {
*
* @param mixed $uri Either A $uri array, or a request string. Will use $this->config if left empty.
* @param string $uriTemplate The Uri template/format to use.
* @return mixed A fully qualified URL formated according to $uriTemplate, or false on failure
* @return mixed A fully qualified URL formatted according to $uriTemplate, or false on failure
*/
protected function _buildUri($uri = array(), $uriTemplate = '%scheme://%user:%pass@%host:%port/%path?%query#%fragment') {
if (is_string($uri)) {
@ -720,7 +720,7 @@ class HttpSocket extends CakeSocket {
/**
* This function can be thought of as a reverse to PHP5's http_build_query(). It takes a given query string and turns it into an array and
* supports nesting by using the php bracket syntax. So this menas you can parse queries like:
* supports nesting by using the php bracket syntax. So this means you can parse queries like:
*
* - ?key[subKey]=value
* - ?key[]=value1&key[]=value2

View file

@ -56,7 +56,7 @@ class Dispatcher {
* to autoRender, via Controller::$autoRender, then Dispatcher will render the view.
*
* Actions in CakePHP can be any public method on a controller, that is not declared in Controller. If you
* want controller methods to be public and in-accesible by URL, then prefix them with a `_`.
* want controller methods to be public and in-accessible by URL, then prefix them with a `_`.
* For example `public function _loadPosts() { }` would not be accessible via URL. Private and protected methods
* are also not accessible via URL.
*
@ -272,7 +272,7 @@ class Dispatcher {
if ($parts[0] === 'theme') {
$themeName = $parts[1];
unset($parts[0], $parts[1]);
$fileFragment = implode(DS, $parts);
$fileFragment = urldecode(implode(DS, $parts));
$path = App::themePath($themeName) . 'webroot' . DS;
if (file_exists($path . $fileFragment)) {
$assetFile = $path . $fileFragment;
@ -281,7 +281,7 @@ class Dispatcher {
$plugin = Inflector::camelize($parts[0]);
if (CakePlugin::loaded($plugin)) {
unset($parts[0]);
$fileFragment = implode(DS, $parts);
$fileFragment = urldecode(implode(DS, $parts));
$pluginWebroot = CakePlugin::path($plugin) . 'webroot' . DS;
if (file_exists($pluginWebroot . $fileFragment)) {
$assetFile = $pluginWebroot . $fileFragment;

View file

@ -1,13 +1,5 @@
<?php
/**
* A single Route used by the Router to connect requests to
* parameter maps.
*
* Not normally created as a standalone. Use Router::connect() to create
* Routes for your application.
*
* PHP5
*
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
@ -16,10 +8,20 @@
*
* @copyright Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP(tm) Project
* @package Cake.Routing.Route
* @since CakePHP(tm) v 1.3
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::uses('Set', 'Utility');
/**
* A single Route used by the Router to connect requests to
* parameter maps.
*
* Not normally created as a standalone. Use Router::connect() to create
* Routes for your application.
*
* @package Cake.Routing.Route
*/
class CakeRoute {
/**
@ -60,7 +62,7 @@ class CakeRoute {
protected $_greedy = false;
/**
* The compiled route regular expresssion
* The compiled route regular expression
*
* @var string
*/
@ -237,7 +239,7 @@ class CakeRoute {
// restructure 'pass' key route params
if (isset($this->options['pass'])) {
$j = count($this->options['pass']);
while($j--) {
while ($j--) {
if (isset($route[$this->options['pass'][$j]])) {
array_unshift($route['pass'], $route[$this->options['pass'][$j]]);
}
@ -349,7 +351,7 @@ class CakeRoute {
}
/**
* Apply persistent parameters to a url array. Persistant parameters are a special
* Apply persistent parameters to a url array. Persistent parameters are a special
* key used during route creation to force route parameters to persist when omitted from
* a url array.
*
@ -483,7 +485,8 @@ class CakeRoute {
$named = array();
foreach ($params['named'] as $key => $value) {
if (is_array($value)) {
foreach ($value as $namedKey => $namedValue) {
$flat = Set::flatten($value, '][');
foreach ($flat as $namedKey => $namedValue) {
$named[] = $key . "[$namedKey]" . $separator . rawurlencode($namedValue);
}
} else {

View file

@ -256,7 +256,7 @@ class BasicsTest extends CakeTestCase {
$this->assertEquals($expected, $result);
$result = am(array('one' => array(2, 3), 'two' => array('foo')), array('one' => array(4, 5)));
$expected = array('one' => array(4, 5),'two' => array('foo'));
$expected = array('one' => array(4, 5), 'two' => array('foo'));
$this->assertEquals($expected, $result);
}

View file

@ -126,6 +126,19 @@ class CacheTest extends CakeTestCase {
$read = Cache::read('Test', 'invalid');
}
/**
* Test reading from a config that is undefined.
*
* @return void
*/
public function testReadNonExistingConfig() {
$this->assertFalse(Cache::read('key', 'totally fake'));
$this->assertFalse(Cache::write('key', 'value', 'totally fake'));
$this->assertFalse(Cache::increment('key', 1, 'totally fake'));
$this->assertFalse(Cache::decrement('key', 1, 'totally fake'));
}
/**
* test that trying to configure classes that don't extend CacheEngine fail.
*
@ -148,10 +161,10 @@ class CacheTest extends CakeTestCase {
$_cacheConfigSessions = Cache::config('sessions');
$_cacheConfigTests = Cache::config('tests');
$result = Cache::config('sessions', array('engine'=> 'File', 'path' => TMP . 'sessions'));
$result = Cache::config('sessions', array('engine' => 'File', 'path' => TMP . 'sessions'));
$this->assertEquals($result['settings'], Cache::settings('sessions'));
$result = Cache::config('tests', array('engine'=> 'File', 'path' => TMP . 'tests'));
$result = Cache::config('tests', array('engine' => 'File', 'path' => TMP . 'tests'));
$this->assertEquals($result['settings'], Cache::settings('tests'));
Cache::config('sessions', $_cacheConfigSessions['settings']);
@ -322,7 +335,7 @@ class CacheTest extends CakeTestCase {
*/
public function testCacheDisable() {
Configure::write('Cache.disable', false);
Cache::config('test_cache_disable_1', array('engine'=> 'File', 'path' => TMP . 'tests'));
Cache::config('test_cache_disable_1', array('engine' => 'File', 'path' => TMP . 'tests'));
$this->assertTrue(Cache::write('key_1', 'hello', 'test_cache_disable_1'));
$this->assertSame(Cache::read('key_1', 'test_cache_disable_1'), 'hello');
@ -338,7 +351,7 @@ class CacheTest extends CakeTestCase {
$this->assertSame(Cache::read('key_3', 'test_cache_disable_1'), 'hello');
Configure::write('Cache.disable', true);
Cache::config('test_cache_disable_2', array('engine'=> 'File', 'path' => TMP . 'tests'));
Cache::config('test_cache_disable_2', array('engine' => 'File', 'path' => TMP . 'tests'));
$this->assertFalse(Cache::write('key_4', 'hello', 'test_cache_disable_2'));
$this->assertFalse(Cache::read('key_4', 'test_cache_disable_2'));

View file

@ -61,10 +61,10 @@ class FileEngineTest extends CakeTestCase {
* @return void
*/
public function testCacheDirChange() {
$result = Cache::config('sessions', array('engine'=> 'File', 'path' => TMP . 'sessions'));
$result = Cache::config('sessions', array('engine' => 'File', 'path' => TMP . 'sessions'));
$this->assertEquals($result['settings'], Cache::settings('sessions'));
$result = Cache::config('sessions', array('engine'=> 'File', 'path' => TMP . 'tests'));
$result = Cache::config('sessions', array('engine' => 'File', 'path' => TMP . 'tests'));
$this->assertEquals($result['settings'], Cache::settings('sessions'));
$this->assertNotEquals($result['settings'], Cache::settings('default'));
}
@ -276,7 +276,7 @@ class FileEngineTest extends CakeTestCase {
public function testRemoveWindowsSlashesFromCache() {
Cache::config('windows_test', array('engine' => 'File', 'isWindows' => true, 'prefix' => null, 'path' => TMP));
$expected = array (
$expected = array(
'C:\dev\prj2\sites\cake\libs' => array(
0 => 'C:\dev\prj2\sites\cake\libs', 1 => 'C:\dev\prj2\sites\cake\libs\view',
2 => 'C:\dev\prj2\sites\cake\libs\view\scaffolds', 3 => 'C:\dev\prj2\sites\cake\libs\view\pages',

View file

@ -81,7 +81,7 @@ class MemcacheEngineTest extends CakeTestCase {
unset($settings['serialize'], $settings['path']);
$expecting = array(
'prefix' => 'cake_',
'duration'=> 3600,
'duration' => 3600,
'probability' => 100,
'servers' => array('127.0.0.1'),
'persistent' => true,
@ -102,7 +102,7 @@ class MemcacheEngineTest extends CakeTestCase {
$available = true;
$Memcache = new Memcache();
foreach($servers as $server) {
foreach ($servers as $server) {
list($host, $port) = explode(':', $server);
if (!@$Memcache->connect($host, $port)) {
$available = false;
@ -312,12 +312,12 @@ class MemcacheEngineTest extends CakeTestCase {
public function testConfigurationConflict() {
Cache::config('long_memcache', array(
'engine' => 'Memcache',
'duration'=> '+2 seconds',
'duration' => '+2 seconds',
'servers' => array('127.0.0.1:11211'),
));
Cache::config('short_memcache', array(
'engine' => 'Memcache',
'duration'=> '+1 seconds',
'duration' => '+1 seconds',
'servers' => array('127.0.0.1:11211'),
));
Cache::config('some_file', array('engine' => 'File'));

View file

@ -59,7 +59,7 @@ class XcacheEngineTest extends CakeTestCase {
$settings = Cache::settings();
$expecting = array(
'prefix' => 'cake_',
'duration'=> 3600,
'duration' => 3600,
'probability' => 100,
'engine' => 'Xcache',
);

View file

@ -83,21 +83,38 @@ class BakeShellTest extends CakeTestCase {
$this->Shell->View = $this->getMock('ModelTask', array(), array(&$this->Dispatcher));
$this->Shell->DbConfig = $this->getMock('DbConfigTask', array(), array(&$this->Dispatcher));
$this->Shell->DbConfig->expects($this->once())->method('getConfig')->will($this->returnValue('test'));
$this->Shell->DbConfig->expects($this->once())
->method('getConfig')
->will($this->returnValue('test'));
$this->Shell->Model->expects($this->never())->method('getName');
$this->Shell->Model->expects($this->once())->method('bake')->will($this->returnValue(true));
$this->Shell->Model->expects($this->never())
->method('getName');
$this->Shell->Model->expects($this->once())
->method('bake')
->will($this->returnValue(true));
$this->Shell->Controller->expects($this->once())->method('bake')->will($this->returnValue(true));
$this->Shell->View->expects($this->once())->method('execute');
$this->Shell->Controller->expects($this->once())
->method('bake')
->will($this->returnValue(true));
$this->Shell->View->expects($this->once())
->method('execute');
$this->Shell->expects($this->once())->method('_stop');
$this->Shell->expects($this->at(0))->method('out')->with('Bake All');
$this->Shell->expects($this->at(5))->method('out')->with('<success>Bake All complete</success>');
$this->Shell->expects($this->at(0))
->method('out')
->with('Bake All');
$this->Shell->expects($this->at(5))
->method('out')
->with('<success>Bake All complete</success>');
$this->Shell->connection = '';
$this->Shell->params = array();
$this->Shell->args = array('User');
$this->Shell->all();
$this->assertEquals('User', $this->Shell->View->args[0]);
}
}

View file

@ -353,12 +353,12 @@ class SchemaShellTest extends CakeTestCase {
$contents = $this->file->read();
$this->assertRegExp('/class TestPluginSchema/', $contents);
$this->assertRegExp('/var \$posts/', $contents);
$this->assertRegExp('/var \$auth_users/', $contents);
$this->assertRegExp('/var \$authors/', $contents);
$this->assertRegExp('/var \$test_plugin_comments/', $contents);
$this->assertNotRegExp('/var \$users/', $contents);
$this->assertNotRegExp('/var \$articles/', $contents);
$this->assertRegExp('/public \$posts/', $contents);
$this->assertRegExp('/public \$auth_users/', $contents);
$this->assertRegExp('/public \$authors/', $contents);
$this->assertRegExp('/public \$test_plugin_comments/', $contents);
$this->assertNotRegExp('/public \$users/', $contents);
$this->assertNotRegExp('/public \$articles/', $contents);
CakePlugin::unload();
}

View file

@ -274,8 +274,8 @@ class ControllerTaskTest extends CakeTestCase {
$this->assertContains(' * @property AclComponent $Acl', $result);
$this->assertContains(' * @property AuthComponent $Auth', $result);
$this->assertContains('class ArticlesController extends AppController', $result);
$this->assertContains("\$components = array('Acl', 'Auth')", $result);
$this->assertContains("\$helpers = array('Ajax', 'Time')", $result);
$this->assertContains("public \$components = array('Acl', 'Auth')", $result);
$this->assertContains("public \$helpers = array('Ajax', 'Time')", $result);
$this->assertContains("--actions--", $result);
$result = $this->Task->bake('Articles', 'scaffold', $helpers, $components);

View file

@ -21,6 +21,7 @@ App::uses('ShellDispatcher', 'Console');
App::uses('Shell', 'Console');
App::uses('ConsoleOutput', 'Console');
App::uses('ConsoleInput', 'Console');
App::uses('ModelTask', 'Console/Command/Task');
App::uses('FixtureTask', 'Console/Command/Task');
App::uses('TemplateTask', 'Console/Command/Task');
App::uses('DbConfigTask', 'Console/Command/Task');

View file

@ -109,33 +109,32 @@ class ModelTaskTest extends CakeTestCase {
*
* @return void
*/
public function testListAll() {
$count = count($this->Task->listAll('test'));
if ($count != count($this->fixtures)) {
$this->markTestSkipped('Additional tables detected.');
}
public function testListAllArgument() {
$this->_useMockedOut();
$this->Task->expects($this->at(1))->method('out')->with('1. BakeArticle');
$this->Task->expects($this->at(2))->method('out')->with('2. BakeArticlesBakeTag');
$this->Task->expects($this->at(3))->method('out')->with('3. BakeComment');
$this->Task->expects($this->at(4))->method('out')->with('4. BakeTag');
$this->Task->expects($this->at(5))->method('out')->with('5. CategoryThread');
$this->Task->expects($this->at(7))->method('out')->with('1. BakeArticle');
$this->Task->expects($this->at(8))->method('out')->with('2. BakeArticlesBakeTag');
$this->Task->expects($this->at(9))->method('out')->with('3. BakeComment');
$this->Task->expects($this->at(10))->method('out')->with('4. BakeTag');
$this->Task->expects($this->at(11))->method('out')->with('5. CategoryThread');
$result = $this->Task->listAll('test');
$expected = array('bake_articles', 'bake_articles_bake_tags', 'bake_comments', 'bake_tags', 'category_threads');
$this->assertEquals($expected, $result);
$this->assertContains('bake_articles', $result);
$this->assertContains('bake_articles_bake_tags', $result);
$this->assertContains('bake_tags', $result);
$this->assertContains('bake_comments', $result);
$this->assertContains('category_threads', $result);
}
/**
* Test that listAll uses the connection property
*
* @return void
*/
public function testListAllConnection() {
$this->_useMockedOut();
$this->Task->connection = 'test';
$result = $this->Task->listAll();
$expected = array('bake_articles', 'bake_articles_bake_tags', 'bake_comments', 'bake_tags', 'category_threads');
$this->assertEquals($expected, $result);
$this->assertContains('bake_articles', $result);
$this->assertContains('bake_articles_bake_tags', $result);
$this->assertContains('bake_tags', $result);
$this->assertContains('bake_comments', $result);
$this->assertContains('category_threads', $result);
}
/**
@ -201,6 +200,39 @@ class ModelTaskTest extends CakeTestCase {
$this->assertEquals($expected, $result);
}
/**
* test getTable with non-conventional tablenames
*
* @return void
*/
public function testGetTableOddTable() {
$out = $this->getMock('ConsoleOutput', array(), array(), '', false);
$in = $this->getMock('ConsoleInput', array(), array(), '', false);
$this->Task = $this->getMock('ModelTask',
array('in', 'err', '_stop', '_checkUnitTest', 'getAllTables'),
array($out, $out, $in)
);
$this->_setupOtherMocks();
$this->Task->connection = 'test';
$this->Task->path = '/my/path/';
$this->Task->interactive = true;
$this->Task->expects($this->once())->method('getAllTables')->will($this->returnValue(array('articles', 'bake_odd')));
$this->Task->expects($this->any())->method('in')
->will($this->onConsecutiveCalls(
2 // bake_odd
));
$result = $this->Task->getName();
$expected = 'BakeOdd';
$this->assertEquals($expected, $result);
$result = $this->Task->getTable($result);
$expected = 'bake_odd';
$this->assertEquals($expected, $result);
}
/**
* test that initializing the validations works.
*
@ -549,7 +581,7 @@ class ModelTaskTest extends CakeTestCase {
}
/**
* Ensure that the fixutre object is correctly called.
* Ensure that the fixture object is correctly called.
*
* @return void
*/
@ -861,9 +893,17 @@ STRINGEND;
$this->Task->expects($this->at(3))->method('createFile')
->with($filename, $this->stringContains('class BakeComment'));
$filename = '/my/path/BakeComment.php';
$this->Task->expects($this->at(3))->method('createFile')
->with($filename, $this->stringContains('public $primaryKey = \'otherid\';'));
$filename = '/my/path/BakeTag.php';
$this->Task->expects($this->at(4))
->method('createFile')->with($filename, $this->stringContains('class BakeTag'));
$this->Task->expects($this->at(4))->method('createFile')
->with($filename, $this->stringContains('class BakeTag'));
$filename = '/my/path/BakeTag.php';
$this->Task->expects($this->at(4))->method('createFile')
->with($filename, $this->logicalNot($this->stringContains('public $primaryKey')));
$filename = '/my/path/CategoryThread.php';
$this->Task->expects($this->at(5))->method('createFile')
@ -875,6 +915,61 @@ STRINGEND;
$this->assertEquals(count(ClassRegistry::mapKeys()), 0);
}
/**
* test that odd tablenames arent inflected back from modelname
*
* @return void
*/
public function testExecuteIntoAllOddTables() {
$out = $this->getMock('ConsoleOutput', array(), array(), '', false);
$in = $this->getMock('ConsoleInput', array(), array(), '', false);
$this->Task = $this->getMock('ModelTask',
array('in', 'err', '_stop', '_checkUnitTest', 'getAllTables', '_getModelObject', 'bake', 'bakeFixture'),
array($out, $out, $in)
);
$this->_setupOtherMocks();
$this->Task->connection = 'test';
$this->Task->path = '/my/path/';
$this->Task->args = array('all');
$this->Task->expects($this->once())->method('_checkUnitTest')->will($this->returnValue(true));
$this->Task->expects($this->once())->method('getAllTables')->will($this->returnValue(array('bake_odd')));
$object = new Model(array('name' => 'BakeOdd', 'table' => 'bake_odd', 'ds' => 'test'));
$this->Task->expects($this->once())->method('_getModelObject')->with('BakeOdd', 'bake_odd')->will($this->returnValue($object));
$this->Task->expects($this->at(3))->method('bake')->with($object, false)->will($this->returnValue(true));
$this->Task->expects($this->once())->method('bakeFixture')->with('BakeOdd', 'bake_odd');
$this->Task->execute();
$out = $this->getMock('ConsoleOutput', array(), array(), '', false);
$in = $this->getMock('ConsoleInput', array(), array(), '', false);
$this->Task = $this->getMock('ModelTask',
array('in', 'err', '_stop', '_checkUnitTest', 'getAllTables', '_getModelObject', 'doAssociations', 'doValidation', 'createFile'),
array($out, $out, $in)
);
$this->_setupOtherMocks();
$this->Task->connection = 'test';
$this->Task->path = '/my/path/';
$this->Task->args = array('all');
$this->Task->expects($this->once())->method('_checkUnitTest')->will($this->returnValue(true));
$this->Task->expects($this->once())->method('getAllTables')->will($this->returnValue(array('bake_odd')));
$object = new Model(array('name' => 'BakeOdd', 'table' => 'bake_odd', 'ds' => 'test'));
$this->Task->expects($this->once())->method('_getModelObject')->will($this->returnValue($object));
$this->Task->expects($this->once())->method('doAssociations')->will($this->returnValue(array()));
$this->Task->expects($this->once())->method('doValidation')->will($this->returnValue(array()));
$filename = '/my/path/BakeOdd.php';
$this->Task->expects($this->once())->method('createFile')
->with($filename, $this->stringContains('class BakeOdd'));
$filename = '/my/path/BakeOdd.php';
$this->Task->expects($this->once())->method('createFile')
->with($filename, $this->stringContains('public $useTable = \'bake_odd\''));
$this->Task->execute();
}
/**
* test that skipTables changes how all() works.
*
@ -920,10 +1015,8 @@ STRINGEND;
* @return void
*/
public function testExecuteIntoInteractive() {
$count = count($this->Task->listAll('test'));
if ($count != count($this->fixtures)) {
$this->markTestSkipped('Additional tables detected.');
}
$tables = $this->Task->listAll('test');
$article = array_search('bake_articles', $tables) + 1;
$this->Task->connection = 'test';
$this->Task->path = '/my/path/';
@ -931,7 +1024,7 @@ STRINGEND;
$this->Task->expects($this->any())->method('in')
->will($this->onConsecutiveCalls(
'1', // article
$article, // article
'n', // no validation
'y', // associations
'y', // comment relation

View file

@ -163,6 +163,7 @@ class FormAuthenticateTest extends CakeTestCase {
), true);
CakePlugin::load('TestPlugin');
$ts = date('Y-m-d H:i:s');
$PluginModel = ClassRegistry::init('TestPlugin.TestPluginAuthUser');
$user['id'] = 1;
$user['username'] = 'gwoo';
@ -184,7 +185,7 @@ class FormAuthenticateTest extends CakeTestCase {
'username' => 'gwoo',
'created' => '2007-03-17 01:16:23'
);
$this->assertTrue($result['updated'] >= date('Y-m-d H:i:s'));
$this->assertTrue($result['updated'] >= $ts);
unset($result['updated']);
$this->assertEquals($expected, $result);
CakePlugin::unload();

View file

@ -671,6 +671,11 @@ class AuthComponentTest extends CakeTestCase {
$this->Controller->request->query['url'] = Router::normalize($url);
$this->assertFalse($this->Controller->Auth->startup($this->Controller));
$url = '/auth_test/CamelCase';
$this->Controller->request->addParams(Router::parse($url));
$this->Controller->request->query['url'] = Router::normalize($url);
$this->assertFalse($this->Controller->Auth->startup($this->Controller));
}
/**
@ -777,7 +782,7 @@ class AuthComponentTest extends CakeTestCase {
$this->Auth->Session->delete('Auth');
$_SERVER['HTTP_REFERER'] = $_ENV['HTTP_REFERER'] = Router::url('/admin', true);
$this->Auth->Session->write('Auth', array(
'AuthUser' => array('id'=>'1', 'username' => 'nate')
'AuthUser' => array('id' => '1', 'username' => 'nate')
));
$this->Auth->request->params['action'] = 'login';
$this->Auth->request->url = 'auth_test/login';

View file

@ -102,12 +102,12 @@ class CookieComponentTest extends CakeTestCase {
* @return void
*/
protected function _setCookieData() {
$this->Cookie->write(array('Encrytped_array' => array('name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' =>'CakePHP Rocks!')));
$this->Cookie->write(array('Encrytped_array' => array('name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' => 'CakePHP Rocks!')));
$this->Cookie->write(array('Encrytped_multi_cookies.name' => 'CakePHP'));
$this->Cookie->write(array('Encrytped_multi_cookies.version' => '1.2.0.x'));
$this->Cookie->write(array('Encrytped_multi_cookies.tag' => 'CakePHP Rocks!'));
$this->Cookie->write(array('Plain_array' => array('name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' =>'CakePHP Rocks!')), null, false);
$this->Cookie->write(array('Plain_array' => array('name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' => 'CakePHP Rocks!')), null, false);
$this->Cookie->write(array('Plain_multi_cookies.name' => 'CakePHP'), null, false);
$this->Cookie->write(array('Plain_multi_cookies.version' => '1.2.0.x'), null, false);
$this->Cookie->write(array('Plain_multi_cookies.tag' => 'CakePHP Rocks!'), null, false);
@ -145,11 +145,11 @@ class CookieComponentTest extends CakeTestCase {
public function testReadEncryptedCookieData() {
$this->_setCookieData();
$data = $this->Cookie->read('Encrytped_array');
$expected = array('name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' =>'CakePHP Rocks!');
$expected = array('name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' => 'CakePHP Rocks!');
$this->assertEquals($data, $expected);
$data = $this->Cookie->read('Encrytped_multi_cookies');
$expected = array('name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' =>'CakePHP Rocks!');
$expected = array('name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' => 'CakePHP Rocks!');
$this->assertEquals($data, $expected);
}
@ -162,11 +162,11 @@ class CookieComponentTest extends CakeTestCase {
$this->_setCookieData();
$data = $this->Cookie->read('Plain_array');
$expected = array('name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' =>'CakePHP Rocks!');
$expected = array('name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' => 'CakePHP Rocks!');
$this->assertEquals($data, $expected);
$data = $this->Cookie->read('Plain_multi_cookies');
$expected = array('name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' =>'CakePHP Rocks!');
$expected = array('name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' => 'CakePHP Rocks!');
$this->assertEquals($data, $expected);
}
@ -279,7 +279,7 @@ class CookieComponentTest extends CakeTestCase {
$this->_setCookieData();
$this->Cookie->delete('Encrytped_multi_cookies.name');
$data = $this->Cookie->read('Encrytped_multi_cookies');
$expected = array('version' => '1.2.0.x', 'tag' =>'CakePHP Rocks!');
$expected = array('version' => '1.2.0.x', 'tag' => 'CakePHP Rocks!');
$this->assertEquals($data, $expected);
$this->Cookie->delete('Encrytped_array');
@ -288,7 +288,7 @@ class CookieComponentTest extends CakeTestCase {
$this->Cookie->delete('Plain_multi_cookies.name');
$data = $this->Cookie->read('Plain_multi_cookies');
$expected = array('version' => '1.2.0.x', 'tag' =>'CakePHP Rocks!');
$expected = array('version' => '1.2.0.x', 'tag' => 'CakePHP Rocks!');
$this->assertEquals($data, $expected);
$this->Cookie->delete('Plain_array');
@ -372,7 +372,7 @@ class CookieComponentTest extends CakeTestCase {
$this->assertNull($data);
$_COOKIE['CakeTestCookie'] = array(
'Encrytped_array' => $this->__encrypt(array('name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' =>'CakePHP Rocks!')),
'Encrytped_array' => $this->__encrypt(array('name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' => 'CakePHP Rocks!')),
'Encrytped_multi_cookies' => array(
'name' => $this->__encrypt('CakePHP'),
'version' => $this->__encrypt('1.2.0.x'),
@ -386,19 +386,19 @@ class CookieComponentTest extends CakeTestCase {
$this->Cookie->startup(null);
$data = $this->Cookie->read('Encrytped_array');
$expected = array('name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' =>'CakePHP Rocks!');
$expected = array('name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' => 'CakePHP Rocks!');
$this->assertEquals($expected, $data);
$data = $this->Cookie->read('Encrytped_multi_cookies');
$expected = array('name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' =>'CakePHP Rocks!');
$expected = array('name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' => 'CakePHP Rocks!');
$this->assertEquals($expected, $data);
$data = $this->Cookie->read('Plain_array');
$expected = array('name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' =>'CakePHP Rocks!');
$expected = array('name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' => 'CakePHP Rocks!');
$this->assertEquals($expected, $data);
$data = $this->Cookie->read('Plain_multi_cookies');
$expected = array('name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' =>'CakePHP Rocks!');
$expected = array('name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' => 'CakePHP Rocks!');
$this->assertEquals($expected, $data);
$this->Cookie->destroy();
unset($_COOKIE['CakeTestCookie']);
@ -427,7 +427,7 @@ class CookieComponentTest extends CakeTestCase {
$this->assertEquals($expected, $data);
$_COOKIE['CakeTestCookie'] = array(
'Encrytped_array' => $this->__encrypt(array('name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' =>'CakePHP Rocks!')),
'Encrytped_array' => $this->__encrypt(array('name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' => 'CakePHP Rocks!')),
'Encrytped_multi_cookies' => array(
'name' => $this->__encrypt('CakePHP'),
'version' => $this->__encrypt('1.2.0.x'),
@ -439,19 +439,19 @@ class CookieComponentTest extends CakeTestCase {
'tag' => 'CakePHP Rocks!'));
$data = $this->Cookie->read('Encrytped_array');
$expected = array('name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' =>'CakePHP Rocks!');
$expected = array('name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' => 'CakePHP Rocks!');
$this->assertEquals($expected, $data);
$data = $this->Cookie->read('Encrytped_multi_cookies');
$expected = array('name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' =>'CakePHP Rocks!');
$expected = array('name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' => 'CakePHP Rocks!');
$this->assertEquals($expected, $data);
$data = $this->Cookie->read('Plain_array');
$expected = array('name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' =>'CakePHP Rocks!');
$expected = array('name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' => 'CakePHP Rocks!');
$this->assertEquals($expected, $data);
$data = $this->Cookie->read('Plain_multi_cookies');
$expected = array('name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' =>'CakePHP Rocks!');
$expected = array('name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' => 'CakePHP Rocks!');
$this->assertEquals($expected, $data);
$this->Cookie->destroy();
unset($_COOKIE['CakeTestCookie']);

View file

@ -61,6 +61,7 @@ class DebugCompTransport extends AbstractTransport {
* @return boolean
*/
public function send(CakeEmail $email) {
$email->addHeaders(array('Date' => EmailComponentTest::$sentDate));
$headers = $email->getHeaders(array_fill_keys(array('from', 'replyTo', 'readReceipt', 'returnPath', 'to', 'cc', 'bcc', 'subject'), true));
$to = $headers['To'];
$subject = $headers['Subject'];
@ -134,6 +135,13 @@ class EmailComponentTest extends CakeTestCase {
*/
public $name = 'Email';
/**
* sentDate
*
* @var string
*/
public static $sentDate = null;
/**
* setUp method
*
@ -149,6 +157,8 @@ class EmailComponentTest extends CakeTestCase {
$this->Controller->EmailTest->initialize($this->Controller, array());
self::$sentDate = date(DATE_RFC2822);
App::build(array(
'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View'. DS)
));
@ -189,7 +199,7 @@ class EmailComponentTest extends CakeTestCase {
$this->Controller->EmailTest->delivery = 'DebugComp';
$this->Controller->EmailTest->messageId = false;
$date = date(DATE_RFC2822);
$date = self::$sentDate;
$message = <<<MSGBLOC
<pre>To: postmaster@example.com
From: noreply@example.com
@ -242,7 +252,7 @@ MSGBLOC;
$this->Controller->EmailTest->delivery = 'DebugComp';
$this->Controller->EmailTest->messageId = false;
$date = date(DATE_RFC2822);
$date = self::$sentDate;
$header = <<<HEADBLOC
To: postmaster@example.com
From: noreply@example.com
@ -375,7 +385,7 @@ HTMLBLOC;
$this->assertRegExp('/From: noreply@example.com\n/', $result);
$this->assertRegExp('/Cc: cc@example.com\n/', $result);
$this->assertRegExp('/Bcc: bcc@example.com\n/', $result);
$this->assertRegExp('/Date: ' . preg_quote(date(DATE_RFC2822)) . '\n/', $result);
$this->assertRegExp('/Date: ' . preg_quote(self::$sentDate) . '\n/', $result);
$this->assertRegExp('/X-Mailer: CakePHP Email Component\n/', $result);
$this->assertRegExp('/Content-Type: text\/plain; charset=UTF-8\n/', $result);
$this->assertRegExp('/Content-Transfer-Encoding: 8bitMessage:\n/', $result);
@ -404,7 +414,7 @@ HTMLBLOC;
$this->assertRegExp('/Subject: Cake Debug Test\n/', $result);
$this->assertRegExp('/Reply-To: noreply@example.com\n/', $result);
$this->assertRegExp('/From: noreply@example.com\n/', $result);
$this->assertRegExp('/Date: ' . preg_quote(date(DATE_RFC2822)) . '\n/', $result);
$this->assertRegExp('/Date: ' . preg_quote(self::$sentDate) . '\n/', $result);
$this->assertRegExp('/X-Mailer: CakePHP Email Component\n/', $result);
$this->assertRegExp('/Content-Type: text\/plain; charset=UTF-8\n/', $result);
$this->assertRegExp('/Content-Transfer-Encoding: 8bitMessage:\n/', $result);
@ -575,7 +585,7 @@ HTMLBLOC;
$this->Controller->EmailTest->to = 'postmaster@example.com';
$this->Controller->EmailTest->from = 'noreply@example.com';
$this->Controller->EmailTest->subject = 'Cake Debug Test';
$this->Controller->EmailTest->date = 'Today!';
$this->Controller->EmailTest->date = self::$sentDate = 'Today!';
$this->Controller->EmailTest->template = null;
$this->Controller->EmailTest->delivery = 'DebugComp';

View file

@ -1291,7 +1291,7 @@ class ControllerTest extends CakeTestCase {
*/
public function testInvokeActionPrefixProtection() {
Router::reload();
Router::connect('/admin/:controller/:action/*', array('prefix'=>'admin'));
Router::connect('/admin/:controller/:action/*', array('prefix' => 'admin'));
$url = new CakeRequest('test/admin_add/');
$url->addParams(array('controller' => 'test_controller', 'action' => 'admin_add'));

View file

@ -161,7 +161,7 @@ class ScaffoldTest extends CakeTestCase {
'pass' => array(),
'form' => array(),
'named' => array(),
'url' => array('url' =>'admin/scaffold_mock/edit'),
'url' => array('url' => 'admin/scaffold_mock/edit'),
'controller' => 'scaffold_mock',
'action' => 'admin_edit',
'admin' => true,
@ -191,7 +191,7 @@ class ScaffoldTest extends CakeTestCase {
'pass' => array(),
'form' => array(),
'named' => array(),
'url' => array('url' =>'admin/scaffold_mock/edit'),
'url' => array('url' => 'admin/scaffold_mock/edit'),
'controller' => 'scaffold_mock',
'action' => 'admin_edit',
'admin' => true,
@ -245,7 +245,7 @@ class ScaffoldTest extends CakeTestCase {
'pass' => array(1),
'form' => array(),
'named' => array(),
'url' => array('url' =>'scaffold_mock'),
'url' => array('url' => 'scaffold_mock'),
'controller' => 'scaffold_mock',
'action' => 'edit',
);
@ -285,7 +285,7 @@ class ScaffoldTest extends CakeTestCase {
'pass' => array(1),
'form' => array(),
'named' => array(),
'url' => array('url' =>'scaffold_mock'),
'url' => array('url' => 'scaffold_mock'),
'controller' => 'scaffold_mock',
'action' => 'edit',
);
@ -323,7 +323,7 @@ class ScaffoldTest extends CakeTestCase {
'pass' => array(1),
'form' => array(),
'named' => array(),
'url' => array('url' =>'scaffold_mock/edit'),
'url' => array('url' => 'scaffold_mock/edit'),
'controller' => 'scaffold_mock',
'action' => 'edit',
);

View file

@ -363,6 +363,9 @@ class AppTest extends CakeTestCase {
*/
public function testListObjectsIgnoreDotDirectories() {
$path = CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS;
$this->skipIf(!is_writable($path), $path . ' is not writable.');
App::build(array(
'plugins' => array($path)
), App::RESET);

View file

@ -2603,7 +2603,7 @@ class I18nTest extends CakeTestCase {
$this->assertEquals($expected, $result);
}
public function testTimeDefinitionJapanese(){
public function testTimeDefinitionJapanese() {
Configure::write('Config.language', 'ja_jp');
$result = __c('d_fmt', 5);

View file

@ -2921,9 +2921,9 @@ class ContainableBehaviorTest extends CakeTestCase {
'order' => array('Article.id' => 'ASC')
));
if (!empty($result)) {
foreach($result as $i=>$article) {
foreach($article['Comment'] as $j=>$comment) {
$result[$i]['Comment'][$j] = array_diff_key($comment, array('id'=>true));
foreach ($result as $i => $article) {
foreach ($article['Comment'] as $j => $comment) {
$result[$i]['Comment'][$j] = array_diff_key($comment, array('id' => true));
}
}
}
@ -3628,7 +3628,7 @@ class ContainableBehaviorTest extends CakeTestCase {
return $this->__containments($result['models']);
} else {
$result = $Model;
foreach($result as $i => $containment) {
foreach ($result as $i => $containment) {
$result[$i] = array_diff_key($containment, array('instance' => true));
}
}
@ -3646,7 +3646,7 @@ class ContainableBehaviorTest extends CakeTestCase {
function __assertBindings(&$Model, $expected = array()) {
$expected = array_merge(array('belongsTo' => array(), 'hasOne' => array(), 'hasMany' => array(), 'hasAndBelongsToMany' => array()), $expected);
foreach($expected as $binding => $expect) {
foreach ($expected as $binding => $expect) {
$this->assertEquals(array_keys($Model->$binding), $expect);
}
}
@ -3664,14 +3664,14 @@ class ContainableBehaviorTest extends CakeTestCase {
$debug = '[';
$lines = array();
foreach($relationTypes as $binding) {
foreach ($relationTypes as $binding) {
if (!empty($Model->$binding)) {
$models = array_keys($Model->$binding);
foreach($models as $linkedModel) {
foreach ($models as $linkedModel) {
$line = $linkedModel;
if (!empty($extra) && !empty($Model->{$binding}[$linkedModel])) {
$extraData = array();
foreach(array_intersect_key($Model->{$binding}[$linkedModel], array_flip($extra)) as $key => $value) {
foreach (array_intersect_key($Model->{$binding}[$linkedModel], array_flip($extra)) as $key => $value) {
$extraData[] = $key . ': ' . (is_array($value) ? '(' . implode(', ', $value) . ')' : $value);
}
$line .= ' {' . implode(' - ', $extraData) . '}';

View file

@ -1053,7 +1053,7 @@ class TreeBehaviorNumberTest extends CakeTestCase {
array($modelClass => array('id' => 3, 'name' => '1.1.1', $parentField => 2, $leftField => 3, $rightField => 4)),
array($modelClass => array('id' => 4, 'name' => '1.1.2', $parentField => 2, $leftField => 5, $rightField => 6)),
array($modelClass => array('id' => 5, 'name' => '1.2', $parentField => 1, $leftField => 8, $rightField => 13)),
array($modelClass => array( 'id' => 6, 'name' => '1.2.1', $parentField => 5, $leftField => 9, $rightField => 10)),
array($modelClass => array('id' => 6, 'name' => '1.2.1', $parentField => 5, $leftField => 9, $rightField => 10)),
array($modelClass => array('id' => 7, 'name' => '1.2.2', $parentField => 5, $leftField => 11, $rightField => 12)));
$this->assertEquals($total, $expects);
@ -1149,7 +1149,7 @@ class TreeBehaviorNumberTest extends CakeTestCase {
array($modelClass => array('id' => 3, 'name' => '1.1.1', $parentField => 2, $leftField => 3, $rightField => 4)),
array($modelClass => array('id' => 4, 'name' => '1.1.2', $parentField => 2, $leftField => 5, $rightField => 6)),
array($modelClass => array('id' => 5, 'name' => '1.2', $parentField => 1, $leftField => 8, $rightField => 13)),
array($modelClass => array( 'id' => 6, 'name' => '1.2.1', $parentField => 5, $leftField => 9, $rightField => 10)),
array($modelClass => array('id' => 6, 'name' => '1.2.1', $parentField => 5, $leftField => 9, $rightField => 10)),
array($modelClass => array('id' => 7, 'name' => '1.2.2', $parentField => 5, $leftField => 11, $rightField => 12))
);
$this->assertEquals($total, $expects);

View file

@ -135,7 +135,7 @@ class TreeBehaviorScopedTest extends CakeTestCase {
*/
public function testMoveUpWithScope() {
$this->Ad = new Ad();
$this->Ad->Behaviors->attach('Tree', array('scope'=>'Campaign'));
$this->Ad->Behaviors->attach('Tree', array('scope' => 'Campaign'));
$this->Ad->moveUp(6);
$this->Ad->id = 4;

View file

@ -665,7 +665,7 @@ class BehaviorCollectionTest extends CakeTestCase {
array(
'Apple' => array('id' => 1),
'Child' => array(
array('id' => 2,'name' => 'Bright Red Apple', 'mytime' => '22:57:17'))),
array('id' => 2, 'name' => 'Bright Red Apple', 'mytime' => '22:57:17'))),
array(
'Apple' => array('id' => 2),
'Child' => array(
@ -737,7 +737,7 @@ class BehaviorCollectionTest extends CakeTestCase {
array(
'Apple' => array('id' => 1),
'Child' => array(
array('id' => 2,'name' => 'Bright Red Apple', 'mytime' => '22:57:17'))),
array('id' => 2, 'name' => 'Bright Red Apple', 'mytime' => '22:57:17'))),
array(
'Apple' => array('id' => 2),
'Child' => array(
@ -807,13 +807,13 @@ class BehaviorCollectionTest extends CakeTestCase {
$expected2 = array(
array(
'Apple' => array('id' => 1),
'Parent' => array('id' => 2,'name' => 'Bright Red Apple', 'mytime' => '22:57:17')),
'Parent' => array('id' => 2, 'name' => 'Bright Red Apple', 'mytime' => '22:57:17')),
array(
'Apple' => array('id' => 2),
'Parent' => array('id' => 1, 'name' => 'Red Apple 1', 'mytime' => '22:57:17')),
array(
'Apple' => array('id' => 3),
'Parent' => array('id' => 2,'name' => 'Bright Red Apple', 'mytime' => '22:57:17'))
'Parent' => array('id' => 2, 'name' => 'Bright Red Apple', 'mytime' => '22:57:17'))
);
$result2 = $Apple->find('all', array(
'fields' => array('Apple.id', 'Parent.id', 'Parent.name', 'Parent.mytime'),

View file

@ -741,7 +741,7 @@ class CakeSchemaTest extends CakeTestCase {
'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => true)),
);
$result = $this->Schema->generateTable('posts', $posts);
$this->assertRegExp('/var \$posts/', $result);
$this->assertRegExp('/public \$posts/', $result);
}
/**
* testSchemaWrite method

View file

@ -1305,7 +1305,7 @@ class MysqlTest extends CakeTestCase {
$this->Model->schema();
$this->_buildRelatedModels($this->Model);
$binding = array('type'=>'belongsTo', 'model'=>'TestModel4');
$binding = array('type' => 'belongsTo', 'model' => 'TestModel4');
$queryData = array();
$resultSet = null;
$null = null;
@ -1716,7 +1716,7 @@ class MysqlTest extends CakeTestCase {
$this->Model->schema();
$this->_buildRelatedModels($this->Model);
$binding = array('type'=>'hasAndBelongsToMany', 'model'=>'TestModel7');
$binding = array('type' => 'hasAndBelongsToMany', 'model' => 'TestModel7');
$queryData = array('conditions' => array('TestModel4.name !=' => 'mariano'));
$resultSet = null;
$null = null;
@ -1749,7 +1749,7 @@ class MysqlTest extends CakeTestCase {
$this->Model->hasAndBelongsToMany['TestModel7']['offset'] = 2;
$this->Model->hasAndBelongsToMany['TestModel7']['limit'] = 5;
$binding = array('type'=>'hasAndBelongsToMany', 'model'=>'TestModel7');
$binding = array('type' => 'hasAndBelongsToMany', 'model' => 'TestModel7');
$queryData = array();
$resultSet = null;
$null = null;
@ -1785,7 +1785,7 @@ class MysqlTest extends CakeTestCase {
$this->Model->hasAndBelongsToMany['TestModel7']['page'] = 2;
$this->Model->hasAndBelongsToMany['TestModel7']['limit'] = 5;
$binding = array('type'=>'hasAndBelongsToMany', 'model'=>'TestModel7');
$binding = array('type' => 'hasAndBelongsToMany', 'model' => 'TestModel7');
$queryData = array();
$resultSet = null;
$null = null;
@ -1856,7 +1856,7 @@ class MysqlTest extends CakeTestCase {
$expected = " WHERE score BETWEEN 90.1 AND 95.7";
$this->assertEquals($expected, $result);
$result = $this->Dbo->conditions(array('score' => array(2=>1, 2, 10)));
$result = $this->Dbo->conditions(array('score' => array(2 => 1, 2, 10)));
$expected = " WHERE score IN (1, 2, 10)";
$this->assertEquals($expected, $result);

View file

@ -487,22 +487,22 @@ class PostgresTest extends CakeTestCase {
$schema = new CakeSchema();
$schema->tables = array('i18n' => array(
'id' => array(
'type' => 'integer', 'null' => false, 'default' => null,
'length' => 10, 'key' => 'primary'
'type' => 'integer', 'null' => false, 'default' => null,
'length' => 10, 'key' => 'primary'
),
'locale' => array('type'=>'string', 'null' => false, 'length' => 6, 'key' => 'index'),
'model' => array('type'=>'string', 'null' => false, 'key' => 'index'),
'locale' => array('type' => 'string', 'null' => false, 'length' => 6, 'key' => 'index'),
'model' => array('type' => 'string', 'null' => false, 'key' => 'index'),
'foreign_key' => array(
'type'=>'integer', 'null' => false, 'length' => 10, 'key' => 'index'
'type' => 'integer', 'null' => false, 'length' => 10, 'key' => 'index'
),
'field' => array('type'=>'string', 'null' => false, 'key' => 'index'),
'content' => array('type'=>'text', 'null' => true, 'default' => null),
'field' => array('type' => 'string', 'null' => false, 'key' => 'index'),
'content' => array('type' => 'text', 'null' => true, 'default' => null),
'indexes' => array(
'PRIMARY' => array('column' => 'id', 'unique' => 1),
'locale' => array('column' => 'locale', 'unique' => 0),
'model' => array('column' => 'model', 'unique' => 0),
'row_id' => array('column' => 'foreign_key', 'unique' => 0),
'field' => array('column' => 'field', 'unique' => 0)
'PRIMARY' => array('column' => 'id', 'unique' => 1),
'locale' => array('column' => 'locale', 'unique' => 0),
'model' => array('column' => 'model', 'unique' => 0),
'row_id' => array('column' => 'foreign_key', 'unique' => 0),
'field' => array('column' => 'field', 'unique' => 0)
)
));

View file

@ -262,6 +262,10 @@ class SqliteTest extends CakeTestCase {
public function testDescribe() {
$this->loadFixtures('User');
$Model = new Model(array('name' => 'User', 'ds' => 'test', 'table' => 'users'));
$this->Dbo->cacheSources = true;
Configure::write('Cache.disable', false);
$result = $this->Dbo->describe($Model);
$expected = array(
'id' => array(
@ -300,6 +304,9 @@ class SqliteTest extends CakeTestCase {
$result = $this->Dbo->describe($Model->useTable);
$this->assertEquals($expected, $result);
$result = Cache::read('test_users', '_cake_model_');
$this->assertEquals($expected, $result);
}
/**

View file

@ -549,6 +549,85 @@ class ModelDeleteTest extends BaseModelTest {
$this->assertTrue($Article->delete(1));
}
/**
* testDeleteDependent method
*
* @return void
*/
public function testDeleteDependent() {
$this->loadFixtures('Bidding', 'BiddingMessage');
$Bidding = new Bidding();
$result = $Bidding->find('all');
$expected = array(
array(
'Bidding' => array('id' => 1, 'bid' => 'One', 'name' => 'Bid 1'),
'BiddingMessage' => array('bidding' => 'One', 'name' => 'Message 1'),
),
array(
'Bidding' => array('id' => 2, 'bid' => 'Two', 'name' => 'Bid 2'),
'BiddingMessage' => array('bidding' => 'Two', 'name' => 'Message 2'),
),
array(
'Bidding' => array('id' => 3, 'bid' => 'Three', 'name' => 'Bid 3'),
'BiddingMessage' => array('bidding' => 'Three', 'name' => 'Message 3'),
),
array(
'Bidding' => array('id' => 4, 'bid' => 'Five', 'name' => 'Bid 5'),
'BiddingMessage' => array('bidding' => '', 'name' => ''),
),
);
$this->assertEquals($expected, $result);
$Bidding->delete(4, true);
$result = $Bidding->find('all');
$expected = array(
array(
'Bidding' => array('id' => 1, 'bid' => 'One', 'name' => 'Bid 1'),
'BiddingMessage' => array('bidding' => 'One', 'name' => 'Message 1'),
),
array(
'Bidding' => array('id' => 2, 'bid' => 'Two', 'name' => 'Bid 2'),
'BiddingMessage' => array('bidding' => 'Two', 'name' => 'Message 2'),
),
array(
'Bidding' => array('id' => 3, 'bid' => 'Three', 'name' => 'Bid 3'),
'BiddingMessage' => array('bidding' => 'Three', 'name' => 'Message 3'),
),
);
$this->assertEquals($expected, $result);
$Bidding->delete(2, true);
$result = $Bidding->find('all');
$expected = array(
array(
'Bidding' => array('id' => 1, 'bid' => 'One', 'name' => 'Bid 1'),
'BiddingMessage' => array('bidding' => 'One', 'name' => 'Message 1'),
),
array(
'Bidding' => array('id' => 3, 'bid' => 'Three', 'name' => 'Bid 3'),
'BiddingMessage' => array('bidding' => 'Three', 'name' => 'Message 3'),
),
);
$this->assertEquals($expected, $result);
$result = $Bidding->BiddingMessage->find('all', array('order' => array('BiddingMessage.name' => 'ASC')));
$expected = array(
array(
'BiddingMessage' => array('bidding' => 'One', 'name' => 'Message 1'),
'Bidding' => array('id' => 1, 'bid' => 'One', 'name' => 'Bid 1'),
),
array(
'BiddingMessage' => array('bidding' => 'Three', 'name' => 'Message 3'),
'Bidding' => array('id' => 3, 'bid' => 'Three', 'name' => 'Bid 3'),
),
array(
'BiddingMessage' => array('bidding' => 'Four', 'name' => 'Message 4'),
'Bidding' => array('id' => '', 'bid' => '', 'name' => ''),
),
);
$this->assertEquals($expected, $result);
}
/**
* test deleteLinks with Multiple habtm associations
*

View file

@ -245,13 +245,13 @@ class ModelIntegrationTest extends BaseModelTest {
$this->loadFixtures('Article', 'User');
$TestUser =& new User();
$options = array (
$options = array(
'fields' => array(
'user',
'Article.published',
),
'joins' => array (
array (
'joins' => array(
array(
'table' => 'articles',
'alias' => 'Article',
'type' => 'LEFT',
@ -678,7 +678,7 @@ class ModelIntegrationTest extends BaseModelTest {
$TestModel->data = null;
$TestModel->set($data);
$expected = array('Apple'=> array('mytime'=> ''));
$expected = array('Apple' => array('mytime' => ''));
$this->assertEquals($TestModel->data, $expected);
$data = array();
@ -688,7 +688,7 @@ class ModelIntegrationTest extends BaseModelTest {
$TestModel->data = null;
$TestModel->set($data);
$expected = array('Apple'=> array('mytime'=> ''));
$expected = array('Apple' => array('mytime' => ''));
$this->assertEquals($TestModel->data, $expected, 'Empty values are not returning properly. %s');
$data = array();
@ -698,7 +698,7 @@ class ModelIntegrationTest extends BaseModelTest {
$TestModel->data = null;
$TestModel->set($data);
$expected = array('Apple'=> array('mytime'=> '00:00:00'));
$expected = array('Apple' => array('mytime' => '00:00:00'));
$this->assertEquals($TestModel->data, $expected, 'Midnight is not returning proper values. %s');
$data = array();
@ -707,7 +707,7 @@ class ModelIntegrationTest extends BaseModelTest {
$TestModel->data = null;
$TestModel->set($data);
$expected = array('Apple'=> array('mytime'=> '00:00:00'));
$expected = array('Apple' => array('mytime' => '00:00:00'));
$this->assertEquals($TestModel->data, $expected, 'Midnight is not returning proper values. %s');
$data = array();
@ -717,7 +717,7 @@ class ModelIntegrationTest extends BaseModelTest {
$TestModel->data = null;
$TestModel->set($data);
$expected = array('Apple'=> array('mytime'=> '03:04:04'));
$expected = array('Apple' => array('mytime' => '03:04:04'));
$this->assertEquals($TestModel->data, $expected);
$data = array();
@ -727,7 +727,7 @@ class ModelIntegrationTest extends BaseModelTest {
$TestModel->data = null;
$TestModel->set($data);
$expected = array('Apple' => array('mytime'=> '03:04:04'));
$expected = array('Apple' => array('mytime' => '03:04:04'));
$this->assertEquals($TestModel->data, $expected);
$data = array();
@ -737,7 +737,7 @@ class ModelIntegrationTest extends BaseModelTest {
$TestModel->data = null;
$TestModel->set($data);
$expected = array('Apple'=> array('mytime'=> '03:04:04'));
$expected = array('Apple' => array('mytime' => '03:04:04'));
$this->assertEquals($TestModel->data, $expected);
$db = ConnectionManager::getDataSource('test');
@ -769,7 +769,7 @@ class ModelIntegrationTest extends BaseModelTest {
$TestModel->data = null;
$TestModel->set($data);
$expected = array('Apple'=> array('created'=> ''));
$expected = array('Apple' => array('created' => ''));
$this->assertEquals($TestModel->data, $expected);
$data = array();
@ -779,7 +779,7 @@ class ModelIntegrationTest extends BaseModelTest {
$TestModel->data = null;
$TestModel->set($data);
$expected = array('Apple'=> array('date'=> ''));
$expected = array('Apple' => array('date' => ''));
$this->assertEquals($TestModel->data, $expected);
$data = array();
@ -792,7 +792,7 @@ class ModelIntegrationTest extends BaseModelTest {
$TestModel->data = null;
$TestModel->set($data);
$expected = array('Apple'=> array('created'=> '2007-08-20 00:00:00'));
$expected = array('Apple' => array('created' => '2007-08-20 00:00:00'));
$this->assertEquals($TestModel->data, $expected);
$data = array();
@ -805,7 +805,7 @@ class ModelIntegrationTest extends BaseModelTest {
$TestModel->data = null;
$TestModel->set($data);
$expected = array('Apple'=> array('created'=> '2007-08-20 10:12:00'));
$expected = array('Apple' => array('created' => '2007-08-20 10:12:00'));
$this->assertEquals($TestModel->data, $expected);
$data = array();
@ -818,7 +818,7 @@ class ModelIntegrationTest extends BaseModelTest {
$TestModel->data = null;
$TestModel->set($data);
$expected = array('Apple'=> array('created'=> ''));
$expected = array('Apple' => array('created' => ''));
$this->assertEquals($TestModel->data, $expected);
$data = array();
@ -827,7 +827,7 @@ class ModelIntegrationTest extends BaseModelTest {
$TestModel->data = null;
$TestModel->set($data);
$expected = array('Apple'=> array('created'=> ''));
$expected = array('Apple' => array('created' => ''));
$this->assertEquals($TestModel->data, $expected);
$data = array();
@ -837,7 +837,7 @@ class ModelIntegrationTest extends BaseModelTest {
$TestModel->data = null;
$TestModel->set($data);
$expected = array('Apple'=> array('created'=> ''));
$expected = array('Apple' => array('created' => ''));
$this->assertEquals($TestModel->data, $expected);
$data = array();
@ -850,9 +850,9 @@ class ModelIntegrationTest extends BaseModelTest {
$TestModel->data = null;
$TestModel->set($data);
$expected = array(
'Apple'=> array(
'created'=> '',
'date'=> '2006-12-25'
'Apple' => array(
'created' => '',
'date' => '2006-12-25'
));
$this->assertEquals($TestModel->data, $expected);
@ -870,9 +870,9 @@ class ModelIntegrationTest extends BaseModelTest {
$TestModel->data = null;
$TestModel->set($data);
$expected = array(
'Apple'=> array(
'created'=> '2007-08-20 10:12:09',
'date'=> '2006-12-25'
'Apple' => array(
'created' => '2007-08-20 10:12:09',
'date' => '2006-12-25'
));
$this->assertEquals($TestModel->data, $expected);
@ -889,7 +889,7 @@ class ModelIntegrationTest extends BaseModelTest {
$TestModel->data = null;
$TestModel->set($data);
$expected = array('Apple'=> array('created'=> '', 'date'=> ''));
$expected = array('Apple' => array('created' => '', 'date' => ''));
$this->assertEquals($TestModel->data, $expected);
$data = array();
@ -905,7 +905,7 @@ class ModelIntegrationTest extends BaseModelTest {
$TestModel->data = null;
$TestModel->set($data);
$expected = array('Apple'=> array('created'=> '', 'date'=> '2006-12-25'));
$expected = array('Apple' => array('created' => '', 'date' => '2006-12-25'));
$this->assertEquals($TestModel->data, $expected);
$data = array();
@ -915,7 +915,7 @@ class ModelIntegrationTest extends BaseModelTest {
$TestModel->data = null;
$TestModel->set($data);
$expected = array('Apple'=> array('date'=> '2006-12-25'));
$expected = array('Apple' => array('date' => '2006-12-25'));
$this->assertEquals($TestModel->data, $expected);
$db = ConnectionManager::getDataSource('test');
@ -1954,7 +1954,7 @@ class ModelIntegrationTest extends BaseModelTest {
'default' => null,
'length' => null
),
'updated'=> array(
'updated' => array(
'type' => 'datetime',
'null' => true,
'default' => null,

View file

@ -131,7 +131,7 @@ class ModelReadTest extends BaseModelTest {
'fields' => array('Thread.project_id', 'COUNT(*) AS total')
));
$result = array();
foreach($rows as $row) {
foreach ($rows as $row) {
$result[$row['Thread']['project_id']] = $row[0]['total'];
}
$expected = array(
@ -143,10 +143,10 @@ class ModelReadTest extends BaseModelTest {
$rows = $Thread->find('all', array(
'group' => 'Thread.project_id',
'fields' => array('Thread.project_id', 'COUNT(*) AS total'),
'order'=> 'Thread.project_id'
'order' => 'Thread.project_id'
));
$result = array();
foreach($rows as $row) {
foreach ($rows as $row) {
$result[$row['Thread']['project_id']] = $row[0]['total'];
}
$expected = array(
@ -211,19 +211,19 @@ class ModelReadTest extends BaseModelTest {
$expected = array(
array('Product' => array('type' => 'Clothing'), array('price' => 32)),
array('Product' => array('type' => 'Food'), array('price' => 9)),
array('Product' => array('type' => 'Music'), array( 'price' => 4)),
array('Product' => array('type' => 'Music'), array('price' => 4)),
array('Product' => array('type' => 'Toy'), array('price' => 3))
);
$result = $Product->find('all',array(
'fields'=>array('Product.type', 'MIN(Product.price) as price'),
'group'=> 'Product.type',
'fields' => array('Product.type', 'MIN(Product.price) as price'),
'group' => 'Product.type',
'order' => 'Product.type ASC'
));
$this->assertEquals($expected, $result);
$result = $Product->find('all', array(
'fields'=>array('Product.type', 'MIN(Product.price) as price'),
'group'=> array('Product.type'),
'fields' => array('Product.type', 'MIN(Product.price) as price'),
'group' => array('Product.type'),
'order' => 'Product.type ASC'));
$this->assertEquals($expected, $result);
}
@ -386,7 +386,7 @@ class ModelReadTest extends BaseModelTest {
$result = $TestModel->find('all');
$expected = array(
array(
'Apple' => array (
'Apple' => array(
'id' => 1,
'apple_id' => 2,
'color' => 'Red 1',
@ -452,7 +452,7 @@ class ModelReadTest extends BaseModelTest {
'mytime' => '22:57:17'
))),
'Sample' => array(
'id' =>'',
'id' => '',
'apple_id' => '',
'name' => ''
),
@ -1133,7 +1133,7 @@ class ModelReadTest extends BaseModelTest {
'mytime' => '22:57:17'
))),
'Sample' => array(
'id' =>'',
'id' => '',
'apple_id' => '',
'name' => ''
),
@ -1742,7 +1742,7 @@ class ModelReadTest extends BaseModelTest {
$result = $TestModel->find('all');
$expected = array(
array(
'Apple' => array (
'Apple' => array(
'id' => 1,
'apple_id' => 2,
'color' => 'Red 1',
@ -1803,7 +1803,7 @@ class ModelReadTest extends BaseModelTest {
'mytime' => '22:57:17'
))),
'Sample' => array(
'id' =>'',
'id' => '',
'apple_id' => '',
'name' => ''
)),
@ -2237,7 +2237,7 @@ class ModelReadTest extends BaseModelTest {
'mytime' => '22:57:17'
))),
'Sample' => array(
'id' =>'',
'id' => '',
'apple_id' => '',
'name' => ''
)),
@ -2646,7 +2646,7 @@ class ModelReadTest extends BaseModelTest {
'mytime' => '22:57:17'
))),
'Sample' => array(
'id' =>'',
'id' => '',
'apple_id' => '',
'name' => ''
)),
@ -3397,38 +3397,38 @@ class ModelReadTest extends BaseModelTest {
'fields' => 'id, name, parent_id',
'conditions' => array('Category.id !=' => 1)
));
$expected = array (
array ('Category' => array(
$expected = array(
array('Category' => array(
'id' => '2',
'name' => 'Category 1.1',
'parent_id' => '1'
)),
array ('Category' => array(
array('Category' => array(
'id' => '3',
'name' => 'Category 1.2',
'parent_id' => '1'
)),
array ('Category' => array(
array('Category' => array(
'id' => '4',
'name' => 'Category 2',
'parent_id' => '0'
)),
array ('Category' => array(
array('Category' => array(
'id' => '5',
'name' => 'Category 3',
'parent_id' => '0'
)),
array ('Category' => array(
array('Category' => array(
'id' => '6',
'name' => 'Category 3.1',
'parent_id' => '5'
)),
array ('Category' => array(
array('Category' => array(
'id' => '7',
'name' => 'Category 1.1.1',
'parent_id' => '2'
)),
array ('Category' => array(
array('Category' => array(
'id' => '8',
'name' => 'Category 1.1.2',
'parent_id' => '2'
@ -6087,7 +6087,7 @@ class ModelReadTest extends BaseModelTest {
'conditions' => array(
'user' => 'larry'),
'fields' => NULL,
'joins' => array (),
'joins' => array(),
'limit' => NULL,
'offset' => NULL,
'order' => array(

View file

@ -69,6 +69,7 @@ abstract class BaseModelTest extends CakeTestCase {
'core.uuiditems_uuidportfolio', 'core.uuiditems_uuidportfolio_numericid', 'core.fruit',
'core.fruits_uuid_tag', 'core.uuid_tag', 'core.product_update_all', 'core.group_update_all',
'core.player', 'core.guild', 'core.guilds_player', 'core.armor', 'core.armors_player',
'core.bidding', 'core.bidding_message'
);
/**

View file

@ -435,7 +435,7 @@ class ModelWriteTest extends BaseModelTest {
$TestModel2->save(array(
'name' => 'Item 7',
'syfile_id' => 1,
'published'=> true
'published' => true
));
$result = $TestModel->findById(1);
@ -450,7 +450,7 @@ class ModelWriteTest extends BaseModelTest {
$TestModel2->save(array(
'id' => 1,
'syfile_id' => 1,
'published'=> false
'published' => false
));
$result = $TestModel->findById(1);
@ -993,11 +993,11 @@ class ModelWriteTest extends BaseModelTest {
$TestModel->recursive = -1;
$result = $TestModel->find('all', array('fields' => array('id', 'title')));
$expected = array(
array('Article' => array('id' => 1, 'title' => 'First Article' )),
array('Article' => array('id' => 2, 'title' => 'Second Article' )),
array('Article' => array('id' => 3, 'title' => 'Third Article' )),
array('Article' => array('id' => 4, 'title' => 'Fourth Article - New Title' )),
array('Article' => array('id' => 5, 'title' => 'Fifth Article - New Title 5' ))
array('Article' => array('id' => 1, 'title' => 'First Article')),
array('Article' => array('id' => 2, 'title' => 'Second Article')),
array('Article' => array('id' => 3, 'title' => 'Third Article')),
array('Article' => array('id' => 4, 'title' => 'Fourth Article - New Title')),
array('Article' => array('id' => 5, 'title' => 'Fifth Article - New Title 5'))
);
$this->assertEquals($expected, $result);
}
@ -3661,7 +3661,7 @@ class ModelWriteTest extends BaseModelTest {
1 => array('title' => 'title 1'),
2 => array('title' => 'title 2'),
),
array('validate'=>'only')
array('validate' => 'only')
);
$this->assertFalse($result);
$expected = array(
@ -3675,7 +3675,7 @@ class ModelWriteTest extends BaseModelTest {
1 => array('title' => ''),
2 => array('title' => 'title 2'),
),
array('validate'=>'only')
array('validate' => 'only')
);
$this->assertFalse($result);
$expected = array(
@ -3778,7 +3778,7 @@ class ModelWriteTest extends BaseModelTest {
),
array(
'body' => 3,
'published' =>'sd',
'published' => 'sd',
),
);
$Something->create();
@ -3810,7 +3810,7 @@ class ModelWriteTest extends BaseModelTest {
array(
'title' => 'valid',
'body' => 'this body',
'published' =>'sd',
'published' => 'sd',
),
);
$Something->create();
@ -5083,7 +5083,7 @@ class ModelWriteTest extends BaseModelTest {
),
array(
'body' => 3,
'published' =>'sd',
'published' => 'sd',
),
);
$Something->create();
@ -5115,7 +5115,7 @@ class ModelWriteTest extends BaseModelTest {
array(
'title' => 'valid',
'body' => 'this body',
'published' =>'sd',
'published' => 'sd',
),
);
$Something->create();
@ -5305,7 +5305,7 @@ class ModelWriteTest extends BaseModelTest {
$results = $ProductUpdateAll->find('all', compact('conditions'));
$this->assertTrue(!empty($results));
$ProductUpdateAll->bindModel(array('belongsTo'=>array('Group')));
$ProductUpdateAll->bindModel(array('belongsTo' => array('Group')));
$ProductUpdateAll->belongsTo = array(
'Group' => array(
'className' => 'GroupUpdateAll',
@ -5431,7 +5431,7 @@ class ModelWriteTest extends BaseModelTest {
);
$ProductUpdateAll->updateAll(array('name' => "'new product'"), $conditions);
$resultsFkFalse = $ProductUpdateAll->find('all', array('conditions' => array('ProductUpdateAll.name'=>'new product')));
$resultsFkFalse = $ProductUpdateAll->find('all', array('conditions' => array('ProductUpdateAll.name' => 'new product')));
$expected = array(
'0' => array(
'ProductUpdateAll' => array(

View file

@ -46,12 +46,12 @@ class Test extends CakeTestModel {
* @var array
*/
protected $_schema = array(
'id'=> array('type' => 'integer', 'null' => '', 'default' => '1', 'length' => '8', 'key'=>'primary'),
'name'=> array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'),
'email'=> array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
'notes'=> array('type' => 'text', 'null' => '1', 'default' => 'write some notes here', 'length' => ''),
'created'=> array('type' => 'date', 'null' => '1', 'default' => '', 'length' => ''),
'updated'=> array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null)
'id' => array('type' => 'integer', 'null' => '', 'default' => '1', 'length' => '8', 'key' => 'primary'),
'name' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'),
'email' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
'notes' => array('type' => 'text', 'null' => '1', 'default' => 'write some notes here', 'length' => ''),
'created' => array('type' => 'date', 'null' => '1', 'default' => '', 'length' => ''),
'updated' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null)
);
}
@ -89,12 +89,12 @@ class TestAlias extends CakeTestModel {
* @var array
*/
protected $_schema = array(
'id'=> array('type' => 'integer', 'null' => '', 'default' => '1', 'length' => '8', 'key'=>'primary'),
'name'=> array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'),
'email'=> array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
'notes'=> array('type' => 'text', 'null' => '1', 'default' => 'write some notes here', 'length' => ''),
'created'=> array('type' => 'date', 'null' => '1', 'default' => '', 'length' => ''),
'updated'=> array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null)
'id' => array('type' => 'integer', 'null' => '', 'default' => '1', 'length' => '8', 'key' => 'primary'),
'name' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'),
'email' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
'notes' => array('type' => 'text', 'null' => '1', 'default' => 'write some notes here', 'length' => ''),
'created' => array('type' => 'date', 'null' => '1', 'default' => '', 'length' => ''),
'updated' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null)
);
}
@ -899,7 +899,7 @@ class ModifiedAuthor extends Author {
* @return void
*/
public function afterFind($results, $primary = false) {
foreach($results as $index => $result) {
foreach ($results as $index => $result) {
$results[$index]['Author']['user'] .= ' (CakePHP)';
}
return $results;
@ -1001,6 +1001,69 @@ class Bid extends CakeTestModel {
public $belongsTo = array('Message');
}
/**
* BiddingMessage class
*
* @package Cake.Test.Case.Model
*/
class BiddingMessage extends CakeTestModel {
/**
* name property
*
* @var string 'BiddingMessage'
*/
public $name = 'BiddingMessage';
/**
* primaryKey property
*
* @var string 'bidding'
*/
public $primaryKey = 'bidding';
/**
* belongsTo property
*
* @var array
*/
public $belongsTo = array(
'Bidding' => array(
'foreignKey' => false,
'conditions' => array('BiddingMessage.bidding = Bidding.bid')
)
);
}
/**
* Bidding class
*
* @package Cake.Test.Case.Model
*/
class Bidding extends CakeTestModel {
/**
* name property
*
* @var string 'Bidding'
*/
public $name = 'Bidding';
/**
* hasOne property
*
* @var array
*/
public $hasOne = array(
'BiddingMessage' => array(
'foreignKey' => false,
'conditions' => array('BiddingMessage.bidding = Bidding.bid'),
'dependent' => true
)
);
}
/**
* NodeAfterFind class
*
@ -2480,7 +2543,7 @@ class Campaign extends CakeTestModel {
*
* @var array
*/
public $hasMany = array('Ad' => array('fields' => array('id','campaign_id','name')));
public $hasMany = array('Ad' => array('fields' => array('id', 'campaign_id', 'name')));
}
/**
@ -3782,7 +3845,7 @@ class Level extends CakeTestModel {
* @var array
*/
public $hasMany = array(
'Group'=> array(
'Group' => array(
'className' => 'Group'
),
'User2' => array(
@ -3993,9 +4056,9 @@ class Category2 extends CakeTestModel {
),
'Article2' => array(
'className' => 'Article2',
'order'=>'Article2.published_date DESC',
'order' => 'Article2.published_date DESC',
'foreignKey' => 'category_id',
'limit'=>'3')
'limit' => '3')
);
/**
@ -4300,7 +4363,7 @@ class ArticleFeatured2 extends CakeTestModel {
* @var array
*/
public $hasMany = array(
'Comment2' => array('className'=>'Comment2', 'dependent' => true)
'Comment2' => array('className' => 'Comment2', 'dependent' => true)
);
/**

View file

@ -1048,6 +1048,29 @@ class CakeRequestTest extends CakeTestCase {
$this->assertEquals('/app/webroot/', $request->webroot);
}
/**
* Check that a sub-directory containing app|webroot doesn't get mishandled when re-writing is off.
*
* @return void
*/
public function testBaseUrlWithAppAndWebrootInDirname() {
Configure::write('App.baseUrl', '/approval/index.php');
$_SERVER['DOCUMENT_ROOT'] = '/Users/markstory/Sites/';
$_SERVER['SCRIPT_FILENAME'] = '/Users/markstory/Sites/approval/index.php';
$request = new CakeRequest();
$this->assertEquals('/approval/index.php', $request->base);
$this->assertEquals('/approval/app/webroot/', $request->webroot);
Configure::write('App.baseUrl', '/webrootable/index.php');
$_SERVER['DOCUMENT_ROOT'] = '/Users/markstory/Sites/';
$_SERVER['SCRIPT_FILENAME'] = '/Users/markstory/Sites/webrootable/index.php';
$request = new CakeRequest();
$this->assertEquals('/webrootable/index.php', $request->base);
$this->assertEquals('/webrootable/app/webroot/', $request->webroot);
}
/**
* test baseUrl with no rewrite, and using the app/webroot/index.php file as is normal with virtual hosts.
*
@ -1063,6 +1086,21 @@ class CakeRequestTest extends CakeTestCase {
$this->assertEquals('/', $request->webroot);
}
/**
* Test that a request with a . in the main GET parameter is filtered out.
* PHP changes GET parameter keys containing dots to _.
*
* @return void
*/
public function testGetParamsWithDot() {
$_GET['/posts/index/add_add'] = '';
$_SERVER['SCRIPT_NAME'] = '/cake_dev/app/webroot/index.php';
$_SERVER['REQUEST_URI'] = '/cake_dev/posts/index/add.add';
$request = new CakeRequest();
$this->assertEquals(array(), $request->query);
}
/**
* generator for environment configurations
*

Some files were not shown because too many files have changed in this diff Show more