mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Merge remote-tracking branch 'origin/2.0' into 2.0-class-loading
Conflicts: cake/libs/view/helpers/js.php cake/tests/lib/templates/missing_conenction.php cake/tests/lib/templates/missing_connection.php lib/Cake/Model/ConnectionManager.php lib/Cake/TestSuite/templates/missing_conenction.php lib/Cake/View/Helper/FormHelper.php lib/Cake/tests/Case/Core/ConfigureTest.php
This commit is contained in:
commit
000e05b468
40 changed files with 342 additions and 110 deletions
|
@ -28,7 +28,6 @@ Cache::config('default', array('engine' => 'File'));
|
|||
|
||||
/**
|
||||
* The settings below can be used to set additional paths to models, views and controllers.
|
||||
* This is related to Ticket #470 (https://trac.cakephp.org/ticket/470)
|
||||
*
|
||||
* App::build(array(
|
||||
* 'plugins' => array('/full/path/to/plugins/', '/next/full/path/to/plugins/'),
|
||||
|
|
9
cake/tests/test_app/config/var_test2.php
Normal file
9
cake/tests/test_app/config/var_test2.php
Normal file
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
$config = array(
|
||||
'Read' => 'value2',
|
||||
'Deep' => array(
|
||||
'Second' => array(
|
||||
'SecondDeepest' => 'buried2'
|
||||
)
|
||||
)
|
||||
);
|
1
cake/tests/test_app/views/posts/alt_ext.alt
Normal file
1
cake/tests/test_app/views/posts/alt_ext.alt
Normal file
|
@ -0,0 +1 @@
|
|||
alt ext
|
|
@ -91,6 +91,21 @@ class Cache {
|
|||
* Fast reads/writes, and benefits from memcache being distributed.
|
||||
* - `XcacheEngine` - Uses the Xcache extension, an alternative to APC.
|
||||
*
|
||||
* The following keys are used in core cache engines:
|
||||
*
|
||||
* - `duration` Specify how long items in this cache configuration last.
|
||||
* - `prefix` Prefix appended to all entries. Good for when you need to share a keyspace
|
||||
* with either another cache config or annother application.
|
||||
* - `probability` Probability of hitting a cache gc cleanup. Setting to 0 will disable
|
||||
* cache::gc from ever being called automatically.
|
||||
* - `servers' Used by memcache. Give the address of the memcached servers to use.
|
||||
* - `compress` Used by memcache. Enables memcache's compressed format.
|
||||
* - `serialize` Used by FileCache. Should cache objects be serialized first.
|
||||
* - `path` Used by FileCache. Path to where cachefiles should be saved.
|
||||
* - `lock` Used by FileCache. Should files be locked before writing to them?
|
||||
* - `user` Used by Xcache. Username for XCache
|
||||
* - `password` Used by Xcache. Password for XCache
|
||||
*
|
||||
* @see app/config/core.php for configuration settings
|
||||
* @param string $name Name of the configuration
|
||||
* @param array $settings Optional associative array of settings passed to the engine
|
||||
|
@ -147,7 +162,7 @@ class Cache {
|
|||
}
|
||||
self::$_engines[$name] = new $cacheClass();
|
||||
if (self::$_engines[$name]->init($config)) {
|
||||
if (time() % self::$_engines[$name]->settings['probability'] === 0) {
|
||||
if (self::$_engines[$name]->settings['probability'] && time() % self::$_engines[$name]->settings['probability'] === 0) {
|
||||
self::$_engines[$name]->gc();
|
||||
}
|
||||
return true;
|
||||
|
@ -579,4 +594,4 @@ abstract class CacheEngine {
|
|||
$key = Inflector::underscore(str_replace(array(DS, '/', '.'), '_', strval($key)));
|
||||
return $key;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -310,7 +310,7 @@ class ModelTask extends BakeTask {
|
|||
* @param object $model Model to have validations generated for.
|
||||
* @return array $validate Array of user selected validations.
|
||||
*/
|
||||
public function doValidation(&$model) {
|
||||
public function doValidation($model) {
|
||||
if (!is_object($model)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -442,7 +442,7 @@ class ModelTask extends BakeTask {
|
|||
* @param object $model
|
||||
* @return array $assocaitons
|
||||
*/
|
||||
public function doAssociations(&$model) {
|
||||
public function doAssociations($model) {
|
||||
if (!is_object($model)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -493,7 +493,7 @@ class ModelTask extends BakeTask {
|
|||
* @param array $associations Array of inprogress associations
|
||||
* @return array $associations with belongsTo added in.
|
||||
*/
|
||||
public function findBelongsTo(&$model, $associations) {
|
||||
public function findBelongsTo($model, $associations) {
|
||||
$fields = $model->schema(true);
|
||||
foreach ($fields as $fieldName => $field) {
|
||||
$offset = strpos($fieldName, '_id');
|
||||
|
@ -522,7 +522,7 @@ class ModelTask extends BakeTask {
|
|||
* @param array $associations Array of inprogress associations
|
||||
* @return array $associations with hasOne and hasMany added in.
|
||||
*/
|
||||
public function findHasOneAndMany(&$model, $associations) {
|
||||
public function findHasOneAndMany($model, $associations) {
|
||||
$foreignKey = $this->_modelKey($model->name);
|
||||
foreach ($this->_tables as $otherTable) {
|
||||
$tempOtherModel = $this->_getModelObject($this->_modelName($otherTable), $otherTable);
|
||||
|
@ -565,7 +565,7 @@ class ModelTask extends BakeTask {
|
|||
* @param array $associations Array of inprogress associations
|
||||
* @return array $associations with hasAndBelongsToMany added in.
|
||||
*/
|
||||
public function findHasAndBelongsToMany(&$model, $associations) {
|
||||
public function findHasAndBelongsToMany($model, $associations) {
|
||||
$foreignKey = $this->_modelKey($model->name);
|
||||
foreach ($this->_tables as $otherTable) {
|
||||
$tempOtherModel = $this->_getModelObject($this->_modelName($otherTable), $otherTable);
|
||||
|
@ -605,7 +605,7 @@ class ModelTask extends BakeTask {
|
|||
* @param array $associations Array of associations to be confirmed.
|
||||
* @return array Array of confirmed associations
|
||||
*/
|
||||
public function confirmAssociations(&$model, $associations) {
|
||||
public function confirmAssociations($model, $associations) {
|
||||
foreach ($associations as $type => $settings) {
|
||||
if (!empty($associations[$type])) {
|
||||
$count = count($associations[$type]);
|
||||
|
|
|
@ -276,7 +276,7 @@ class ProjectTask extends Shell {
|
|||
$contents = $File->read();
|
||||
if (preg_match('/([\s]*define\(\'CAKE_CORE_INCLUDE_PATH\',[\s\'A-z0-9]*\);)/', $contents, $match)) {
|
||||
$root = strpos(CAKE_CORE_INCLUDE_PATH, '/') === 0 ? " DS . '" : "'";
|
||||
$result = str_replace($match[0], "\t\tdefine('CAKE_CORE_INCLUDE_PATH', " . $root . str_replace(DS, "' . DS . '", trim(CAKE_CORE_INCLUDE_PATH, DS)) . "');", $contents);
|
||||
$result = str_replace($match[0], "\n\t\tdefine('CAKE_CORE_INCLUDE_PATH', " . $root . str_replace(DS, "' . DS . '", trim(CAKE_CORE_INCLUDE_PATH, DS)) . "');", $contents);
|
||||
if (!$File->write($result)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -287,7 +287,7 @@ class ProjectTask extends Shell {
|
|||
$File = new File($path . 'webroot' . DS . 'test.php');
|
||||
$contents = $File->read();
|
||||
if (preg_match('/([\s]*define\(\'CAKE_CORE_INCLUDE_PATH\',[\s\'A-z0-9]*\);)/', $contents, $match)) {
|
||||
$result = str_replace($match[0], "\t\tdefine('CAKE_CORE_INCLUDE_PATH', " . $root . str_replace(DS, "' . DS . '", trim(CAKE_CORE_INCLUDE_PATH, DS)) . "');", $contents);
|
||||
$result = str_replace($match[0], "\n\t\tdefine('CAKE_CORE_INCLUDE_PATH', " . $root . str_replace(DS, "' . DS . '", trim(CAKE_CORE_INCLUDE_PATH, DS)) . "');", $contents);
|
||||
if (!$File->write($result)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -384,4 +384,4 @@ class ProjectTask extends Shell {
|
|||
));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -302,7 +302,7 @@ class TestTask extends BakeTask {
|
|||
* @param object $subject The object you want to generate fixtures for.
|
||||
* @return array Array of fixtures to be included in the test.
|
||||
*/
|
||||
public function generateFixtureList(&$subject) {
|
||||
public function generateFixtureList($subject) {
|
||||
$this->_fixtures = array();
|
||||
if (is_a($subject, 'Model')) {
|
||||
$this->_processModel($subject);
|
||||
|
@ -319,7 +319,7 @@ class TestTask extends BakeTask {
|
|||
* @param Model $subject A Model class to scan for associations and pull fixtures off of.
|
||||
* @return void
|
||||
*/
|
||||
protected function _processModel(&$subject) {
|
||||
protected function _processModel($subject) {
|
||||
$this->_addFixture($subject->name);
|
||||
$associated = $subject->getAssociated();
|
||||
foreach ($associated as $alias => $type) {
|
||||
|
@ -343,7 +343,7 @@ class TestTask extends BakeTask {
|
|||
* @param Controller $subject A controller to pull model names off of.
|
||||
* @return void
|
||||
*/
|
||||
protected function _processController(&$subject) {
|
||||
protected function _processController($subject) {
|
||||
$subject->constructClasses();
|
||||
$models = array(Inflector::classify($subject->name));
|
||||
if (!empty($subject->uses)) {
|
||||
|
|
|
@ -458,7 +458,7 @@ class ViewTask extends BakeTask {
|
|||
* @return array $associations
|
||||
* @access private
|
||||
*/
|
||||
private function __associations(&$model) {
|
||||
private function __associations($model) {
|
||||
$keys = array('belongsTo', 'hasOne', 'hasMany', 'hasAndBelongsToMany');
|
||||
$associations = array();
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
<div class="<?php echo $pluralVar;?> form">
|
||||
<?php echo "<?php echo \$this->Form->create('{$modelClass}');?>\n";?>
|
||||
<fieldset>
|
||||
<legend><?php printf("<?php __('%s %s'); ?>", Inflector::humanize($action), $singularHumanName); ?></legend>
|
||||
<legend><?php printf("<?php __('%s %s'); ?>", Inflector::humanize($action), $singularHumanName); ?></legend>
|
||||
<?php
|
||||
echo "\t<?php\n";
|
||||
foreach ($fields as $field) {
|
||||
|
|
|
@ -28,7 +28,6 @@ Cache::config('default', array('engine' => 'File'));
|
|||
|
||||
/**
|
||||
* The settings below can be used to set additional paths to models, views and controllers.
|
||||
* This is related to Ticket #470 (https://trac.cakephp.org/ticket/470)
|
||||
*
|
||||
* App::build(array(
|
||||
* 'plugins' => array('/full/path/to/plugins/', '/next/full/path/to/plugins/'),
|
||||
|
|
|
@ -331,7 +331,7 @@ class AuthComponent extends Component {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (empty($this->authorize) || $this->isAuthorized()) {
|
||||
if (empty($this->authorize) || $this->isAuthorized($this->user())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -707,4 +707,4 @@ class AuthComponent extends Component {
|
|||
public function flash($message) {
|
||||
$this->Session->setFlash($message, $this->flash['element'], $this->flash['params'], $this->flash['key']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -272,9 +272,9 @@ class Configure {
|
|||
* Loads stored configuration information from a resource. You can add
|
||||
* config file resource readers with `Configure::config()`.
|
||||
*
|
||||
* Loaded configuration infomration will be merged with the current
|
||||
* Loaded configuration information will be merged with the current
|
||||
* runtime configuration. You can load configuration files from plugins
|
||||
* by preceeding the filename with the plugin name.
|
||||
* by preceding the filename with the plugin name.
|
||||
*
|
||||
* `Configure::load('Users.user', 'default')`
|
||||
*
|
||||
|
@ -285,15 +285,26 @@ class Configure {
|
|||
*
|
||||
* @link http://book.cakephp.org/view/929/load
|
||||
* @param string $key name of configuration resource to load.
|
||||
* @param string $config Name of the configured reader to use to read the resource identfied by $key.
|
||||
* @param string $config Name of the configured reader to use to read the resource identified by $key.
|
||||
* @param boolean $merge if config files should be merged instead of simply overridden
|
||||
* @return mixed false if file not found, void if load successful.
|
||||
* @throws ConfigureException Will throw any exceptions the reader raises.
|
||||
*/
|
||||
public static function load($key, $config = 'default') {
|
||||
public static function load($key, $config = 'default', $merge = true) {
|
||||
if (!isset(self::$_readers[$config])) {
|
||||
return false;
|
||||
}
|
||||
$values = self::$_readers[$config]->read($key);
|
||||
|
||||
if ($merge) {
|
||||
$keys = array_keys($values);
|
||||
foreach ($keys as $key) {
|
||||
if (($c = self::read($key)) && is_array($values[$key]) && is_array($c)) {
|
||||
$values[$key] = array_merge_recursive($c, $values[$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return self::write($values);
|
||||
}
|
||||
|
||||
|
|
|
@ -31,9 +31,8 @@ class AclBehavior extends ModelBehavior {
|
|||
* Maps ACL type options to ACL models
|
||||
*
|
||||
* @var array
|
||||
* @access protected
|
||||
*/
|
||||
private $__typeMaps = array('requester' => 'Aro', 'controlled' => 'Aco');
|
||||
private $__typeMaps = array('requester' => 'Aro', 'controlled' => 'Aco', 'both' => array('Aro', 'Aco'));
|
||||
|
||||
/**
|
||||
* Sets up the configuation for the model, and loads ACL models if they haven't been already
|
||||
|
@ -45,14 +44,19 @@ class AclBehavior extends ModelBehavior {
|
|||
if (is_string($config)) {
|
||||
$config = array('type' => $config);
|
||||
}
|
||||
$this->settings[$model->name] = array_merge(array('type' => 'requester'), (array)$config);
|
||||
$this->settings[$model->name] = array_merge(array('type' => 'controlled'), (array)$config);
|
||||
$this->settings[$model->name]['type'] = strtolower($this->settings[$model->name]['type']);
|
||||
|
||||
$type = $this->__typeMaps[$this->settings[$model->name]['type']];
|
||||
$types = $this->__typeMaps[$this->settings[$model->name]['type']];
|
||||
if (!class_exists('AclNode')) {
|
||||
require LIBS . 'model' . DS . 'db_acl.php';
|
||||
}
|
||||
$model->{$type} = ClassRegistry::init($type);
|
||||
if (!is_array($types)) {
|
||||
$types = array($types);
|
||||
}
|
||||
foreach ($types as $type) {
|
||||
$model->{$type} = ClassRegistry::init($type);
|
||||
}
|
||||
if (!method_exists($model, 'parentNode')) {
|
||||
trigger_error(__d('cake_dev', 'Callback parentNode() not defined in %s', $model->alias), E_USER_WARNING);
|
||||
}
|
||||
|
@ -62,11 +66,18 @@ class AclBehavior extends ModelBehavior {
|
|||
* Retrieves the Aro/Aco node for this model
|
||||
*
|
||||
* @param mixed $ref
|
||||
* @param string $type Only needed when Acl is set up as 'both', specify 'Aro' or 'Aco' to get the correct node
|
||||
* @return array
|
||||
* @link http://book.cakephp.org/view/1322/node
|
||||
*/
|
||||
public function node($model, $ref = null) {
|
||||
$type = $this->__typeMaps[$this->settings[$model->name]['type']];
|
||||
public function node($model, $ref = null, $type = null) {
|
||||
if (empty($type)) {
|
||||
$type = $this->__typeMaps[$this->settings[$model->name]['type']];
|
||||
if (is_array($type)) {
|
||||
trigger_error(__('AclBehavior is setup with more then one type, please specify type parameter for node()', true), E_USER_WARNING);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
if (empty($ref)) {
|
||||
$ref = array('model' => $model->name, 'foreign_key' => $model->id);
|
||||
}
|
||||
|
@ -80,22 +91,27 @@ class AclBehavior extends ModelBehavior {
|
|||
* @return void
|
||||
*/
|
||||
public function afterSave($model, $created) {
|
||||
$type = $this->__typeMaps[$this->settings[$model->name]['type']];
|
||||
$parent = $model->parentNode();
|
||||
if (!empty($parent)) {
|
||||
$parent = $this->node($model, $parent);
|
||||
$types = $this->__typeMaps[$this->settings[$model->name]['type']];
|
||||
if (!is_array($types)) {
|
||||
$types = array($types);
|
||||
}
|
||||
$data = array(
|
||||
'parent_id' => isset($parent[0][$type]['id']) ? $parent[0][$type]['id'] : null,
|
||||
'model' => $model->name,
|
||||
'foreign_key' => $model->id
|
||||
);
|
||||
if (!$created) {
|
||||
$node = $this->node($model);
|
||||
$data['id'] = isset($node[0][$type]['id']) ? $node[0][$type]['id'] : null;
|
||||
foreach ($types as $type) {
|
||||
$parent = $model->parentNode();
|
||||
if (!empty($parent)) {
|
||||
$parent = $this->node($model, $parent, $type);
|
||||
}
|
||||
$data = array(
|
||||
'parent_id' => isset($parent[0][$type]['id']) ? $parent[0][$type]['id'] : null,
|
||||
'model' => $model->alias,
|
||||
'foreign_key' => $model->id
|
||||
);
|
||||
if (!$created) {
|
||||
$node = $this->node($model, null, $type);
|
||||
$data['id'] = isset($node[0][$type]['id']) ? $node[0][$type]['id'] : null;
|
||||
}
|
||||
$model->{$type}->create();
|
||||
$model->{$type}->save($data);
|
||||
}
|
||||
$model->{$type}->create();
|
||||
$model->{$type}->save($data);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -104,10 +120,15 @@ class AclBehavior extends ModelBehavior {
|
|||
* @return void
|
||||
*/
|
||||
public function afterDelete($model) {
|
||||
$type = $this->__typeMaps[$this->settings[$model->name]['type']];
|
||||
$node = Set::extract($this->node($model), "0.{$type}.id");
|
||||
if (!empty($node)) {
|
||||
$model->{$type}->delete($node);
|
||||
$types = $this->__typeMaps[$this->settings[$model->name]['type']];
|
||||
if (!is_array($types)) {
|
||||
$types = array($types);
|
||||
}
|
||||
foreach ($types as $type) {
|
||||
$node = Set::extract($this->node($model, null, $type), "0.{$type}.id");
|
||||
if (!empty($node)) {
|
||||
$model->{$type}->delete($node);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1449,7 +1449,7 @@ class Model extends Object {
|
|||
* @param mixed $id ID of record in this model
|
||||
* @access private
|
||||
*/
|
||||
function __saveMulti($joined, $id, &$db) {
|
||||
function __saveMulti($joined, $id, $db) {
|
||||
foreach ($joined as $assoc => $data) {
|
||||
|
||||
if (isset($this->hasAndBelongsToMany[$assoc])) {
|
||||
|
@ -1959,7 +1959,7 @@ class Model extends Object {
|
|||
*/
|
||||
protected function _deleteLinks($id) {
|
||||
foreach ($this->hasAndBelongsToMany as $assoc => $data) {
|
||||
$joinModel = $data['with'];
|
||||
list($plugin, $joinModel) = pluginSplit($data['with']);
|
||||
$records = $this->{$joinModel}->find('all', array(
|
||||
'conditions' => array_merge(array($this->{$joinModel}->escapeField($data['foreignKey']) => $id)),
|
||||
'fields' => $this->{$joinModel}->primaryKey,
|
||||
|
|
|
@ -117,7 +117,7 @@ class CakeSocket {
|
|||
}
|
||||
|
||||
if (!empty($errNum) || !empty($errStr)) {
|
||||
$this->setLastError($errStr, $errNum);
|
||||
$this->setLastError($errNum, $errStr);
|
||||
throw new SocketException($errStr, $errNum);
|
||||
}
|
||||
|
||||
|
|
|
@ -221,7 +221,8 @@ class Router {
|
|||
* Shows connecting a route with custom route parameters as well as providing patterns for those parameters.
|
||||
* Patterns for routing parameters do not need capturing groups, as one will be added for each route params.
|
||||
*
|
||||
* $options offers three 'special' keys. `pass`, `persist` and `routeClass` have special meaning in the $options array.
|
||||
* $options offers four 'special' keys. `pass`, `named`, `persist` and `routeClass`
|
||||
* have special meaning in the $options array.
|
||||
*
|
||||
* `pass` is used to define which of the routed parameters should be shifted into the pass array. Adding a
|
||||
* parameter to pass will remove it from the regular route array. Ex. `'pass' => array('slug')`
|
||||
|
@ -233,6 +234,9 @@ class Router {
|
|||
* `routeClass` is used to extend and change how individual routes parse requests and handle reverse routing,
|
||||
* via a custom routing class. Ex. `'routeClass' => 'SlugRoute'`
|
||||
*
|
||||
* `named` is used to configure named parameters at the route level. This key uses the same options
|
||||
* as Router::connectNamed()
|
||||
*
|
||||
* @param string $route A string describing the template of the route
|
||||
* @param array $defaults An array describing the default route parameters. These parameters will be used by default
|
||||
* and can supply routing parameters that are not dynamic. See above.
|
||||
|
@ -286,7 +290,7 @@ class Router {
|
|||
* `Router::redirect('/home/*', array('controller' => 'posts', 'action' => 'view', array('persist' => true));`
|
||||
*
|
||||
* Redirects /home/* to /posts/view and passes the parameters to /posts/view. Using an array as the
|
||||
* redirect destination allows you to use other routes to define where a url string should be redirected ot.
|
||||
* redirect destination allows you to use other routes to define where a url string should be redirected to.
|
||||
*
|
||||
* `Router::redirect('/posts/*', 'http://google.com', array('status' => 302));`
|
||||
*
|
||||
|
|
|
@ -252,7 +252,7 @@ class CakeTestSuiteDispatcher {
|
|||
} catch (MissingConnectionException $exception) {
|
||||
ob_end_clean();
|
||||
$baseDir = $this->_baseDir;
|
||||
include CAKE_TESTS_LIB . 'templates' . DS . 'missing_conenction.php';
|
||||
include CAKE_TESTS_LIB . 'templates' . DS . 'missing_connection.php';
|
||||
exit();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -140,7 +140,7 @@ class CakeTestFixture {
|
|||
* @param object $db An instance of the database object used to create the fixture table
|
||||
* @return boolean True on success, false on failure
|
||||
*/
|
||||
public function create(&$db) {
|
||||
public function create($db) {
|
||||
if (!isset($this->fields) || empty($this->fields)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -157,7 +157,7 @@ class CakeTestFixture {
|
|||
* @param object $db An instance of the database object used to create the fixture table
|
||||
* @return boolean True on success, false on failure
|
||||
*/
|
||||
public function drop(&$db) {
|
||||
public function drop($db) {
|
||||
if (empty($this->fields)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -174,7 +174,7 @@ class CakeTestFixture {
|
|||
* @param object $db An instance of the database into which the records will be inserted
|
||||
* @return boolean on success or if there are no records to insert, or false on failure
|
||||
*/
|
||||
public function insert(&$db) {
|
||||
public function insert($db) {
|
||||
if (!isset($this->_insert)) {
|
||||
$values = array();
|
||||
if (isset($this->records) && !empty($this->records)) {
|
||||
|
@ -195,7 +195,7 @@ class CakeTestFixture {
|
|||
* @param object $db A reference to a db instance
|
||||
* @return boolean
|
||||
*/
|
||||
public function truncate(&$db) {
|
||||
public function truncate($db) {
|
||||
$fullDebug = $db->fullDebug;
|
||||
$db->fullDebug = false;
|
||||
$return = $db->truncate($this->table);
|
||||
|
|
|
@ -177,7 +177,7 @@ class ClassRegistry {
|
|||
* @param mixed $object Object to store
|
||||
* @return boolean True if the object was written, false if $key already exists
|
||||
*/
|
||||
public static function addObject($key, &$object) {
|
||||
public static function addObject($key, $object) {
|
||||
$_this = ClassRegistry::getInstance();
|
||||
$key = Inflector::underscore($key);
|
||||
if (!isset($_this->__objects[$key])) {
|
||||
|
|
|
@ -540,17 +540,11 @@ class Inflector {
|
|||
* @param string $string the string you want to slug
|
||||
* @param string $replacement will replace keys in map
|
||||
* @param array $map extra elements to map to the replacement
|
||||
* @deprecated $map param will be removed in future versions. Use Inflector::rules() instead
|
||||
* @return string
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1479/Class-methods
|
||||
*/
|
||||
public static function slug($string, $replacement = '_', $map = array()) {
|
||||
|
||||
if (is_array($replacement)) {
|
||||
$map = $replacement;
|
||||
$replacement = '_';
|
||||
}
|
||||
public static function slug($string, $replacement = '_') {
|
||||
$quotedReplacement = preg_quote($replacement, '/');
|
||||
|
||||
$merge = array(
|
||||
|
@ -559,7 +553,7 @@ class Inflector {
|
|||
sprintf('/^[%s]+|[%s]+$/', $quotedReplacement, $quotedReplacement) => '',
|
||||
);
|
||||
|
||||
$map = $map + self::$_transliteration + $merge;
|
||||
$map = self::$_transliteration + $merge;
|
||||
return preg_replace(array_keys($map), array_values($map), $string);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -263,7 +263,7 @@ class Sanitize {
|
|||
*
|
||||
* @param Model $model The model containing the data to be formatted
|
||||
*/
|
||||
public static function formatColumns(&$model) {
|
||||
public static function formatColumns($model) {
|
||||
foreach ($model->data as $name => $values) {
|
||||
if ($name == $model->alias) {
|
||||
$curModel =& $model;
|
||||
|
|
|
@ -181,7 +181,7 @@ class Xml {
|
|||
* @param string $format Either 'attribute' or 'tags'. This determines where nested keys go.
|
||||
* @return void
|
||||
*/
|
||||
protected static function _fromArray(&$dom, &$node, &$data, $format) {
|
||||
protected static function _fromArray($dom, $node, &$data, $format) {
|
||||
if (empty($data) || !is_array($data)) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -366,10 +366,6 @@ class FormHelper extends AppHelper {
|
|||
unset($options['label']);
|
||||
}
|
||||
$submitOptions = $options;
|
||||
|
||||
if (!$submit) {
|
||||
$submit = __d('cake', 'Submit');
|
||||
}
|
||||
}
|
||||
$out .= $this->submit($submit, $submitOptions);
|
||||
}
|
||||
|
@ -1366,7 +1362,7 @@ class FormHelper extends AppHelper {
|
|||
* @link http://book.cakephp.org/view/1431/submit
|
||||
*/
|
||||
public function submit($caption = null, $options = array()) {
|
||||
if (!$caption) {
|
||||
if (!is_string($caption) && empty($caption)) {
|
||||
$caption = __d('cake', 'Submit');
|
||||
}
|
||||
$out = null;
|
||||
|
@ -2092,6 +2088,8 @@ class FormHelper extends AppHelper {
|
|||
|
||||
if (empty($attributes['class'])) {
|
||||
$attributes['class'] = 'checkbox';
|
||||
} elseif ($attributes['class'] === 'form-error') {
|
||||
$attributes['class'] = 'checkbox ' . $attributes['class'];
|
||||
}
|
||||
$label = $this->label(null, $title, $label);
|
||||
$item = $this->Html->useTag('checkboxmultiple', $name, $htmlOptions);
|
||||
|
@ -2242,4 +2240,4 @@ class FormHelper extends AppHelper {
|
|||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -407,7 +407,10 @@ class JsHelper extends AppHelper {
|
|||
* @return array Array of js options and Htmloptions
|
||||
*/
|
||||
protected function _getHtmlOptions($options, $additional = array()) {
|
||||
$htmlKeys = array_merge(array('class', 'id', 'escape', 'onblur', 'onfocus', 'rel', 'title'), $additional);
|
||||
$htmlKeys = array_merge(
|
||||
array('class', 'id', 'escape', 'onblur', 'onfocus', 'rel', 'title', 'style'),
|
||||
$additional
|
||||
);
|
||||
$htmlOptions = array();
|
||||
foreach ($htmlKeys as $key) {
|
||||
if (isset($options[$key])) {
|
||||
|
|
|
@ -324,7 +324,6 @@ class CacheTest extends CakeTestCase {
|
|||
* Check that the "Cache.disable" configuration and a change to it
|
||||
* (even after a cache config has been setup) is taken into account.
|
||||
*
|
||||
* @link https://trac.cakephp.org/ticket/6236
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
|
|
|
@ -849,6 +849,9 @@ class AuthTest extends CakeTestCase {
|
|||
|
||||
//external authed action
|
||||
$_SERVER['HTTP_REFERER'] = 'http://webmail.example.com/view/message';
|
||||
$_GET = array(
|
||||
'url' => '/posts/edit/1'
|
||||
);
|
||||
$this->Auth->Session->delete('Auth');
|
||||
$url = '/posts/edit/1';
|
||||
$this->Auth->request = $this->Controller->request = new CakeRequest($url);
|
||||
|
|
|
@ -821,7 +821,6 @@ class ScaffoldTest extends CakeTestCase {
|
|||
/**
|
||||
* test that habtm relationship keys get added to scaffoldFields.
|
||||
*
|
||||
* @see http://code.cakephp.org/tickets/view/48
|
||||
* @return void
|
||||
*/
|
||||
function testHabtmFieldAdditionWithScaffoldForm() {
|
||||
|
|
|
@ -193,17 +193,45 @@ class ConfigureTest extends CakeTestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* test load
|
||||
* test load with merging
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function testLoad() {
|
||||
function testLoadWithMerge() {
|
||||
Configure::config('test', new PhpReader(LIBS . 'tests' . DS . 'test_app' . DS . 'config' . DS));
|
||||
|
||||
$result = Configure::load('var_test', 'test');
|
||||
$this->assertTrue($result);
|
||||
|
||||
|
||||
$this->assertEquals('value', Configure::read('Read'));
|
||||
|
||||
$result = Configure::load('var_test2', 'test', true);
|
||||
$this->assertTrue($result);
|
||||
|
||||
$this->assertEquals('value2', Configure::read('Read'));
|
||||
$this->assertEquals('buried2', Configure::read('Deep.Second.SecondDeepest'));
|
||||
$this->assertEquals('buried', Configure::read('Deep.Deeper.Deepest'));
|
||||
}
|
||||
|
||||
/**
|
||||
* test loading with overwrite
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function testLoadNoMerge() {
|
||||
Configure::config('test', new PhpReader(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'config' . DS));
|
||||
|
||||
$result = Configure::load('var_test', 'test');
|
||||
$this->assertTrue($result);
|
||||
|
||||
$this->assertEquals('value', Configure::read('Read'));
|
||||
|
||||
$result = Configure::load('var_test2', 'test', false);
|
||||
$this->assertTrue($result);
|
||||
|
||||
$this->assertEquals('value2', Configure::read('Read'));
|
||||
$this->assertEquals('buried2', Configure::read('Deep.Second.SecondDeepest'));
|
||||
$this->assertNull(Configure::read('Deep.Deeper.Deepest'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -56,7 +56,7 @@ class AclPerson extends CakeTestModel {
|
|||
* @var array
|
||||
* @access public
|
||||
*/
|
||||
public $actsAs = array('Acl' => 'requester');
|
||||
public $actsAs = array('Acl' => 'both');
|
||||
|
||||
/**
|
||||
* belongsTo property
|
||||
|
@ -136,7 +136,7 @@ class AclUser extends CakeTestModel {
|
|||
* @var array
|
||||
* @access public
|
||||
*/
|
||||
public $actsAs = array('Acl');
|
||||
public $actsAs = array('Acl' => 'requester');
|
||||
|
||||
/**
|
||||
* parentNode
|
||||
|
@ -259,6 +259,20 @@ class AclBehaviorTest extends CakeTestCase {
|
|||
$this->assertTrue(is_object($Post->Aco));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test Setup of AclBehavior as both requester and controlled
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function testSetupMulti() {
|
||||
$User =& new AclPerson();
|
||||
$this->assertTrue(isset($User->Behaviors->Acl->settings['AclPerson']));
|
||||
$this->assertEqual($User->Behaviors->Acl->settings['AclPerson']['type'], 'both');
|
||||
$this->assertTrue(is_object($User->Aro));
|
||||
$this->assertTrue(is_object($User->Aco));
|
||||
}
|
||||
|
||||
/**
|
||||
* test After Save
|
||||
*
|
||||
|
@ -291,6 +305,15 @@ class AclBehaviorTest extends CakeTestCase {
|
|||
);
|
||||
$this->Aro->save($aroData);
|
||||
|
||||
$acoData = array(
|
||||
'Aco' => array(
|
||||
'model' => 'AclPerson',
|
||||
'foreign_key' => 2,
|
||||
'parent_id' => null
|
||||
)
|
||||
);
|
||||
$this->Aco->save($acoData);
|
||||
|
||||
$Person = new AclPerson();
|
||||
$data = array(
|
||||
'AclPerson' => array(
|
||||
|
@ -306,7 +329,7 @@ class AclBehaviorTest extends CakeTestCase {
|
|||
$this->assertTrue(is_array($result));
|
||||
$this->assertEqual($result['Aro']['parent_id'], 5);
|
||||
|
||||
$node = $Person->node(array('model' => 'AclPerson', 'foreign_key' => 8));
|
||||
$node = $Person->node(array('model' => 'AclPerson', 'foreign_key' => 8), 'Aro');
|
||||
$this->assertEqual(count($node), 2);
|
||||
$this->assertEqual($node[0]['Aro']['parent_id'], 5);
|
||||
$this->assertEqual($node[1]['Aro']['parent_id'], null);
|
||||
|
@ -320,17 +343,24 @@ class AclBehaviorTest extends CakeTestCase {
|
|||
);
|
||||
$this->Aro->create();
|
||||
$this->Aro->save($aroData);
|
||||
|
||||
$acoData = array(
|
||||
'Aco' => array(
|
||||
'model' => 'AclPerson',
|
||||
'foreign_key' => 1,
|
||||
'parent_id' => null
|
||||
));
|
||||
$this->Aco->create();
|
||||
$this->Aco->save($acoData);
|
||||
$Person->read(null, 8);
|
||||
$Person->set('mother_id', 1);
|
||||
$Person->save();
|
||||
$result = $this->Aro->find('first', array(
|
||||
'conditions' => array('Aro.model' => 'AclPerson', 'Aro.foreign_key' => $Person->id)
|
||||
));
|
||||
$this->assertTrue(is_array($result));
|
||||
$this->assertEqual($result['Aro']['parent_id'], 7);
|
||||
|
||||
$node = $Person->node(array('model' => 'AclPerson', 'foreign_key' => 8));
|
||||
$this->assertTrue(is_array($result));
|
||||
$this->assertEqual($result['Aro']['parent_id'], 7);
|
||||
|
||||
$node = $Person->node(array('model' => 'AclPerson', 'foreign_key' => 8), 'Aro');
|
||||
$this->assertEqual(sizeof($node), 2);
|
||||
$this->assertEqual($node[0]['Aro']['parent_id'], 7);
|
||||
$this->assertEqual($node[1]['Aro']['parent_id'], null);
|
||||
|
@ -351,6 +381,16 @@ class AclBehaviorTest extends CakeTestCase {
|
|||
);
|
||||
$this->Aro->save($aroData);
|
||||
|
||||
|
||||
$acoData = array(
|
||||
'Aco' => array(
|
||||
'model' => 'AclPerson',
|
||||
'foreign_key' => 2,
|
||||
'parent_id' => null
|
||||
)
|
||||
);
|
||||
$this->Aco->save($acoData);
|
||||
|
||||
$Person = new AclPerson();
|
||||
$data = array(
|
||||
'AclPerson' => array(
|
||||
|
@ -387,7 +427,17 @@ class AclBehaviorTest extends CakeTestCase {
|
|||
)
|
||||
);
|
||||
$this->Aro->save($aroData);
|
||||
|
||||
$acoData = array(
|
||||
'Aco' => array(
|
||||
'model' => 'AclPerson',
|
||||
'foreign_key' => 2,
|
||||
'parent_id' => null
|
||||
)
|
||||
);
|
||||
$this->Aco->save($acoData);
|
||||
$Person = new AclPerson();
|
||||
|
||||
$data = array(
|
||||
'AclPerson' => array(
|
||||
'name' => 'Trent',
|
||||
|
@ -397,7 +447,7 @@ class AclBehaviorTest extends CakeTestCase {
|
|||
);
|
||||
$Person->save($data);
|
||||
$id = $Person->id;
|
||||
$node = $Person->node();
|
||||
$node = $Person->node(null, 'Aro');
|
||||
$this->assertEqual(count($node), 2);
|
||||
$this->assertEqual($node[0]['Aro']['parent_id'], 5);
|
||||
$this->assertEqual($node[1]['Aro']['parent_id'], null);
|
||||
|
@ -450,7 +500,7 @@ class AclBehaviorTest extends CakeTestCase {
|
|||
$this->Aro->save($aroData);
|
||||
|
||||
$Person->id = 2;
|
||||
$result = $Person->node();
|
||||
$result = $Person->node(null, 'Aro');
|
||||
$this->assertTrue(is_array($result));
|
||||
$this->assertEqual(count($result), 1);
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ class DboMssqlTestDb extends DboMssql {
|
|||
* @access protected
|
||||
* @return void
|
||||
*/
|
||||
function _matchRecords(&$model, $conditions = null) {
|
||||
function _matchRecords($model, $conditions = null) {
|
||||
return $this->conditions(array('id' => array(1, 2)));
|
||||
}
|
||||
|
||||
|
|
|
@ -986,7 +986,7 @@ class DboMysqlTest extends CakeTestCase {
|
|||
* @access protected
|
||||
* @return void
|
||||
*/
|
||||
function _buildRelatedModels(&$model) {
|
||||
function _buildRelatedModels($model) {
|
||||
foreach ($model->associations() as $type) {
|
||||
foreach ($model->{$type} as $assoc => $assocData) {
|
||||
if (is_string($assocData)) {
|
||||
|
@ -1009,7 +1009,7 @@ class DboMysqlTest extends CakeTestCase {
|
|||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function &_prepareAssociationQuery(&$model, &$queryData, $binding) {
|
||||
function &_prepareAssociationQuery($model, &$queryData, $binding) {
|
||||
$type = $binding['type'];
|
||||
$assoc = $binding['model'];
|
||||
$assocData = $model->{$type}[$assoc];
|
||||
|
|
|
@ -533,6 +533,23 @@ class ModelDeleteTest extends BaseModelTest {
|
|||
$this->assertTrue($result, 'deleteAll returned false when all no records matched conditions. %s');
|
||||
}
|
||||
|
||||
/**
|
||||
* test that a plugin model as the 'with' model doesn't have issues
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function testDeleteLinksWithPLuginJoinModel() {
|
||||
$this->loadFixtures('Article', 'ArticlesTag', 'Tag');
|
||||
$Article =& new Article();
|
||||
$Article->unbindModel(array('hasAndBelongsToMany' => array('Tag')), false);
|
||||
unset($Article->Tag, $Article->ArticleTags);
|
||||
$Article->bindModel(array('hasAndBelongsToMany' => array(
|
||||
'Tag' => array('with' => 'TestPlugin.ArticlesTag')
|
||||
)), false);
|
||||
|
||||
$this->assertTrue($Article->delete(1));
|
||||
}
|
||||
|
||||
/**
|
||||
* test deleteLinks with Multiple habtm associations
|
||||
*
|
||||
|
|
|
@ -1212,7 +1212,6 @@ class ModelIntegrationTest extends BaseModelTest {
|
|||
));
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
// Tests related to ticket https://trac.cakephp.org/ticket/5594
|
||||
$TestModel = new ArticleFeatured();
|
||||
$TestFakeModel = new ArticleFeatured(array('table' => false));
|
||||
|
||||
|
|
|
@ -2972,7 +2972,8 @@ class ModelWriteTest extends BaseModelTest {
|
|||
'published' => 'Y',
|
||||
'user_id' => 1
|
||||
))
|
||||
), array('validate' => 'only'));
|
||||
), array('validate' => 'first'));
|
||||
$this->assertFalse($result);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3761,7 +3762,6 @@ class ModelWriteTest extends BaseModelTest {
|
|||
/**
|
||||
* TestFindAllWithoutForeignKey
|
||||
*
|
||||
* @link http://code.cakephp.org/tickets/view/69
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
|
@ -3826,7 +3826,6 @@ class ModelWriteTest extends BaseModelTest {
|
|||
/**
|
||||
* testProductUpdateAllWithForeignKey
|
||||
*
|
||||
* @link http://code.cakephp.org/tickets/view/69
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
|
@ -3877,7 +3876,6 @@ class ModelWriteTest extends BaseModelTest {
|
|||
/**
|
||||
* testProductUpdateAllWithoutForeignKey
|
||||
*
|
||||
* @link http://code.cakephp.org/tickets/view/69
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
|
|
|
@ -660,7 +660,6 @@ class FolderTest extends CakeTestCase {
|
|||
*
|
||||
* @return void
|
||||
* @access public
|
||||
* @link https://trac.cakephp.org/ticket/6259
|
||||
*/
|
||||
function testCopy() {
|
||||
$path = TMP . 'folder_test';
|
||||
|
@ -719,7 +718,6 @@ class FolderTest extends CakeTestCase {
|
|||
*
|
||||
* @return void
|
||||
* @access public
|
||||
* @link https://trac.cakephp.org/ticket/6259
|
||||
*/
|
||||
function testMove() {
|
||||
$path = TMP . 'folder_test';
|
||||
|
|
|
@ -228,11 +228,12 @@ class InflectorTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
function testInflectorSlugWithMap() {
|
||||
$result = Inflector::slug('replace every r', array('/r/' => '1'));
|
||||
Inflector::rules('transliteration', array('/r/' => '1'));
|
||||
$result = Inflector::slug('replace every r');
|
||||
$expected = '1eplace_eve1y_1';
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$result = Inflector::slug('replace every r', '_', array('/r/' => '1'));
|
||||
$result = Inflector::slug('replace every r', '_');
|
||||
$expected = '1eplace_eve1y_1';
|
||||
$this->assertEqual($result, $expected);
|
||||
}
|
||||
|
@ -244,7 +245,8 @@ class InflectorTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
function testInflectorSlugWithMapOverridingDefault() {
|
||||
$result = Inflector::slug('Testing æ ø å', '-', array('/å/' => 'aa', '/ø/' => 'oe'));
|
||||
Inflector::rules('transliteration', array('/å/' => 'aa', '/ø/' => 'oe'));
|
||||
$result = Inflector::slug('Testing æ ø å', '-');
|
||||
$expected = 'Testing-ae-oe-aa';
|
||||
$this->assertEqual($result, $expected);
|
||||
}
|
||||
|
@ -386,8 +388,6 @@ class InflectorTest extends CakeTestCase {
|
|||
|
||||
Inflector::rules('transliteration', array('/ä|æ/' => 'ae', '/å/' => 'aa'), true);
|
||||
$this->assertEqual(Inflector::slug('Testing æ ø å'), 'Testing_ae_ø_aa');
|
||||
|
||||
$this->assertEqual(Inflector::slug('Testing æ ø å', '-', array('/ø/' => 'oe')), 'Testing-ae-oe-aa');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -3639,6 +3639,42 @@ class FormHelperTest extends CakeTestCase {
|
|||
'label' => false
|
||||
));
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$this->Form->validationErrors['Model']['tags'] = 'Select atleast one option';
|
||||
$result = $this->Form->input('Model.tags', array(
|
||||
'options' => array('one'),
|
||||
'multiple' => 'checkbox',
|
||||
'label' => false,
|
||||
'div' => false
|
||||
));
|
||||
$expected = array(
|
||||
'input' => array('type' => 'hidden', 'name' => 'data[Model][tags]', 'value' => '', 'id' => 'ModelTags'),
|
||||
array('div' => array('class' => 'checkbox form-error')),
|
||||
array('input' => array('type' => 'checkbox', 'name' => 'data[Model][tags][]', 'value' => '0', 'id' => 'ModelTags0')),
|
||||
array('label' => array('for' => 'ModelTags0')),
|
||||
'one',
|
||||
'/label',
|
||||
'/div'
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$result = $this->Form->input('Model.tags', array(
|
||||
'options' => array('one'),
|
||||
'multiple' => 'checkbox',
|
||||
'class' => 'mycheckbox',
|
||||
'label' => false,
|
||||
'div' => false
|
||||
));
|
||||
$expected = array(
|
||||
'input' => array('type' => 'hidden', 'name' => 'data[Model][tags]', 'value' => '', 'id' => 'ModelTags'),
|
||||
array('div' => array('class' => 'mycheckbox form-error')),
|
||||
array('input' => array('type' => 'checkbox', 'name' => 'data[Model][tags][]', 'value' => '0', 'id' => 'ModelTags0')),
|
||||
array('label' => array('for' => 'ModelTags0')),
|
||||
'one',
|
||||
'/label',
|
||||
'/div'
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -5373,6 +5409,14 @@ class FormHelperTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
function testSubmitButton() {
|
||||
$result = $this->Form->submit('');
|
||||
$expected = array(
|
||||
'div' => array('class' => 'submit'),
|
||||
'input' => array('type' => 'submit', 'value' => ''),
|
||||
'/div'
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$result = $this->Form->submit('Test Submit');
|
||||
$expected = array(
|
||||
'div' => array('class' => 'submit'),
|
||||
|
@ -6488,6 +6532,24 @@ class FormHelperTest extends CakeTestCase {
|
|||
function testFormEnd() {
|
||||
$this->assertEqual($this->Form->end(), '</form>');
|
||||
|
||||
$result = $this->Form->end('');
|
||||
$expected = array(
|
||||
'div' => array('class' => 'submit'),
|
||||
'input' => array('type' => 'submit', 'value' => ''),
|
||||
'/div',
|
||||
'/form'
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$result = $this->Form->end(array('label' => ''));
|
||||
$expected = array(
|
||||
'div' => array('class' => 'submit'),
|
||||
'input' => array('type' => 'submit', 'value' => ''),
|
||||
'/div',
|
||||
'/form'
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$result = $this->Form->end('save');
|
||||
$expected = array(
|
||||
'div' => array('class' => 'submit'),
|
||||
|
|
|
@ -369,7 +369,6 @@ class HtmlHelperTest extends CakeTestCase {
|
|||
*
|
||||
* @access public
|
||||
* @return void
|
||||
* @link https://trac.cakephp.org/ticket/6490
|
||||
*/
|
||||
function testImageTagWithTheme() {
|
||||
if ($this->skipIf(!is_writable(WWW_ROOT . 'theme'), 'Cannot write to webroot/theme')) {
|
||||
|
|
|
@ -487,7 +487,7 @@ class JsHelperTest extends CakeTestCase {
|
|||
function testSubmitWithMock() {
|
||||
$this->_useMock();
|
||||
|
||||
$options = array('update' => '#content', 'id' => 'test-submit');
|
||||
$options = array('update' => '#content', 'id' => 'test-submit', 'style' => 'margin: 0');
|
||||
|
||||
$this->Js->TestJsEngine->expects($this->at(0))
|
||||
->method('get');
|
||||
|
@ -512,7 +512,7 @@ class JsHelperTest extends CakeTestCase {
|
|||
$result = $this->Js->submit('Save', $options);
|
||||
$expected = array(
|
||||
'div' => array('class' => 'submit'),
|
||||
'input' => array('type' => 'submit', 'id' => $options['id'], 'value' => 'Save'),
|
||||
'input' => array('type' => 'submit', 'id' => $options['id'], 'value' => 'Save', 'style' => 'margin: 0'),
|
||||
'/div'
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
|
|
@ -952,4 +952,30 @@ class ViewTest extends CakeTestCase {
|
|||
$View->render('this_is_missing');
|
||||
$result = str_replace(array("\t", "\r\n", "\n"), "", ob_get_clean());
|
||||
}
|
||||
|
||||
/**
|
||||
* testAltExt method
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function testAltExt() {
|
||||
$this->PostsController->ext = '.alt';
|
||||
$View = new TestView($this->PostsController);
|
||||
$result = $View->render('alt_ext', false);
|
||||
$this->assertEqual($result, 'alt ext');
|
||||
}
|
||||
|
||||
/**
|
||||
* testAltBadExt method
|
||||
*
|
||||
* @expectedException MissingViewException
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function testAltBadExt() {
|
||||
$View = new TestView($this->PostsController);
|
||||
$View->render('alt_ext');
|
||||
$result = str_replace(array("\t", "\r\n", "\n"), "", ob_get_clean());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue