Merge branch 'master' into 2.5

This commit is contained in:
mark_story 2013-09-26 10:07:10 -04:00
commit cc5795c67d
26 changed files with 117 additions and 61 deletions

View file

@ -54,7 +54,7 @@ Cache::config('default', array('engine' => 'File'));
*/
/**
* Custom Inflector rules, can be set to correctly pluralize or singularize table, model, controller names or whatever other
* Custom Inflector rules can be set to correctly pluralize or singularize table, model, controller names or whatever other
* string is passed to the inflection functions
*
* Inflector::rules('singular', array('rules' => array(), 'irregular' => array(), 'uninflected' => array()));
@ -64,7 +64,7 @@ Cache::config('default', array('engine' => 'File'));
/**
* Plugins need to be loaded manually, you can either load them one by one or all of them in a single call
* Uncomment one of the lines below, as you need. make sure you read the documentation on CakePlugin to use more
* Uncomment one of the lines below, as you need. Make sure you read the documentation on CakePlugin to use more
* advanced ways of loading plugins
*
* CakePlugin::loadAll(); // Loads all plugins at once
@ -73,7 +73,7 @@ Cache::config('default', array('engine' => 'File'));
*/
/**
* You can attach event listeners to the request lifecycle as Dispatcher Filter . By Default CakePHP bundles two filters:
* You can attach event listeners to the request lifecycle as Dispatcher Filter. By default CakePHP bundles two filters:
*
* - AssetDispatcher filter will serve your asset files (css, images, js, etc) from your themes and plugins
* - CacheDispatcher filter will read the Cache.check configure variable and try to serve cached content generated from controllers

View file

@ -97,7 +97,7 @@
* /app/webroot/.htaccess
*
* And uncomment the App.baseUrl below. But keep in mind
* that plugin assets such as images, CSS and Javascript files
* that plugin assets such as images, CSS and JavaScript files
* will not work without url rewriting!
* To work around this issue you should either symlink or copy
* the plugin assets into you app's webroot directory. This is
@ -254,7 +254,7 @@
* Plug in your own custom JavaScript compressor by dropping a script in your webroot to handle the
* output, and setting the config below to the name of the script.
*
* To use, prefix your JavaScript link URLs with '/cjs/' instead of '/js/' or use JavaScriptHelper::link().
* To use, prefix your JavaScript link URLs with '/cjs/' instead of '/js/' or use JsHelper::link().
*/
//Configure::write('Asset.filter.js', 'custom_javascript_output_filter.php');

View file

