Merge branch '2.0' of github.com:cakephp/cakephp into 2.0

This commit is contained in:
Graham Weldon 2011-12-14 16:04:40 +11:00
commit d83115927d
241 changed files with 2119 additions and 1038 deletions

View file

@ -200,6 +200,7 @@
* timestamping regardless of debug value.
*/
//Configure::write('Asset.timestamp', true);
/**
* Compress CSS output by removing comments, whitespace, repeating tags, etc.
* This requires a/var/cache directory to be writable by the web server for caching.

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;
@ -374,6 +374,7 @@ class Cache {
self::set(null, $config);
return $success;
}
/**
* Decrement a number under the key and return decremented value.
*
@ -387,7 +388,7 @@ class Cache {
$settings = self::settings($config);
if (empty($settings)) {
return null;
return false;
}
if (!self::isInitialized($config)) {
return false;
@ -401,6 +402,7 @@ class Cache {
self::set(null, $config);
return $success;
}
/**
* Delete a key from the cache.
*
@ -422,7 +424,7 @@ class Cache {
$settings = self::settings($config);
if (empty($settings)) {
return null;
return false;
}
if (!self::isInitialized($config)) {
return false;

View file

@ -21,7 +21,11 @@
*/
/**
* File Storage engine for cache
* File Storage engine for cache. Filestorage is the slowest cache storage
* to read and write. However, it is good for servers that don't have other storage
* engine available, or have content which is not performance sensitive.
*
* You can configure a FileEngine cache, using Cache::config()
*
* @package Cake.Cache.Engine
*/
@ -84,7 +88,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 +277,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

@ -110,6 +110,7 @@ class XcacheEngine extends CacheEngine {
public function decrement($key, $offset = 1) {
return xcache_dec($key, $offset);
}
/**
* Delete a key from the cache
*

View file

@ -24,6 +24,8 @@ App::uses('File', 'Utility');
/**
* API shell to show method signatures of CakePHP core classes.
*
* Implementation of a Cake Shell to show CakePHP core method signatures.
*
* @package Cake.Console.Command
*/
class ApiShell extends AppShell {
@ -151,6 +153,7 @@ class ApiShell extends AppShell {
))->description(__d('cake_console', 'Lookup doc block comments for classes in CakePHP.'));
return $parser;
}
/**
* Show help for this shell.
*

View file

@ -24,7 +24,11 @@ App::uses('AppShell', 'Console/Command');
App::uses('Model', 'Model');
/**
* Bake is a command-line code generation utility for automating programmer chores.
* Command-line code generation utility to automate programmer chores.
*
* Bake is CakePHP's code generation script, which can help you kickstart
* application development by writing fully functional skeleton controllers,
* models, and views. Going further, Bake can also write Unit Tests for you.
*
* @package Cake.Console.Command
* @link http://book.cakephp.org/2.0/en/console-and-shells/code-generation-with-bake.html
@ -185,7 +189,7 @@ class BakeShell extends AppShell {
}
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

@ -88,7 +88,7 @@ class ConsoleShell extends AppShell {
$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";

View file

@ -27,6 +27,9 @@ App::uses('CakeSchema', 'Model');
/**
* Schema is a command-line database management utility for automating programmer chores.
*
* Schema is CakePHP's database management utility. This helps you maintain versions of
* of your database.
*
* @package Cake.Console.Command
* @link http://book.cakephp.org/2.0/en/console-and-shells/schema-management-and-migrations.html
*/

View file

@ -91,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
*/
@ -222,14 +222,14 @@ class FixtureTask extends BakeTask {
$schema = $this->_generateSchema($tableInfo);
}
if (!isset($importOptions['records']) && !isset($importOptions['fromTable'])) {
if (empty($importOptions['records']) && !isset($importOptions['fromTable'])) {
$recordCount = 1;
if (isset($this->params['count'])) {
$recordCount = $this->params['count'];
}
$records = $this->_makeRecordString($this->_generateRecords($tableInfo, $recordCount));
}
if (isset($this->params['records']) || isset($importOptions['fromTable'])) {
if (!empty($this->params['records']) || isset($importOptions['fromTable'])) {
$records = $this->_makeRecordString($this->_getRecordsFromTable($model, $useTable));
}
$out = $this->generateFixtureFile($model, compact('records', 'table', 'schema', 'import', 'fields'));

View file

@ -101,10 +101,12 @@ class ModelTask extends BakeTask {
return $this->all();
}
$model = $this->_modelName($this->args[0]);
$object = $this->_getModelObject($model);
$this->listAll($this->connection);
$useTable = $this->getTable($model);
$object = $this->_getModelObject($model, $useTable);
if ($this->bake($object, false)) {
if ($this->_checkUnitTest()) {
$this->bakeFixture($model);
$this->bakeFixture($model, $useTable);
$this->bakeTest($model);
}
}
@ -298,6 +300,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;
@ -796,12 +799,14 @@ class ModelTask extends BakeTask {
public function listAll($useDbConfig = null) {
$this->_tables = $this->getAllTables($useDbConfig);
if ($this->interactive === true) {
$this->out(__d('cake_console', 'Possible Models based on your current database:'));
$this->_modelNames = array();
$count = count($this->_tables);
for ($i = 0; $i < $count; $i++) {
$this->_modelNames[] = $this->_modelName($this->_tables[$i]);
}
if ($this->interactive === true) {
$this->out(__d('cake_console', 'Possible Models based on your current database:'));
for ($i = 0; $i < $count; $i++) {
$this->out($i + 1 . ". " . $this->_modelNames[$i]);
}
}
@ -816,19 +821,19 @@ class ModelTask extends BakeTask {
* @return string Table name
*/
public function getTable($modelName, $useDbConfig = null) {
if (!isset($useDbConfig)) {
$useDbConfig = $this->connection;
}
$db = ConnectionManager::getDataSource($useDbConfig);
$useTable = Inflector::tableize($modelName);
if (in_array($modelName, $this->_modelNames)) {
$modelNames = array_flip($this->_modelNames);
$useTable = $this->_tables[$modelNames[$modelName]];
}
if ($this->interactive === true) {
if (!isset($useDbConfig)) {
$useDbConfig = $this->connection;
}
$db = ConnectionManager::getDataSource($useDbConfig);
$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));
@ -837,6 +842,7 @@ class ModelTask extends BakeTask {
if (strtolower($tableIsGood) == 'n') {
$useTable = $this->in(__d('cake_console', 'What is the name of the table?'));
}
}
return $useTable;
}

View file

@ -21,7 +21,7 @@ App::uses('File', 'Utility');
App::uses('Folder', 'Utility');
/**
* Task class for creating a plugin
* The Plugin Task handles creating an empty plugin, ready to be used
*
* @package Cake.Console.Command.Task
*/
@ -75,7 +75,7 @@ class PluginTask extends AppShell {
}
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));
}
}

View file

@ -288,9 +288,7 @@ class ProjectTask extends AppShell {
$File = new File($path . 'Config' . DS . 'core.php');
$contents = $File->read();
if (preg_match('/([\s]*Configure::write\(\'Security.cipherSeed\',[\s\'A-z0-9]*\);)/', $contents, $match)) {
if (!class_exists('Security')) {
require CAKE . 'Utility' . DS . 'security.php';
}
App::uses('Security', 'Utility');
$string = substr(bin2hex(Security::generateAuthKey()), 0, 30);
$result = str_replace($match[0], "\t" . 'Configure::write(\'Security.cipherSeed\', \''.$string.'\');', $contents);
if ($File->write($result)) {

View file

@ -59,7 +59,7 @@ class TemplateTask extends AppShell {
* @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);
@ -70,10 +70,12 @@ class TemplateTask extends AppShell {
$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

@ -555,6 +555,7 @@ class UpgradeShell extends AppShell {
);
$this->_filesRegexpUpdate($patterns);
}
/**
* Move application views files to where they now should be
*

View file

@ -79,6 +79,14 @@ class Shell extends Object {
*/
public $name = null;
/**
* The name of the plugin the shell belongs to.
* Is automatically set by ShellDispatcher when a shell is constructed.
*
* @var string
*/
public $plugin = null;
/**
* Contains tasks to load and instantiate
*
@ -409,7 +417,8 @@ class Shell extends Object {
* @link http://book.cakephp.org/2.0/en/console-and-shells.html#Shell::getOptionParser
*/
public function getOptionParser() {
$parser = new ConsoleOptionParser($this->name);
$name = ($this->plugin ? $this->plugin . '.' : '') . $this->name;
$parser = new ConsoleOptionParser($name);
return $parser;
}
@ -648,7 +657,7 @@ class Shell extends Object {
}
$File = new File($path, true);
if ($File->exists()) {
if ($File->exists() && $File->writable()) {
$data = $File->prepare($contents);
$File->write($data);
$this->out(__d('cake_console', '<success>Wrote</success> `%s`', $path));
@ -716,10 +725,10 @@ class Shell extends Object {
}
/**
* Creates the proper controller camelized name (singularized) for the specified name
* Creates the proper model camelized name (singularized) for the specified name
*
* @param string $name Name
* @return string Camelized and singularized controller name
* @return string Camelized and singularized model name
*/
protected function _modelName($name) {
return Inflector::camelize(Inflector::singularize($name));

View file

@ -219,6 +219,7 @@ class ShellDispatcher {
));
}
$Shell = new $class();
$Shell->plugin = trim($plugin, '.');
return $Shell;
}

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

@ -200,6 +200,7 @@
* timestamping regardless of debug value.
*/
//Configure::write('Asset.timestamp', true);
/**
* Compress CSS output by removing comments, whitespace, repeating tags, etc.
* This requires a/var/cache directory to be writable by the web server for caching.

View file

@ -365,6 +365,7 @@ form .submit input[type=submit] {
form .submit input[type=submit]:hover {
background: #5BA150;
}
/* Form errors */
form .error {
background: #FFDACC;
@ -646,6 +647,7 @@ pre {
overflow: auto;
text-shadow: none;
}
/* excerpt */
.cake-code-dump pre,
.cake-code-dump pre code {

View file

@ -24,6 +24,7 @@
if (!defined('DS')) {
define('DS', DIRECTORY_SEPARATOR);
}
/**
* These defines should only be edited if you have cake installed in
* a directory layout other than the way it is distributed.
@ -37,6 +38,7 @@
if (!defined('ROOT')) {
define('ROOT', dirname(dirname(dirname(__FILE__))));
}
/**
* The actual directory name for the "app".
*

View file

@ -24,6 +24,7 @@ ini_set('display_errors', 1);
if (!defined('DS')) {
define('DS', DIRECTORY_SEPARATOR);
}
/**
* These defines should only be edited if you have cake installed in
* a directory layout other than the way it is distributed.
@ -37,6 +38,7 @@ ini_set('display_errors', 1);
if (!defined('ROOT')) {
define('ROOT', dirname(dirname(dirname(__FILE__))));
}
/**
* The actual directory name for the "app".
*

View file

@ -18,6 +18,14 @@
* @since CakePHP(tm) v 2.0
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
/**
* Error Handling Controller
*
* Controller used by ErrorHandler to render error views.
*
* @package Cake.Controller
*/
class CakeErrorController extends AppController {
/**

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

@ -100,6 +100,7 @@ class DigestAuthenticate extends BaseAuthenticate {
$this->settings['opaque'] = md5($this->settings['realm']);
}
}
/**
* Authenticate a user using Digest HTTP auth. Will use the configured User model and attempt a
* login using Digest HTTP auth.
@ -142,6 +143,7 @@ class DigestAuthenticate extends BaseAuthenticate {
}
return false;
}
/**
* Find a user record using the standard options.
*

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

View file

@ -94,7 +94,7 @@ class EmailComponent extends Component {
/**
* The date to put in the Date: header. This should be a date
* conformant with the RFC2822 standard. Leave null, to have
* 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

@ -22,7 +22,11 @@
App::uses('Xml', 'Utility');
/**
* Request object for handling HTTP requests
* Request object for handling alternative HTTP requests
*
* Alternative HTTP requests can come from wireless units like mobile phones, palmtop computers,
* and the like. These units have no use for Ajax requests, and this Component can tell how Cake
* should respond to the different needs of a handheld computer and a desktop machine.
*
* @package Cake.Controller.Component
* @link http://book.cakephp.org/2.0/en/core-libraries/components/request-handling.html
@ -485,7 +489,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

@ -22,7 +22,14 @@ App::uses('String', 'Utility');
App::uses('Security', 'Utility');
/**
* SecurityComponent
* The Security Component creates an easy way to integrate tighter security in
* your application. It provides methods for various tasks like:
*
* - Restricting which HTTP methods your application accepts.
* - CSRF protection.
* - Form tampering protection
* - Requiring that SSL be used.
* - Limiting cross controller communication.
*
* @package Cake.Controller.Component
* @link http://book.cakephp.org/2.0/en/core-libraries/components/security-component.html

View file

@ -21,9 +21,9 @@ App::uses('Component', 'Controller');
App::uses('CakeSession', 'Model/Datasource');
/**
* Session Component.
*
* Session handling from the controller.
* The CakePHP SessionComponent provides a way to persist client data between
* page requests. It acts as a wrapper for the `$_SESSION` as well as providing
* convenience methods for several `$_SESSION` related functions.
*
* @package Cake.Controller.Component
* @link http://book.cakephp.org/2.0/en/core-libraries/components/sessions.html

View file

@ -19,6 +19,12 @@
App::uses('ObjectCollection', 'Utility');
App::uses('Component', 'Controller');
/**
* Components collection is used as a registry for loaded components and handles loading
* and constructing component class objects.
*
* @package Cake.Controller
*/
class ComponentCollection extends ObjectCollection {
/**

View file

@ -18,7 +18,8 @@
*/
/**
* CakePlugin class
* CakePlugin is responsible for loading and unloading plugins. It also can
* retrieve plugin paths and load their bootstrap and routes files.
*
* @package Cake.Core
* @link http://book.cakephp.org/2.0/en/plugins.html

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
@ -152,9 +152,7 @@ class Object {
* @return boolean Success of log write
*/
public function log($msg, $type = LOG_ERROR) {
if (!class_exists('CakeLog')) {
require CAKE . 'cake_log.php';
}
App::uses('CakeLog', 'Log');
if (!is_string($msg)) {
$msg = print_r($msg, true);
}

View file

@ -222,7 +222,7 @@ class ExceptionRenderer {
public function error500($error) {
$message = $error->getMessage();
if (Configure::read('debug') == 0) {
$message = __d('cake', 'An Internal Error Has Occurred');
$message = __d('cake', 'An Internal Error Has Occurred.');
}
$url = $this->controller->request->here();
$code = ($error->getCode() > 500 && $error->getCode() < 506) ? $error->getCode() : 500;

View file

@ -226,6 +226,7 @@ class MissingActionException extends CakeException {
parent::__construct($message, $code);
}
}
/**
* Private Action exception - used when a controller action
* starts with a `_`.

View file

@ -96,7 +96,7 @@ class I18n {
*
* @return void
*/
protected function __construct() {
public function __construct() {
$this->l10n = new L10n();
}

View file

@ -16,15 +16,11 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
/**
* Load Model and AppModel
*/
App::uses('AppModel', 'Model');
/**
* ACL Node
*
*
* @package Cake.Model
*/
class AclNode extends AppModel {

View file

@ -16,9 +16,6 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
/**
* Load Model and AppModel
*/
App::uses('AppModel', 'Model');
/**

View file

@ -16,9 +16,6 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
/**
* Load Model and AppModel
*/
App::uses('AppModel', 'Model');
/**

View file

@ -16,9 +16,6 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
/**
* Load Model and AppModel
*/
App::uses('AppModel', 'Model');
/**

View file

@ -23,6 +23,8 @@ App::uses('AclNode', 'Model');
/**
* ACL behavior
*
* Enables objects to easily tie into an ACL system
*
* @package Cake.Model.Behavior
* @link http://book.cakephp.org/2.0/en/core-libraries/behaviors/acl.html
*/

View file

@ -20,8 +20,9 @@
*/
/**
* Behavior to allow for dynamic and atomic manipulation of a Model's associations used for a find call. Most useful for limiting
* the amount of associations and data returned.
* Behavior to allow for dynamic and atomic manipulation of a Model's associations
* used for a find call. Most useful for limiting the amount of associations and
* data returned.
*
* @package Cake.Model.Behavior
* @link http://book.cakephp.org/2.0/en/core-libraries/behaviors/containable.html
@ -259,7 +260,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) {

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

@ -208,7 +208,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.
@ -253,8 +253,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

@ -16,6 +16,7 @@
* @since CakePHP(tm) v 1.2.0.5550
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::uses('Model', 'Model');
App::uses('AppModel', 'Model');
App::uses('ConnectionManager', 'Model');
@ -247,7 +248,12 @@ class CakeSchema extends Object {
continue;
}
try {
$Object = ClassRegistry::init(array('class' => $model, 'ds' => $connection));
} catch (CakeException $e) {
continue;
}
$db = $Object->getDataSource();
if (is_object($Object) && $Object->useTable !== false) {
$fulltable = $table = $db->fullTableName($Object, false);

View file

@ -24,6 +24,9 @@ App::uses('DataSource', 'Model/Datasource');
/**
* Manages loaded instances of DataSource objects
*
* Provides an interface for loading and enumerating connections defined in
* app/Config/database.php
*
* @package Cake.Model
*/
class ConnectionManager {

View file

@ -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) {

View file

@ -22,8 +22,6 @@ App::uses('DboSource', 'Model/Datasource');
/**
* PostgreSQL layer for DBO.
*
* Long description for class
*
* @package Cake.Model.Datasource.Database
*/
class Postgres extends DboSource {
@ -296,22 +294,21 @@ 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.
*/
public function truncate($table, $reset = 0) {
$table = $this->fullTableName($table, false);
if (!isset($this->_sequenceMap[$table])) {
public function truncate($table, $reset = false) {
$fullTable = $this->fullTableName($table, false);
if (!isset($this->_sequenceMap[$fullTable])) {
$cache = $this->cacheSources;
$this->cacheSources = false;
$this->describe($table);
$this->cacheSources = $cache;
}
if ($this->execute('DELETE FROM ' . $this->fullTableName($table))) {
$table = $this->fullTableName($table, false);
if (isset($this->_sequenceMap[$table]) && $reset !== 1) {
foreach ($this->_sequenceMap[$table] as $field => $sequence) {
if (isset($this->_sequenceMap[$fullTable]) && $reset != true) {
foreach ($this->_sequenceMap[$fullTable] as $field => $sequence) {
$this->_execute("ALTER SEQUENCE \"{$sequence}\" RESTART WITH 1");
}
}
@ -397,7 +394,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 = '';
@ -737,7 +734,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

@ -165,7 +165,7 @@ class Sqlite extends DboSource {
if ($cache != null) {
return $cache;
}
$table = $this->fullTableName($model);
$table = $this->fullTableName($model, false);
$fields = array();
$result = $this->_execute('PRAGMA table_info(' . $table . ')');
@ -454,7 +454,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

@ -585,6 +585,7 @@ class Sqlserver extends DboSource {
return parent::value($data, $column);
}
}
/**
* Returns an array of all result rows for a given SQL query.
* Returns false if no rows matched.
@ -742,14 +743,15 @@ class Sqlserver extends DboSource {
}
return $affected;
}
/**
* Executes given SQL statement.
*
* @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);
@ -1791,7 +1791,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;
@ -2048,7 +2048,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.
@ -2505,7 +2505,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])) {

View file

@ -19,12 +19,10 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
/**
* Included libs
*/
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');
@ -700,6 +698,11 @@ class Model extends Object {
} elseif ($this->table === false) {
$this->table = Inflector::tableize($this->name);
}
if ($this->tablePrefix === null) {
unset($this->tablePrefix);
}
$this->_createLinks();
$this->Behaviors->init($this->alias, $this->actsAs);
}
@ -724,7 +727,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) {
@ -799,6 +802,13 @@ class Model extends Object {
if ($name === 'displayField') {
return $this->displayField = $this->hasField(array('title', 'name', $this->primaryKey));
}
if ($name === 'tablePrefix') {
$this->setDataSource();
if (property_exists($this, 'tablePrefix')) {
return $this->tablePrefix;
}
return $this->tablePrefix = null;
}
if (isset($this->{$name})) {
return $this->{$name};
}
@ -1183,12 +1193,14 @@ class Model extends Object {
}
}
$format = $this->getDataSource()->columns[$type]['format'];
$day = empty($date['Y']) ? null : $date['Y'] . '-' . $date['m'] . '-' . $date['d'] . ' ';
$hour = empty($date['H']) ? null : $date['H'] . ':' . $date['i'] . ':' . $date['s'];
$date = new DateTime($day . $hour);
if ($useNewDate && !empty($date)) {
return $date->format($format);
$format = $this->getDataSource()->columns[$type]['format'];
foreach (array('m', 'd', 'H', 'i', 's') as $index) {
if (isset($date[$index])) {
$date[$index] = sprintf('%02d', $date[$index]);
}
}
return str_replace(array_keys($date), array_values($date), $format);
}
}
return $data;
@ -1849,7 +1861,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
@ -2249,11 +2261,17 @@ class Model extends Object {
if ($data['dependent'] === true) {
$model = $this->{$assoc};
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);
@ -3066,6 +3084,7 @@ class Model extends Object {
}
return $valid;
}
/**
* Marks a field as invalid, optionally setting the name of validation
* rule (in case of multiple validation for field) that was broken.

View file

@ -16,9 +16,6 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
/**
* Load Model and AppModel
*/
App::uses('AppModel', 'Model');
/**

View file

@ -222,7 +222,7 @@ class CakeRequest implements ArrayAccess {
$uri = substr($uri, strlen($base));
}
if (strpos($uri, '?') !== false) {
$uri = parse_url($uri, PHP_URL_PATH);
list($uri) = explode('?', $uri, 2);
}
if (empty($uri) || $uri == '/' || $uri == '//') {
return '/';
@ -278,10 +278,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 . '/';
}
}
@ -483,7 +483,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

@ -16,6 +16,7 @@
* @since CakePHP(tm) v 1.2.0
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::uses('Validation', 'Utility');
/**

View file

@ -18,7 +18,7 @@
*/
/**
* Abstract class
* Abstract transport for sending email
*
* @package Cake.Network.Email
*/

View file

@ -16,6 +16,7 @@
* @since CakePHP(tm) v 2.0.0
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::uses('Validation', 'Utility');
App::uses('Multibyte', 'I18n');
App::uses('AbstractTransport', 'Network/Email');

View file

@ -18,7 +18,7 @@
*/
/**
* Mail class
* Send mail using mail() function
*
* @package Cake.Network.Email
*/

View file

@ -16,10 +16,11 @@
* @since CakePHP(tm) v 2.0.0
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::uses('CakeSocket', 'Network');
/**
* SendEmail class
* Send mail using SMTP protocol
*
* @package Cake.Network.Email
*/

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

@ -18,7 +18,7 @@
*/
/**
* HTTP Response
* HTTP Response from HttpSocket.
*
* @package Cake.Network.Http
*/
@ -74,7 +74,7 @@ class HttpResponse implements ArrayAccess {
public $raw = '';
/**
* Contructor
* Constructor
*
* @param string $message
*/
@ -168,7 +168,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.
*/
@ -191,7 +191,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
*/
@ -283,7 +283,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) {
@ -411,7 +411,7 @@ class HttpResponse implements ArrayAccess {
}
/**
* ArrayAccess - 0ffset Set
* ArrayAccess - Offset Set
*
* @param mixed $offset
* @param mixed $value

View file

@ -157,7 +157,30 @@ class HttpSocket extends CakeSocket {
}
/**
* Set authentication settings
* Set authentication settings.
*
* Accepts two forms of parameters. If all you need is a username + password, as with
* Basic authentication you can do the following:
*
* {{{
* $http->configAuth('Basic', 'mark', 'secret');
* }}}
*
* If you are using an authentication strategy that requires more inputs, like Digest authentication
* you can call `configAuth()` with an array of user information.
*
* {{{
* $http->configAuth('Digest', array(
* 'user' => 'mark',
* 'pass' => 'secret',
* 'realm' => 'my-realm',
* 'nonce' => 1235
* ));
* }}}
*
* To remove any set authentication strategy, call `configAuth()` with no parameters:
*
* `$http->configAuth();`
*
* @param string $method Authentication method (ie. Basic, Digest). If empty, disable authentication
* @param mixed $user Username for authentication. Can be an array with settings to authentication class
@ -273,17 +296,17 @@ class HttpSocket extends CakeSocket {
if (!empty($this->request['cookies'])) {
$cookies = $this->buildCookies($this->request['cookies']);
}
$schema = '';
$scheme = '';
$port = 0;
if (isset($this->request['uri']['schema'])) {
$schema = $this->request['uri']['schema'];
if (isset($this->request['uri']['scheme'])) {
$scheme = $this->request['uri']['scheme'];
}
if (isset($this->request['uri']['port'])) {
$port = $this->request['uri']['port'];
}
if (
($schema === 'http' && $port != 80) ||
($schema === 'https' && $port != 443) ||
($scheme === 'http' && $port != 80) ||
($scheme === 'https' && $port != 443) ||
($port != 80 && $port != 443)
) {
$Host .= ':' . $port;
@ -610,7 +633,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)) {
@ -712,7 +735,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

@ -20,9 +20,6 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
/**
* List of helpers to include
*/
App::uses('Router', 'Routing');
App::uses('CakeRequest', 'Network');
App::uses('CakeResponse', 'Network');
@ -56,7 +53,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 +269,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 +278,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,21 @@
*
* @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 +63,7 @@ class CakeRoute {
protected $_greedy = false;
/**
* The compiled route regular expresssion
* The compiled route regular expression
*
* @var string
*/
@ -341,7 +344,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.
*
@ -475,7 +478,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

@ -1,11 +1,5 @@
<?php
App::uses('CakeRoute', 'Routing/Route');
/**
* Plugin short route, that copies the plugin param to the controller parameters
* It is used for supporting /:plugin routes.
*
* PHP5
*
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
@ -14,10 +8,18 @@ App::uses('CakeRoute', 'Routing/Route');
*
* @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('CakeRoute', 'Routing/Route');
/**
* Plugin short route, that copies the plugin param to the controller parameters
* It is used for supporting /:plugin routes.
*
* @package Cake.Routing.Route
*/
class PluginShortRoute extends CakeRoute {
/**

View file

@ -1,14 +1,5 @@
<?php
App::uses('CakeResponse', 'Network');
App::uses('CakeRoute', 'Routing/Route');
/**
* Redirect route will perform an immediate redirect. Redirect routes
* are useful when you want to have Routing layer redirects occur in your
* application, for when URLs move.
*
* PHP5
*
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
@ -21,6 +12,17 @@ App::uses('CakeRoute', 'Routing/Route');
* @since CakePHP(tm) v 2.0
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::uses('CakeResponse', 'Network');
App::uses('CakeRoute', 'Routing/Route');
/**
* Redirect route will perform an immediate redirect. Redirect routes
* are useful when you want to have Routing layer redirects occur in your
* application, for when URLs move.
*
* @package Cake.Routing.Route
*/
class RedirectRoute extends CakeRoute {
/**

View file

@ -80,6 +80,7 @@ class BasicsTest extends CakeTestCase {
$this->assertEquals($result, array());
}
/**
* testHttpBase method
*

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.
*

View file

@ -45,7 +45,7 @@ class FileEngineTest extends CakeTestCase {
}
/**
* teardown method
* tearDown method
*
* @return void
*/
@ -361,7 +361,7 @@ class FileEngineTest extends CakeTestCase {
$write = Cache::write('masking_test', $data, 'mask_test');
$result = substr(sprintf('%o',fileperms(TMP . 'tests' . DS .'cake_masking_test')), -4);
$expected = '0664';
$this->assertEquals($result, $expected);
$this->assertEquals($expected, $result);
Cache::delete('masking_test', 'mask_test');
Cache::drop('mask_test');
@ -369,7 +369,7 @@ class FileEngineTest extends CakeTestCase {
$write = Cache::write('masking_test', $data, 'mask_test');
$result = substr(sprintf('%o',fileperms(TMP . 'tests' . DS .'cake_masking_test')), -4);
$expected = '0666';
$this->assertEquals($result, $expected);
$this->assertEquals($expected, $result);
Cache::delete('masking_test', 'mask_test');
Cache::drop('mask_test');
@ -377,7 +377,7 @@ class FileEngineTest extends CakeTestCase {
$write = Cache::write('masking_test', $data, 'mask_test');
$result = substr(sprintf('%o',fileperms(TMP . 'tests' . DS .'cake_masking_test')), -4);
$expected = '0644';
$this->assertEquals($result, $expected);
$this->assertEquals($expected, $result);
Cache::delete('masking_test', 'mask_test');
Cache::drop('mask_test');
@ -385,7 +385,7 @@ class FileEngineTest extends CakeTestCase {
$write = Cache::write('masking_test', $data, 'mask_test');
$result = substr(sprintf('%o',fileperms(TMP . 'tests' . DS .'cake_masking_test')), -4);
$expected = '0640';
$this->assertEquals($result, $expected);
$this->assertEquals($expected, $result);
Cache::delete('masking_test', 'mask_test');
Cache::drop('mask_test');
}

View file

@ -364,6 +364,7 @@ class MemcacheEngineTest extends CakeTestCase {
Cache::clear(false, 'memcache2');
}
/**
* test that a 0 duration can succesfully write.
*

View file

@ -32,8 +32,8 @@ class IniReaderTest extends CakeTestCase {
*
* @return void
*/
public function setup() {
parent::setup();
public function setUp() {
parent::setUp();
$this->path = CAKE . 'Test' . DS . 'test_app' . DS . 'Config'. DS;
}

View file

@ -28,6 +28,7 @@ class PhpReaderTest extends CakeTestCase {
parent::setUp();
$this->path = CAKE . 'Test' . DS . 'test_app' . DS . 'Config'. DS;
}
/**
* test reading files
*

View file

@ -37,11 +37,12 @@ class AclShellTest extends CakeTestCase {
public $fixtures = array('core.aco', 'core.aro', 'core.aros_aco');
/**
* setup method
* setUp method
*
* @return void
*/
public function setUp() {
parent::setUp();
Configure::write('Acl.database', 'test');
Configure::write('Acl.classname', 'DbAcl');

View file

@ -59,7 +59,7 @@ class BakeShellTest extends CakeTestCase {
}
/**
* teardown method
* tearDown method
*
* @return void
*/
@ -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->Controller->expects($this->once())->method('bake')->will($this->returnValue(true));
$this->Shell->View->expects($this->once())->method('execute');
$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->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

@ -60,7 +60,7 @@ class CommandListShellTest extends CakeTestCase {
}
/**
* teardown
* tearDown
*
* @return void
*/

View file

@ -97,7 +97,7 @@ class SchemaShellTest extends CakeTestCase {
);
/**
* setup method
* setUp method
*
* @return void
*/

View file

@ -64,6 +64,7 @@ class ControllerTaskTest extends CakeTestCase {
* @return void
*/
public function setUp() {
parent::setUp();
$out = $this->getMock('ConsoleOutput', array(), array(), '', false);
$in = $this->getMock('ConsoleInput', array(), array(), '', false);
$this->Task = $this->getMock('ControllerTask',
@ -86,14 +87,15 @@ class ControllerTaskTest extends CakeTestCase {
}
/**
* teardown method
* tearDown method
*
* @return void
*/
public function teardown() {
public function tearDown() {
unset($this->Task);
ClassRegistry::flush();
App::build();
parent::tearDown();
}
/**
@ -274,8 +276,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

@ -31,7 +31,7 @@ App::uses('DbConfigTask', 'Console/Command/Task');
class DbConfigTaskTest extends CakeTestCase {
/**
* setup method
* setUp method
*
* @return void
*/

View file

@ -95,7 +95,7 @@ class ModelTaskTest extends CakeTestCase {
}
/**
* teardown method
* tearDown method
*
* @return void
*/
@ -205,7 +205,7 @@ class ModelTaskTest extends CakeTestCase {
*
* @return void
*/
public function testGetTableOddTable() {
public function testGetTableOddTableInteractive() {
$out = $this->getMock('ConsoleOutput', array(), array(), '', false);
$in = $this->getMock('ConsoleInput', array(), array(), '', false);
$this->Task = $this->getMock('ModelTask',
@ -233,6 +233,34 @@ 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 = false;
$this->Task->args = array('BakeOdd');
$this->Task->expects($this->once())->method('getAllTables')->will($this->returnValue(array('articles', 'bake_odd')));
$this->Task->listAll();
$result = $this->Task->getTable('BakeOdd');
$expected = 'bake_odd';
$this->assertEquals($expected, $result);
}
/**
* test that initializing the validations works.
*
@ -970,6 +998,61 @@ STRINGEND;
$this->Task->execute();
}
/**
* test that odd tablenames arent inflected back from modelname
*
* @return void
*/
public function testExecuteIntoBakeOddTables() {
$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('BakeOdd');
$this->Task->expects($this->once())->method('_checkUnitTest')->will($this->returnValue(true));
$this->Task->expects($this->once())->method('getAllTables')->will($this->returnValue(array('articles', '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->once())->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('BakeOdd');
$this->Task->expects($this->once())->method('_checkUnitTest')->will($this->returnValue(true));
$this->Task->expects($this->once())->method('getAllTables')->will($this->returnValue(array('articles', '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.
*

View file

@ -36,7 +36,7 @@ App::uses('File', 'Utility');
class PluginTaskTest extends CakeTestCase {
/**
* setup method
* setUp method
*
* @return void
*/

View file

@ -35,7 +35,7 @@ App::uses('File', 'Utility');
class ProjectTaskTest extends CakeTestCase {
/**
* setup method
* setUp method
*
* @return void
*/
@ -52,7 +52,7 @@ class ProjectTaskTest extends CakeTestCase {
}
/**
* teardown method
* tearDown method
*
* @return void
*/

View file

@ -19,12 +19,12 @@
* @since CakePHP(tm) v 1.3
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::uses('ShellDispatcher', 'Console');
App::uses('ConsoleOutput', 'Console');
App::uses('ConsoleInput', 'Console');
App::uses('Shell', 'Console');
App::uses('TemplateTask', 'Console/Command/Task');
/**
* TemplateTaskTest class
*
@ -33,11 +33,11 @@ App::uses('TemplateTask', 'Console/Command/Task');
class TemplateTaskTest extends CakeTestCase {
/**
* setup method
* setUp method
*
* @return void
*/
public function setup() {
public function setUp() {
parent::setUp();
$out = $this->getMock('ConsoleOutput', array(), array(), '', false);
$in = $this->getMock('ConsoleInput', array(), array(), '', false);
@ -49,7 +49,7 @@ class TemplateTaskTest extends CakeTestCase {
}
/**
* teardown method
* tearDown method
*
* @return void
*/

View file

@ -220,12 +220,12 @@ class TestTaskTest extends CakeTestCase {
public $fixtures = array('core.article', 'core.comment', 'core.articles_tag', 'core.tag');
/**
* setup method
* setUp method
*
* @return void
*/
public function setup() {
parent::setup();
public function setUp() {
parent::setUp();
$out = $this->getMock('ConsoleOutput', array(), array(), '', false);
$in = $this->getMock('ConsoleInput', array(), array(), '', false);

View file

@ -38,7 +38,7 @@ class ConsoleErrorHandlerTest extends CakeTestCase {
}
/**
* teardown
* tearDown
*
* @return void
*/

View file

@ -422,6 +422,8 @@ class ShellDispatcherTest extends CakeTestCase {
$Dispatcher = new TestShellDispatcher();
$result = $Dispatcher->getShell('test_plugin.example');
$this->assertInstanceOf('ExampleShell', $result);
$this->assertEquals('TestPlugin', $result->plugin);
$this->assertEquals('Example', $result->name);
$Dispatcher = new TestShellDispatcher();
$result = $Dispatcher->getShell('TestPlugin.example');

View file

@ -126,6 +126,11 @@ class ShellTest extends CakeTestCase {
$error = $this->getMock('ConsoleOutput', array(), array(), '', false);
$in = $this->getMock('ConsoleInput', array(), array(), '', false);
$this->Shell = new ShellTestShell($output, $error, $in);
if (is_dir(TMP . 'shell_test')) {
$Folder = new Folder(TMP . 'shell_test');
$Folder->delete();
}
}
/**
@ -490,11 +495,6 @@ class ShellTest extends CakeTestCase {
$path = $expected = DS . 'tmp' . DS . 'ab' . DS . 'index.php';
$this->assertEquals($this->Shell->shortPath($path), $expected);
// Shell::shortPath needs Folder::realpath
// $path = DS . 'tmp' . DS . 'ab' . DS . '..' . DS . 'cd';
// $expected = DS . 'tmp' . DS . 'cd';
// $this->assertEquals($this->Shell->shortPath($path), $expected);
$path = DS . 'tmp' . DS . 'ab' . DS . DS . 'cd';
$expected = DS . 'tmp' . DS . 'ab' . DS . 'cd';
$this->assertEquals($this->Shell->shortPath($path), $expected);
@ -542,8 +542,6 @@ class ShellTest extends CakeTestCase {
$this->assertTrue($result);
$this->assertTrue(file_exists($file));
$this->assertEquals(file_get_contents($file), $contents);
$Folder->delete();
}
/**
@ -588,8 +586,25 @@ class ShellTest extends CakeTestCase {
$this->assertTrue($result);
$this->assertTrue(file_exists($file));
$this->assertEquals($contents, file_get_contents($file));
}
$Folder->delete();
/**
* Test that you can't create files that aren't writable.
*
* @return void
*/
public function testCreateFileNoPermissions() {
$path = TMP . 'shell_test';
$file = $path . DS . 'no_perms';
mkdir($path);
chmod($path, 0444);
$this->Shell->createFile($file, 'testing');
$this->assertFalse(file_exists($file));
chmod($path, 0744);
rmdir($path);
}
/**
@ -841,4 +856,17 @@ TEXT;
$expected = 'TestApple';
$this->assertEquals($expected, $this->Shell->TestApple->name);
}
/**
* Test that option parsers are created with the correct name/command.
*
* @return void
*/
public function testGetOptionParser() {
$this->Shell->name = 'test';
$this->Shell->plugin = 'plugin';
$parser = $this->Shell->getOptionParser();
$this->assertEquals('plugin.test', $parser->command());
}
}

View file

@ -22,23 +22,25 @@ App::uses('Shell', 'Console');
class TaskCollectionTest extends CakeTestCase {
/**
* setup
* setUp
*
* @return void
*/
public function setup() {
public function setUp() {
parent::setUp();
$shell = $this->getMock('Shell', array(), array(), '', false);
$dispatcher = $this->getMock('ShellDispatcher', array(), array(), '', false);
$this->Tasks = new TaskCollection($shell, $dispatcher);
}
/**
* teardown
* tearDown
*
* @return void
*/
public function teardown() {
public function tearDown() {
unset($this->Tasks);
parent::tearDown();
}
/**
@ -69,6 +71,7 @@ class TaskCollectionTest extends CakeTestCase {
$this->assertFalse($this->Tasks->enabled('DbConfig'), 'DbConfigTask should be disabled');
}
/**
* test missingtask exception
*

View file

@ -26,7 +26,7 @@ App::uses('CakeResponse', 'Network');
class ActionsAuthorizeTest extends CakeTestCase {
/**
* setup
* setUp
*
* @return void
*/

View file

@ -57,7 +57,7 @@ class BasicAuthenticateTest extends CakeTestCase {
}
/**
* teardown
* tearDown
*
* @return void
*/
@ -163,6 +163,7 @@ class BasicAuthenticateTest extends CakeTestCase {
$result = $this->auth->authenticate($request, $this->response);
$this->assertFalse($result);
}
/**
* test authenticate sucesss
*

View file

@ -59,7 +59,7 @@ class DigestAuthenticateTest extends CakeTestCase {
}
/**
* teardown
* tearDown
*
* @return void
*/

View file

@ -499,6 +499,7 @@ class CookieComponentTest extends CakeTestCase {
$this->assertNull($this->Cookie->read('User.email'));
$this->Cookie->destroy();
}
/**
* Test deleting recursively with keys that don't exist.
*

View file

@ -470,6 +470,7 @@ class DbAclTest extends CakeTestCase {
$this->Acl->deny('Bobs', 'ROOT/printers/DoesNotExist', 'create');
}
/**
* debug function - to help editing/creating test cases for the ACL component
*

View file

@ -45,6 +45,7 @@ class RequestHandlerTestController extends Controller {
$this->viewPath = 'Posts';
$this->render('index');
}
/**
* test method for ajax redirection + parameter parsing
*

View file

@ -29,21 +29,23 @@ class CookieAliasComponent extends CookieComponent {
class ComponentCollectionTest extends CakeTestCase {
/**
* setup
* setUp
*
* @return void
*/
public function setup() {
public function setUp() {
parent::setUp();
$this->Components = new ComponentCollection();
}
/**
* teardown
* tearDown
*
* @return void
*/
public function teardown() {
public function tearDown() {
unset($this->Components);
parent::tearDown();
}
/**
@ -108,6 +110,7 @@ class ComponentCollectionTest extends CakeTestCase {
$this->assertFalse($this->Components->enabled('Cookie'), 'Cookie should be disabled');
}
/**
* test missingcomponent exception
*

View file

@ -34,6 +34,7 @@ class MergeVarsAppController extends Controller {
* @var array
*/
public $components = array('MergeVar' => array('flag', 'otherFlag', 'redirect' => false));
/**
* helpers
*
@ -42,7 +43,6 @@ class MergeVarsAppController extends Controller {
public $helpers = array('MergeVar' => array('format' => 'html', 'terse'));
}
/**
* MergeVar Component
*

View file

@ -35,12 +35,14 @@ class ControllerTestAppController extends Controller {
* @var array
*/
public $helpers = array('Html');
/**
* uses property
*
* @var array
*/
public $uses = array('ControllerPost');
/**
* components property
*
@ -305,6 +307,7 @@ class TestComponent extends Object {
*/
public function beforeRedirect() {
}
/**
* initialize method
*
@ -320,6 +323,7 @@ class TestComponent extends Object {
*/
public function startup(&$controller) {
}
/**
* shutdown method
*
@ -327,6 +331,7 @@ class TestComponent extends Object {
*/
public function shutdown(&$controller) {
}
/**
* beforeRender callback
*
@ -351,6 +356,7 @@ class AnotherTestController extends ControllerTestAppController {
* @var string 'Name'
*/
public $name = 'AnotherTest';
/**
* uses property
*
@ -358,6 +364,11 @@ class AnotherTestController extends ControllerTestAppController {
*/
public $uses = null;
/**
* merge parent
*
* @var string
*/
protected $_mergeParent = 'ControllerTestAppController';
}
@ -381,19 +392,21 @@ class ControllerTest extends CakeTestCase {
* @return void
*/
public function setUp() {
parent::setUp();
App::objects('plugin', null, false);
App::build();
Router::reload();
}
/**
* teardown
* tearDown
*
* @return void
*/
public function teardown() {
public function tearDown() {
CakePlugin::unload();
App::build();
parent::tearDown();
}
/**
@ -1112,6 +1125,7 @@ class ControllerTest extends CakeTestCase {
$Controller->startupProcess();
}
/**
* Tests that the shutdown process calls the correct functions
*

View file

@ -16,7 +16,6 @@
* @since CakePHP(tm) v 1.2.0.5436
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::uses('Router', 'Routing');
App::uses('Controller', 'Controller');
App::uses('Scaffold', 'Controller');
@ -105,8 +104,6 @@ class TestScaffoldMock extends Scaffold {
}
}
/**
* Scaffold Test class
*
@ -127,6 +124,7 @@ class ScaffoldTest extends CakeTestCase {
* @var array
*/
public $fixtures = array('core.article', 'core.user', 'core.comment', 'core.join_thing', 'core.tag');
/**
* setUp method
*
@ -273,6 +271,7 @@ class ScaffoldTest extends CakeTestCase {
$result = ob_get_clean();
$this->assertRegExp('/Scaffold Mock has been updated/', $result);
}
/**
* test that habtm relationship keys get added to scaffoldFields.
*
@ -308,6 +307,7 @@ class ScaffoldTest extends CakeTestCase {
$result = $Scaffold->controller->viewVars;
$this->assertEquals($result['scaffoldFields'], array('id', 'user_id', 'title', 'body', 'published', 'created', 'updated', 'ScaffoldTag'));
}
/**
* test that the proper names and variable values are set by Scaffold
*

View file

@ -29,12 +29,14 @@ App::uses('Router', 'Routing');
class ErrorHandlerTest extends CakeTestCase {
public $_restoreError = false;
/**
* setup create a request object to get out of router later.
*
* @return void
*/
public function setUp() {
parent::setUp();
App::build(array(
'View' => array(
CAKE . 'Test' . DS . 'test_app' . DS . 'View'. DS
@ -51,17 +53,18 @@ class ErrorHandlerTest extends CakeTestCase {
}
/**
* teardown
* tearDown
*
* @return void
*/
public function teardown() {
public function tearDown() {
Configure::write('debug', $this->_debug);
Configure::write('Error', $this->_error);
App::build();
if ($this->_restoreError) {
restore_error_handler();
}
parent::tearDown();
}
/**

View file

@ -126,6 +126,7 @@ class MyCustomExceptionRenderer extends ExceptionRenderer {
echo 'widget thing is missing';
}
}
/**
* Exception class for testing app error handlers and custom errors.
*
@ -142,12 +143,14 @@ class MissingWidgetThingException extends NotFoundException { }
class ExceptionRendererTest extends CakeTestCase {
public $_restoreError = false;
/**
* setup create a request object to get out of router later.
*
* @return void
*/
public function setUp() {
parent::setUp();
App::build(array(
'views' => array(
CAKE . 'Test' . DS . 'test_app' . DS . 'View'. DS
@ -164,17 +167,18 @@ class ExceptionRendererTest extends CakeTestCase {
}
/**
* teardown
* tearDown
*
* @return void
*/
public function teardown() {
public function tearDown() {
Configure::write('debug', $this->_debug);
Configure::write('Error', $this->_error);
App::build();
if ($this->_restoreError) {
restore_error_handler();
}
parent::tearDown();
}
/**
@ -406,6 +410,7 @@ class ExceptionRendererTest extends CakeTestCase {
$result = ob_get_clean();
$this->assertContains('Not Found', $result);
}
/**
* test that error400 doesn't expose XSS
*

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