@ -279,7 +279,7 @@ class TestTask extends BakeTask {
*/
public function buildTestSubject($type, $class) {
ClassRegistry::flush();
App::import($type, $class);
App::uses($class, $type);
$class = $this->getRealClassName($type, $class);
if (strtolower($type) === 'model') {
$instance = ClassRegistry::init($class);
@ -374,9 +374,9 @@ class TestTask extends BakeTask {
*/
public function generateFixtureList($subject) {
$this->_fixtures = array();
if (is_a($subject, 'Model')) {
if ($subject instanceof Model) {
$this->_processModel($subject);
} elseif (is_a($subject, 'Controller')) {
} elseif ($subject instanceof Controller) {
$this->_processController($subject);
}
return array_values($this->_fixtures);

View file

@ -88,7 +88,7 @@
* /app/webroot/.htaccess
*
* And uncomment the App.baseUrl below. But keep in mind
* that plugin assets such as images, CSS and Javascript files
* that plugin assets such as images, CSS and JavaScript files
* will not work without URL rewriting!
* To work around this issue you should either symlink or copy
* the plugin assets into you app's webroot directory. This is
@ -245,7 +245,7 @@
* Plug in your own custom JavaScript compressor by dropping a script in your webroot to handle the
* output, and setting the config below to the name of the script.
*
* To use, prefix your JavaScript link URLs with '/cjs/' instead of '/js/' or use JavaScriptHelper::link().
* To use, prefix your JavaScript link URLs with '/cjs/' instead of '/js/' or use JsHelper::link().
*/
//Configure::write('Asset.filter.js', 'custom_javascript_output_filter.php');

View file

@ -112,7 +112,7 @@ class CookieComponent extends Component {
* HTTP only cookie
*
* Set to true to make HTTP only cookies. Cookies that are HTTP only
* are not accessible in Javascript.
* are not accessible in JavaScript.
*
* @var boolean
*/

View file

@ -88,7 +88,7 @@ class Controller extends Object implements CakeEventListener {
* An array containing the names of helpers this controller uses. The array elements should
* not contain the "Helper" part of the classname.
*
* Example: `public $helpers = array('Html', 'Javascript', 'Time', 'Ajax');`
* Example: `public $helpers = array('Html', 'Js', 'Time', 'Ajax');`
*
* @var mixed A single name as a string or a list of names as an array.
* @link http://book.cakephp.org/2.0/en/controllers.html#components-helpers-and-uses
@ -940,7 +940,7 @@ class Controller extends Object implements CakeEventListener {
$models = ClassRegistry::keys();
foreach ($models as $currentModel) {
$currentObject = ClassRegistry::getObject($currentModel);
if (is_a($currentObject, 'Model')) {
if ($currentObject instanceof Model) {
$className = get_class($currentObject);
list($plugin) = pluginSplit(App::location($className));
$this->request->params['models'][$currentObject->alias] = compact('plugin', 'className');

View file

@ -121,7 +121,7 @@ class AclNode extends Model {
) {
return false;
}
} elseif (is_object($ref) && is_a($ref, 'Model')) {
} elseif (is_object($ref) && $ref instanceof Model) {
$ref = array('model' => $ref->name, 'foreign_key' => $ref->id);
} elseif (is_array($ref) && !(isset($ref['model']) && isset($ref['foreign_key']))) {
$name = key($ref);

View file

@ -232,7 +232,7 @@ class DataSource extends Object {
* @param mixed $conditions The conditions to use for deleting.
* @return boolean Success
*/
public function delete(Model $model, $id = null) {
public function delete(Model $model, $conditions = null) {
return false;
}

View file

@ -861,7 +861,7 @@ class DboSource extends DataSource {
* @return boolean True if the result is valid else false
*/
public function hasResult() {
return is_a($this->_result, 'PDOStatement');
return $this->_result instanceof PDOStatement;
}
/**
@ -2281,6 +2281,7 @@ class DboSource extends DataSource {
$fields,
$quote,
ConnectionManager::getSourceName($this),
$model->schemaName,
$model->table
);
$cacheKey = md5(serialize($cacheKey));
@ -2961,7 +2962,7 @@ class DboSource extends DataSource {
* @return string
*/
public function createSchema($schema, $tableName = null) {
if (!is_a($schema, 'CakeSchema')) {
if (!$schema instanceof CakeSchema) {
trigger_error(__d('cake_dev', 'Invalid schema object'), E_USER_WARNING);
return null;
}

View file

@ -24,7 +24,6 @@ App::uses('AbstractTransport', 'Network/Email');
App::uses('File', 'Utility');
App::uses('String', 'Utility');
App::uses('View', 'View');
App::import('I18n', 'Multibyte');
/**
* Cake e-mail class.

View file

@ -137,7 +137,7 @@ class SchemaShellTest extends CakeTestCase {
public function testStartup() {
$this->Shell->startup();
$this->assertTrue(isset($this->Shell->Schema));
$this->assertTrue(is_a($this->Shell->Schema, 'CakeSchema'));
$this->assertInstanceOf('CakeSchema', $this->Shell->Schema);
$this->assertEquals(Inflector::camelize(Inflector::slug(APP_DIR)), $this->Shell->Schema->name);
$this->assertEquals('schema.php', $this->Shell->Schema->file);

View file

@ -94,7 +94,7 @@ class MergeVarPluginAppController extends MergeVarsAppController {
*
* @var array
*/
public $helpers = array('Javascript');
public $helpers = array('Js');
/**
* parent for mergeVars
@ -205,7 +205,7 @@ class ControllerMergeVarsTest extends CakeTestCase {
$expected = array(
'MergeVar' => array('format' => 'html', 'terse'),
'Javascript' => null
'Js' => null
);
$this->assertEquals($expected, $Controller->helpers, 'Helpers are unexpected.');

View file

@ -482,8 +482,8 @@ class ControllerTest extends CakeTestCase {
$Controller = new Controller($request);
$Controller->uses = array('ControllerPost', 'ControllerComment');
$Controller->constructClasses();
$this->assertTrue(is_a($Controller->ControllerPost, 'ControllerPost'));
$this->assertTrue(is_a($Controller->ControllerComment, 'ControllerComment'));
$this->assertInstanceOf('ControllerPost', $Controller->ControllerPost);
$this->assertInstanceOf('ControllerComment', $Controller->ControllerComment);
$this->assertEquals('Comment', $Controller->ControllerComment->name);
@ -497,7 +497,7 @@ class ControllerTest extends CakeTestCase {
$Controller->constructClasses();
$this->assertTrue(isset($Controller->TestPluginPost));
$this->assertTrue(is_a($Controller->TestPluginPost, 'TestPluginPost'));
$this->assertInstanceOf('TestPluginPost', $Controller->TestPluginPost);
}
/**

View file

@ -945,6 +945,28 @@ class DboSourceTest extends CakeTestCase {
$this->assertEquals(2, count(DboTestSource::$methodCache['fields']));
}
/**
* test that fields() method cache detects schema name changes
*
* @return void
*/
public function testFieldsCacheKeyWithSchemanameChange() {
Cache::delete('method_cache', '_cake_core_');
DboSource::$methodCache = array();
$Article = ClassRegistry::init('Article');
$ds = $Article->getDataSource();
$ds->cacheMethods = true;
$first = $ds->fields($Article);
$Article->schemaName = 'secondSchema';
$ds = $Article->getDataSource();
$ds->cacheMethods = true;
$second = $ds->fields($Article);
$this->assertEquals(2, count(DboSource::$methodCache['fields']));
}
/**
* Test that group works without a model
*

View file

@ -2376,7 +2376,7 @@ class RouterTest extends CakeTestCase {
array('controller' => 'posts', 'action' => 'view'),
array('routeClass' => 'MockConnectedRoute', 'slug' => '[a-z_-]+')
);
$this->assertTrue(is_a($routes[0], 'MockConnectedRoute'), 'Incorrect class used. %s');
$this->assertInstanceOf('MockConnectedRoute', $routes[0], 'Incorrect class used. %s');
$expected = array('controller' => 'posts', 'action' => 'view', 'slug' => 'test');
$routes[0]->expects($this->any())
->method('parse')

View file

@ -136,7 +136,7 @@ class ClassRegistryTest extends CakeTestCase {
*/
public function testAddModel() {
$Tag = ClassRegistry::init('RegisterArticleTag');
$this->assertTrue(is_a($Tag, 'RegisterArticleTag'));
$this->assertInstanceOf('RegisterArticleTag', $Tag);
$TagCopy = ClassRegistry::isKeySet('RegisterArticleTag');
$this->assertTrue($TagCopy);
@ -145,11 +145,11 @@ class ClassRegistryTest extends CakeTestCase {
$TagCopy = ClassRegistry::getObject('RegisterArticleTag');
$this->assertTrue(is_a($TagCopy, 'RegisterArticleTag'));
$this->assertInstanceOf('RegisterArticleTag', $TagCopy);
$this->assertSame($Tag, $TagCopy);
$NewTag = ClassRegistry::init(array('class' => 'RegisterArticleTag', 'alias' => 'NewTag'));
$this->assertTrue(is_a($Tag, 'RegisterArticleTag'));
$this->assertInstanceOf('RegisterArticleTag', $Tag);
$NewTagCopy = ClassRegistry::init(array('class' => 'RegisterArticleTag', 'alias' => 'NewTag'));
@ -166,17 +166,17 @@ class ClassRegistryTest extends CakeTestCase {
$this->assertTrue($TagCopy->name === 'SomeOtherName');
$User = ClassRegistry::init(array('class' => 'RegisterUser', 'alias' => 'User', 'table' => false));
$this->assertTrue(is_a($User, 'AppModel'));
$this->assertInstanceOf('AppModel', $User);
$UserCopy = ClassRegistry::init(array('class' => 'RegisterUser', 'alias' => 'User', 'table' => false));
$this->assertTrue(is_a($UserCopy, 'AppModel'));
$this->assertInstanceOf('AppModel', $UserCopy);
$this->assertEquals($User, $UserCopy);
$Category = ClassRegistry::init(array('class' => 'RegisterCategory'));
$this->assertTrue(is_a($Category, 'RegisterCategory'));
$this->assertInstanceOf('RegisterCategory', $Category);
$ParentCategory = ClassRegistry::init(array('class' => 'RegisterCategory', 'alias' => 'ParentCategory'));
$this->assertTrue(is_a($ParentCategory, 'RegisterCategory'));
$this->assertInstanceOf('RegisterCategory', $ParentCategory);
$this->assertNotSame($Category, $ParentCategory);
$this->assertNotEquals($Category->alias, $ParentCategory->alias);
@ -193,12 +193,12 @@ class ClassRegistryTest extends CakeTestCase {
ClassRegistry::init('RegisterArticleTag');
$ArticleTag = ClassRegistry::getObject('RegisterArticleTag');
$this->assertTrue(is_a($ArticleTag, 'RegisterArticleTag'));
$this->assertInstanceOf('RegisterArticleTag', $ArticleTag);
ClassRegistry::flush();
$NoArticleTag = ClassRegistry::isKeySet('RegisterArticleTag');
$this->assertFalse($NoArticleTag);
$this->assertTrue(is_a($ArticleTag, 'RegisterArticleTag'));
$this->assertInstanceOf('RegisterArticleTag', $ArticleTag);
}
/**
@ -233,13 +233,13 @@ class ClassRegistryTest extends CakeTestCase {
$this->assertTrue($Tag);
$Article = ClassRegistry::getObject('Article');
$this->assertTrue(is_a($Article, 'RegisterArticle'));
$this->assertInstanceOf('RegisterArticle', $Article);
$Featured = ClassRegistry::getObject('Featured');
$this->assertTrue(is_a($Featured, 'RegisterArticleFeatured'));
$this->assertInstanceOf('RegisterArticleFeatured', $Featured);
$Tag = ClassRegistry::getObject('Tag');
$this->assertTrue(is_a($Tag, 'RegisterArticleTag'));
$this->assertInstanceOf('RegisterArticleTag', $Tag);
}
/**
@ -254,15 +254,15 @@ class ClassRegistryTest extends CakeTestCase {
//Faking a plugin
CakePlugin::load('RegistryPlugin', array('path' => '/fake/path'));
$TestRegistryPluginModel = ClassRegistry::init('RegistryPlugin.TestRegistryPluginModel');
$this->assertTrue(is_a($TestRegistryPluginModel, 'TestRegistryPluginModel'));
$this->assertInstanceOf('TestRegistryPluginModel', $TestRegistryPluginModel);
$this->assertEquals('something_', $TestRegistryPluginModel->tablePrefix);
$PluginUser = ClassRegistry::init(array('class' => 'RegistryPlugin.RegisterUser', 'alias' => 'RegistryPluginUser', 'table' => false));
$this->assertTrue(is_a($PluginUser, 'RegistryPluginAppModel'));
$this->assertInstanceOf('RegistryPluginAppModel', $PluginUser);
$PluginUserCopy = ClassRegistry::getObject('RegistryPluginUser');
$this->assertTrue(is_a($PluginUserCopy, 'RegistryPluginAppModel'));
$this->assertInstanceOf('RegistryPluginAppModel', $PluginUserCopy);
$this->assertSame($PluginUser, $PluginUserCopy);
CakePlugin::unload();
}

View file

@ -3978,6 +3978,40 @@ class FormHelperTest extends CakeTestCase {
'/div'
);
$this->assertTags($result, $expected);
$result = $this->Form->input('Model.field', array(
'type' => 'radio',
'options' => array(
1 => 'A',
2 => 'B',
3 => 'C'
),
'disabled' => array(1)
));
$expected = array(
'div' => array('class' => 'input radio'),
'fieldset' => array(),
'legend' => array(),
'Field',
'/legend',
array('input' => array('type' => 'hidden', 'name' => 'data[Model][field]', 'id' => 'ModelField_', 'value' => '')),
array('input' => array('type' => 'radio', 'name' => 'data[Model][field]', 'id' => 'ModelField1', 'disabled' => 'disabled', 'value' => '1')),
array('label' => array('for' => 'ModelField1')),
'A',
'/label',
array('input' => array('type' => 'radio', 'name' => 'data[Model][field]', 'id' => 'ModelField2', 'value' => '2')),
array('label' => array('for' => 'ModelField2')),
'B',
'/label',
array('input' => array('type' => 'radio', 'name' => 'data[Model][field]', 'id' => 'ModelField3', 'value' => '3')),
array('label' => array('for' => 'ModelField3')),
'C',
'/label',
'/fieldset',
'/div'
);
$this->assertTags($result, $expected);
}
/**

View file

@ -699,7 +699,7 @@ class JsHelperTest extends CakeTestCase {
}
/**
* test set()'ing variables to the Javascript buffer and controlling the output var name.
* test set()'ing variables to the JavaScript buffer and controlling the output var name.
*
* @return void
*/

View file

@ -311,7 +311,7 @@ class ClassRegistry {
$duplicate = false;
if ($this->isKeySet($alias)) {
$model = $this->getObject($alias);
if (is_object($model) && (is_a($model, $class) || $model->alias === $class)) {
if (is_object($model) && ($model instanceof $class || $model->alias === $class)) {
$duplicate = $model;
}
unset($model);

View file

@ -20,7 +20,7 @@
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
App::import('Model', 'ConnectionManager');
App::uses('ConnectionManager', 'Model');
/**
* Data Sanitization.

View file

@ -1506,7 +1506,7 @@ class FormHelper extends AppHelper {
}
foreach ($options as $optValue => $optTitle) {
$optionsHere = array('value' => $optValue);
$optionsHere = array('value' => $optValue, 'disabled' => false);
if (isset($value) && strval($optValue) === strval($value)) {
$optionsHere['checked'] = 'checked';

View file

@ -618,7 +618,7 @@ class HtmlHelper extends AppHelper {
}
/**
* End a Buffered section of Javascript capturing.
* End a Buffered section of JavaScript capturing.
* Generates a script tag inline or in `$scripts_for_layout` depending on the settings
* used when the scriptBlock was started
*

View file

@ -2,7 +2,7 @@
/**
* jQuery Engine Helper for JsHelper
*
* Provides jQuery specific Javascript for JsHelper.
* Provides jQuery specific JavaScript for JsHelper.
*
* Implements the JsHelper interface for jQuery. All $options arrays
* support all options found in the JsHelper, as well as those in the jQuery
@ -30,7 +30,7 @@ App::uses('JsBaseEngineHelper', 'View/Helper');
/**
* jQuery Engine Helper for JsHelper
*
* Provides jQuery specific Javascript for JsHelper.
* Provides jQuery specific JavaScript for JsHelper.
*
* Implements the JsHelper interface for jQuery. All $options arrays
* support all options found in the JsHelper, as well as those in the jQuery
@ -167,7 +167,7 @@ class JqueryEngineHelper extends JsBaseEngineHelper {
* - 'stop' - Whether you want the event to stopped. (defaults true)
*
* @param string $type Type of event to bind to the current dom id
* @param string $callback The Javascript function you wish to trigger or the function literal
* @param string $callback The JavaScript function you wish to trigger or the function literal
* @param array $options Options for the event.
* @return string completed event handler
*/
@ -340,7 +340,7 @@ class JqueryEngineHelper extends JsBaseEngineHelper {
/**
* Serialize a form attached to $selector. If the current selection is not an input or
* form, errors will be created in the Javascript.
* form, errors will be created in the JavaScript.
*
* @param array $options Options for the serialization
* @return string completed form serialization script.

View file

@ -57,7 +57,7 @@ abstract class JsBaseEngineHelper extends AppHelper {
protected $_callbackArguments = array();
/**
* Create an `alert()` message in Javascript
* Create an `alert()` message in JavaScript
*
* @param string $message Message you want to alter.
* @return string completed alert()
@ -68,7 +68,7 @@ abstract class JsBaseEngineHelper extends AppHelper {
/**
* Redirects to an URL. Creates a window.location modification snippet
* that can be used to trigger 'redirects' from Javascript.
* that can be used to trigger 'redirects' from JavaScript.
*
* @param string|array $url URL
* @return string completed redirect in javascript
@ -101,7 +101,7 @@ abstract class JsBaseEngineHelper extends AppHelper {
}
/**
* Create a `prompt()` Javascript function
* Create a `prompt()` JavaScript function
*
* @param string $message Message you want to prompt.
* @param string $default Default message
@ -297,7 +297,7 @@ abstract class JsBaseEngineHelper extends AppHelper {
* - `stop` - Whether you want the event to stopped. (defaults to true)
*
* @param string $type Type of event to bind to the current dom id
* @param string $callback The Javascript function you wish to trigger or the function literal
* @param string $callback The JavaScript function you wish to trigger or the function literal
* @param array $options Options for the event.
* @return string completed event handler
*/
@ -363,7 +363,7 @@ abstract class JsBaseEngineHelper extends AppHelper {
* - `type` - Data type for response. 'json' and 'html' are supported. Default is html for most libraries.
* - `evalScripts` - Whether or not <script> tags should be eval'ed.
* - `dataExpression` - Should the `data` key be treated as a callback. Useful for supplying `$options['data']` as
* another Javascript expression.
* another JavaScript expression.
*
* @param string|array $url Array or String URL to target with the request.
* @param array $options Array of options. See above for cross library supported options
@ -475,7 +475,7 @@ abstract class JsBaseEngineHelper extends AppHelper {
abstract public function serializeForm($options = array());
/**
* Parse an options assoc array into an Javascript object literal.
* Parse an options assoc array into an JavaScript object literal.
* Similar to object() but treats any non-integer value as a string,
* does not include `{ }`
*

View file

@ -19,7 +19,7 @@ App::uses('JsBaseEngineHelper', 'View/Helper');
/**
* MooTools Engine Helper for JsHelper
*
* Provides MooTools specific Javascript for JsHelper.
* Provides MooTools specific JavaScript for JsHelper.
* Assumes that you have the following MooTools packages
*
* - Remote, Remote.HTML, Remote.JSON
@ -144,7 +144,7 @@ class MootoolsEngineHelper extends JsBaseEngineHelper {
* - 'stop' - Whether you want the event to stopped. (defaults true)
*
* @param string $type Type of event to bind to the current dom id
* @param string $callback The Javascript function you wish to trigger or the function literal
* @param string $callback The JavaScript function you wish to trigger or the function literal
* @param array $options Options for the event.
* @return string completed event handler
*/

View file

@ -2,7 +2,7 @@
/**
* Prototype Engine Helper for JsHelper
*
* Provides Prototype specific Javascript for JsHelper. Requires at least
* Provides Prototype specific JavaScript for JsHelper. Requires at least
* Prototype 1.6
*
* PHP 5
@ -26,7 +26,7 @@ App::uses('JsBaseEngineHelper', 'View/Helper');
/**
* Prototype Engine Helper for JsHelper
*
* Provides Prototype specific Javascript for JsHelper. Requires at least
* Provides Prototype specific JavaScript for JsHelper. Requires at least
* Prototype 1.6
*
* @package Cake.View.Helper
@ -142,7 +142,7 @@ class PrototypeEngineHelper extends JsBaseEngineHelper {
* - `stop` - Whether you want the event to stopped. (defaults true)
*
* @param string $type Type of event to bind to the current 946 id
* @param string $callback The Javascript function you wish to trigger or the function literal
* @param string $callback The JavaScript function you wish to trigger or the function literal
* @param array $options Options for the event.
* @return string completed event handler
*/