From d70900c54007d8b5bb6c3138df2328715b3c5cc7 Mon Sep 17 00:00:00 2001
From: jperras
Date: Thu, 23 Jul 2009 16:51:25 -0400
Subject: [PATCH 01/31] Making basics.test.php testDebug more symlink friendly.
Adding deprecated tag to global 'uses' method
---
cake/basics.php | 1 +
cake/tests/cases/basics.test.php | 8 ++++----
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/cake/basics.php b/cake/basics.php
index 1c1dd61d1..f1129c949 100644
--- a/cake/basics.php
+++ b/cake/basics.php
@@ -84,6 +84,7 @@ if (!function_exists('clone')) {
*
*
* @param string $name Filename without the .php part
+ * @deprecated
*/
function uses() {
$args = func_get_args();
diff --git a/cake/tests/cases/basics.test.php b/cake/tests/cases/basics.test.php
index c7ec6a803..eaa0d4313 100644
--- a/cake/tests/cases/basics.test.php
+++ b/cake/tests/cases/basics.test.php
@@ -111,10 +111,10 @@ class BasicsTest extends CakeTestCase {
$_SERVER['HTTPS'] = 'off';
$this->assertFalse(env('HTTPS'));
-
+
$_SERVER['HTTPS'] = false;
$this->assertFalse(env('HTTPS'));
-
+
$_SERVER['HTTPS'] = '';
$this->assertFalse(env('HTTPS'));
@@ -564,7 +564,7 @@ class BasicsTest extends CakeTestCase {
ob_start();
debug('this-is-a-test');
$result = ob_get_clean();
- $pattern = '/.*\>(cake(\/|\\\)tests(\/|\\\)cases(\/|\\\)basics\.test\.php|';
+ $pattern = '/.*\>(.+?cake(\/|\\\)tests(\/|\\\)cases(\/|\\\)basics\.test\.php|';
$pattern .= preg_quote(substr(__FILE__, 1), '/') . ')';
$pattern .= '.*line.*' . (__LINE__ - 4) . '.*this-is-a-test.*/s';
$this->assertPattern($pattern, $result);
@@ -572,7 +572,7 @@ class BasicsTest extends CakeTestCase {
ob_start();
debug('this-is-a-test
', true);
$result = ob_get_clean();
- $pattern = '/.*\>(cake(\/|\\\)tests(\/|\\\)cases(\/|\\\)basics\.test\.php|';
+ $pattern = '/.*\>(.+?cake(\/|\\\)tests(\/|\\\)cases(\/|\\\)basics\.test\.php|';
$pattern .= preg_quote(substr(__FILE__, 1), '/') . ')';
$pattern .= '.*line.*' . (__LINE__ - 4) . '.*<div>this-is-a-test<\/div>.*/s';
$this->assertPattern($pattern, $result);
From e40428801ef3bbf005d753855b60aa3c683f7f21 Mon Sep 17 00:00:00 2001
From: jperras
Date: Thu, 23 Jul 2009 16:53:37 -0400
Subject: [PATCH 02/31] Removing all uses of uses() global method & replacing
with require or App::import.
---
cake/console/libs/shell.php | 2 +-
cake/console/libs/tasks/project.php | 2 +-
cake/console/libs/templates/default/views/home.ctp | 6 ++++--
cake/console/libs/templates/skel/webroot/css.php | 2 +-
cake/libs/controller/components/acl.php | 2 +-
cake/libs/file.php | 2 +-
cake/libs/folder.php | 2 +-
cake/libs/magic_db.php | 5 ++++-
cake/libs/model/behaviors/acl.php | 2 +-
cake/libs/object.php | 2 +-
cake/libs/view/pages/home.ctp | 4 +++-
cake/tests/cases/basics.test.php | 1 +
cake/tests/cases/libs/magic_db.test.php | 4 +++-
cake/tests/cases/libs/set.test.php | 1 -
cake/tests/cases/libs/view/helpers/ajax.test.php | 11 +----------
cake/tests/cases/libs/view/helpers/js.test.php | 7 -------
cake/tests/test_app/views/pages/home.ctp | 6 ++++--
cake/tests/test_app/views/posts/test_nocache_tags.ctp | 4 +++-
18 files changed, 31 insertions(+), 34 deletions(-)
diff --git a/cake/console/libs/shell.php b/cake/console/libs/shell.php
index 9c22a8468..cb0725dce 100644
--- a/cake/console/libs/shell.php
+++ b/cake/console/libs/shell.php
@@ -436,7 +436,7 @@ class Shell extends Object {
}
}
if (!class_exists('File')) {
- uses('file');
+ require LIBS . 'file.php';
}
if ($File = new File($path, true)) {
diff --git a/cake/console/libs/tasks/project.php b/cake/console/libs/tasks/project.php
index fda6a7cf7..af65dea87 100644
--- a/cake/console/libs/tasks/project.php
+++ b/cake/console/libs/tasks/project.php
@@ -194,7 +194,7 @@ class ProjectTask extends Shell {
$contents = $File->read();
if (preg_match('/([\\t\\x20]*Configure::write\\(\\\'Security.salt\\\',[\\t\\x20\'A-z0-9]*\\);)/', $contents, $match)) {
if (!class_exists('Security')) {
- uses('Security');
+ require LIBS . 'security.php';
}
$string = Security::generateAuthKey();
$result = str_replace($match[0], "\t" . 'Configure::write(\'Security.salt\', \''.$string.'\');', $contents);
diff --git a/cake/console/libs/templates/default/views/home.ctp b/cake/console/libs/templates/default/views/home.ctp
index 39020d488..edc233853 100644
--- a/cake/console/libs/templates/default/views/home.ctp
+++ b/cake/console/libs/templates/default/views/home.ctp
@@ -52,7 +52,9 @@ endif;
getDataSource('default');
?>
@@ -79,4 +81,4 @@ $output .= "\t\tYou can also add some CSS styles for your pages at: %s', true),\
$output .= "\t\tAPP . 'views' . DS . 'pages' . DS . 'home.ctp.
', APP . 'views' . DS . 'layouts' . DS . 'default.ctp.
', APP . 'webroot' . DS . 'css');\n";
$output .= "?>\n";
$output .= "\n";
-?>
+?>
\ No newline at end of file
diff --git a/cake/console/libs/templates/skel/webroot/css.php b/cake/console/libs/templates/skel/webroot/css.php
index 52b57fee7..f87842179 100644
--- a/cake/console/libs/templates/skel/webroot/css.php
+++ b/cake/console/libs/templates/skel/webroot/css.php
@@ -32,7 +32,7 @@ if (!defined('CAKE_CORE_INCLUDE_PATH')) {
* Enter description here...
*/
if (!class_exists('File')) {
- uses('file');
+ require LIBS . 'file.php';
}
/**
* Enter description here...
diff --git a/cake/libs/controller/components/acl.php b/cake/libs/controller/components/acl.php
index d68c61f03..9650786de 100644
--- a/cake/libs/controller/components/acl.php
+++ b/cake/libs/controller/components/acl.php
@@ -201,7 +201,7 @@ class DbAcl extends AclBase {
function __construct() {
parent::__construct();
if (!class_exists('AclNode')) {
- uses('model' . DS . 'db_acl');
+ require LIBS . 'model' . DS . 'db_acl.php';
}
$this->Aro =& ClassRegistry::init(array('class' => 'Aro', 'alias' => 'Aro'));
$this->Aco =& ClassRegistry::init(array('class' => 'Aco', 'alias' => 'Aco'));
diff --git a/cake/libs/file.php b/cake/libs/file.php
index b57cb4c72..0971d83a5 100644
--- a/cake/libs/file.php
+++ b/cake/libs/file.php
@@ -27,7 +27,7 @@
*
*/
if (!class_exists('Object')) {
- uses('object');
+ require LIBS . 'object.php';
}
if (!class_exists('Folder')) {
require LIBS . 'folder.php';
diff --git a/cake/libs/folder.php b/cake/libs/folder.php
index 28f32672a..7deb0fa32 100644
--- a/cake/libs/folder.php
+++ b/cake/libs/folder.php
@@ -27,7 +27,7 @@
*
*/
if (!class_exists('Object')) {
- uses('object');
+ require LIBS . 'object.php';
}
/**
* Folder structure browser, lists folders and files.
diff --git a/cake/libs/magic_db.php b/cake/libs/magic_db.php
index 73b16017c..08d50fe0c 100644
--- a/cake/libs/magic_db.php
+++ b/cake/libs/magic_db.php
@@ -22,8 +22,11 @@
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
+if (!class_exists('Object')) {
+ require LIBS . 'object.php';
+}
if (!class_exists('File')) {
- uses('object', 'file');
+ require LIBS . 'file.php';
}
/**
* A class to parse and use the MagicDb for file type analysis
diff --git a/cake/libs/model/behaviors/acl.php b/cake/libs/model/behaviors/acl.php
index 0b867a2ca..91ed1c655 100644
--- a/cake/libs/model/behaviors/acl.php
+++ b/cake/libs/model/behaviors/acl.php
@@ -55,7 +55,7 @@ class AclBehavior extends ModelBehavior {
$type = $this->__typeMaps[$this->settings[$model->name]['type']];
if (!class_exists('AclNode')) {
- uses('model' . DS . 'db_acl');
+ require LIBS . 'model' . DS . 'db_acl.php';
}
$model->{$type} =& ClassRegistry::init($type);
if (!method_exists($model, 'parentNode')) {
diff --git a/cake/libs/object.php b/cake/libs/object.php
index 358fd759f..4276a49f1 100644
--- a/cake/libs/object.php
+++ b/cake/libs/object.php
@@ -148,7 +148,7 @@ class Object {
*/
function log($msg, $type = LOG_ERROR) {
if (!class_exists('CakeLog')) {
- uses('cake_log');
+ require LIBS . 'cake_log.php';
}
if (is_null($this->_log)) {
$this->_log = new CakeLog();
diff --git a/cake/libs/view/pages/home.ctp b/cake/libs/view/pages/home.ctp
index f0e3d9c63..8b0fe2cda 100644
--- a/cake/libs/view/pages/home.ctp
+++ b/cake/libs/view/pages/home.ctp
@@ -78,7 +78,9 @@ endif;
getDataSource('default');
?>
diff --git a/cake/tests/cases/basics.test.php b/cake/tests/cases/basics.test.php
index eaa0d4313..2b27d7b6d 100644
--- a/cake/tests/cases/basics.test.php
+++ b/cake/tests/cases/basics.test.php
@@ -147,6 +147,7 @@ class BasicsTest extends CakeTestCase {
*
* @access public
* @return void
+ * @deprecated
*/
function testUses() {
$this->skipIf(class_exists('Security') || class_exists('Sanitize'), '%s Security and/or Sanitize class already loaded');
diff --git a/cake/tests/cases/libs/magic_db.test.php b/cake/tests/cases/libs/magic_db.test.php
index 3eba7eb46..076859d4a 100644
--- a/cake/tests/cases/libs/magic_db.test.php
+++ b/cake/tests/cases/libs/magic_db.test.php
@@ -22,7 +22,9 @@
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
-uses('magic_db', 'object');
+if (!class_exists('MagicDb')) {
+ require LIBS . 'magic_db.php';
+}
/**
* The test class for the MagicDb class
*
diff --git a/cake/tests/cases/libs/set.test.php b/cake/tests/cases/libs/set.test.php
index d0b7c10f9..2e657e5fb 100644
--- a/cake/tests/cases/libs/set.test.php
+++ b/cake/tests/cases/libs/set.test.php
@@ -1755,7 +1755,6 @@ class SetTest extends CakeTestCase {
$result = Set::reverse($class);
$this->assertIdentical($result, $expected);
- uses('model'.DS.'model');
$model = new Model(array('id' => false, 'name' => 'Model', 'table' => false));
$expected = array(
'Behaviors' => array('modelName' => 'Model', '_attached' => array(), '_disabled' => array(), '__methods' => array(), '__mappedMethods' => array(), '_log' => null),
diff --git a/cake/tests/cases/libs/view/helpers/ajax.test.php b/cake/tests/cases/libs/view/helpers/ajax.test.php
index 439846e0d..233d1fa00 100644
--- a/cake/tests/cases/libs/view/helpers/ajax.test.php
+++ b/cake/tests/cases/libs/view/helpers/ajax.test.php
@@ -27,16 +27,7 @@
if (!defined('CAKEPHP_UNIT_TEST_EXECUTION')) {
define('CAKEPHP_UNIT_TEST_EXECUTION', 1);
}
-uses(
- 'view' . DS . 'helpers' . DS . 'app_helper',
- 'controller' . DS . 'controller',
- 'model' . DS . 'model',
- 'view' . DS . 'helper',
- 'view' . DS . 'helpers'.DS.'ajax',
- 'view' . DS . 'helpers' . DS . 'html',
- 'view' . DS . 'helpers' . DS . 'form',
- 'view' . DS . 'helpers' . DS . 'javascript'
- );
+App::import('Helper', array('Html', 'Form', 'Javascript', 'Ajax'));
/**
* AjaxTestController class
*
diff --git a/cake/tests/cases/libs/view/helpers/js.test.php b/cake/tests/cases/libs/view/helpers/js.test.php
index d0307089b..d227b02a7 100644
--- a/cake/tests/cases/libs/view/helpers/js.test.php
+++ b/cake/tests/cases/libs/view/helpers/js.test.php
@@ -27,13 +27,6 @@
if (!defined('CAKEPHP_UNIT_TEST_EXECUTION')) {
define('CAKEPHP_UNIT_TEST_EXECUTION', 1);
}
-uses(
- 'view' . DS . 'helpers' . DS . 'app_helper',
- 'controller' . DS . 'controller',
- 'model' . DS . 'model',
- 'view' . DS . 'helper',
- 'view' . DS . 'helpers' . DS . 'js'
- );
/**
* JsHelperTest class
*
diff --git a/cake/tests/test_app/views/pages/home.ctp b/cake/tests/test_app/views/pages/home.ctp
index 3812f0f93..b9b6f00ed 100644
--- a/cake/tests/test_app/views/pages/home.ctp
+++ b/cake/tests/test_app/views/pages/home.ctp
@@ -51,7 +51,9 @@ endif;
getDataSource('default');
?>
@@ -77,4 +79,4 @@ if (!empty($filePresent)):
You can also add some CSS styles for your pages at: %s', true),
APP . 'views' . DS . 'pages' . DS . 'home.ctp.
', APP . 'views' . DS . 'layouts' . DS . 'default.ctp.
', APP . 'webroot' . DS . 'css');
?>
-
+
\ No newline at end of file
diff --git a/cake/tests/test_app/views/posts/test_nocache_tags.ctp b/cake/tests/test_app/views/posts/test_nocache_tags.ctp
index db0e7397c..7e4ff8e89 100644
--- a/cake/tests/test_app/views/posts/test_nocache_tags.ctp
+++ b/cake/tests/test_app/views/posts/test_nocache_tags.ctp
@@ -81,7 +81,9 @@
getDataSource('default');
?>
From f64f4cbddc8a4edd4bac50044ea18bb6687b6069 Mon Sep 17 00:00:00 2001
From: AD7six
Date: Sun, 26 Jul 2009 11:59:51 +0200
Subject: [PATCH 03/31] whitespace normalization
---
cake/tests/cases/console/cake.test.php | 15 +----
.../console/libs/tasks/db_config.test.php | 10 ++-
.../cases/console/libs/tasks/fixture.test.php | 17 ++++-
.../cases/console/libs/tasks/test.test.php | 31 ++++++++--
.../controller/components/cookie.test.php | 1 +
.../cases/libs/model/model_delete.test.php | 12 +++-
.../libs/model/model_integration.test.php | 25 ++++++++
.../cases/libs/model/model_read.test.php | 44 ++++++++++---
.../libs/model/model_validation.test.php | 4 ++
.../cases/libs/model/model_write.test.php | 62 +++++++++++++++++--
cake/tests/lib/cake_test_fixture.php | 2 +
.../test_app/views/layouts/cache_layout.ctp | 3 +-
.../views/layouts/email/text/default.ctp | 2 +-
13 files changed, 187 insertions(+), 41 deletions(-)
diff --git a/cake/tests/cases/console/cake.test.php b/cake/tests/cases/console/cake.test.php
index 2baede3a8..a7eecf63b 100644
--- a/cake/tests/cases/console/cake.test.php
+++ b/cake/tests/cases/console/cake.test.php
@@ -116,7 +116,7 @@ class TestShellDispatcher extends ShellDispatcher {
* @return void
*/
function clear() {
-
+
}
/**
@@ -192,7 +192,6 @@ class ShellDispatcherTest extends UnitTestCase {
$Dispatcher->parseParams($params);
$this->assertEqual($expected, $Dispatcher->params);
-
$params = array('cake.php');
$expected = array(
'app' => 'app',
@@ -204,7 +203,6 @@ class ShellDispatcherTest extends UnitTestCase {
$Dispatcher->parseParams($params);
$this->assertEqual($expected, $Dispatcher->params);
-
$params = array(
'cake.php',
'-app',
@@ -220,7 +218,6 @@ class ShellDispatcherTest extends UnitTestCase {
$Dispatcher->parseParams($params);
$this->assertEqual($expected, $Dispatcher->params);
-
$params = array(
'./cake.php',
'bake',
@@ -241,7 +238,6 @@ class ShellDispatcherTest extends UnitTestCase {
$Dispatcher->parseParams($params);
$this->assertEqual($expected, $Dispatcher->params);
-
$params = array(
'./console/cake.php',
'bake',
@@ -260,7 +256,6 @@ class ShellDispatcherTest extends UnitTestCase {
$Dispatcher->parseParams($params);
$this->assertEqual($expected, $Dispatcher->params);
-
$params = array(
'./console/cake.php',
'bake',
@@ -281,7 +276,6 @@ class ShellDispatcherTest extends UnitTestCase {
$Dispatcher->parseParams($params);
$this->assertEqual($expected, $Dispatcher->params);
-
$params = array(
'./console/cake.php',
'-working',
@@ -307,11 +301,9 @@ class ShellDispatcherTest extends UnitTestCase {
$Dispatcher->parseParams($params);
$this->assertEqual($expected, $Dispatcher->params);
-
$expected = array('./console/cake.php', 'schema', 'run', 'create');
$this->assertEqual($expected, $Dispatcher->args);
-
$params = array(
'/cake/1.2.x.x/cake/console/cake.php',
'-working',
@@ -335,7 +327,6 @@ class ShellDispatcherTest extends UnitTestCase {
$Dispatcher->parseParams($params);
$this->assertEqual($expected, $Dispatcher->params);
-
$expected = array('/cake/1.2.x.x/cake/console/cake.php', 'schema', 'run', 'create');
$this->assertEqual($expected, $Dispatcher->args);
$params = array(
@@ -353,12 +344,10 @@ class ShellDispatcherTest extends UnitTestCase {
'root' => 'C:\wamp\www\apps\cake'
);
-
$Dispatcher->params = $Dispatcher->args = array();
$Dispatcher->parseParams($params);
$this->assertEqual($expected, $Dispatcher->params);
-
$params = array(
'cake.php',
'-working',
@@ -377,7 +366,6 @@ class ShellDispatcherTest extends UnitTestCase {
$Dispatcher->parseParams($params);
$this->assertEqual($expected, $Dispatcher->params);
-
$params = array(
'cake.php',
'-working',
@@ -399,7 +387,6 @@ class ShellDispatcherTest extends UnitTestCase {
$Dispatcher->parseParams($params);
$this->assertEqual($expected, $Dispatcher->params);
-
$params = array(
'/home/amelo/dev/cake-common/cake/console/cake.php',
'-root',
diff --git a/cake/tests/cases/console/libs/tasks/db_config.test.php b/cake/tests/cases/console/libs/tasks/db_config.test.php
index 4b510a523..fee7ad0a9 100644
--- a/cake/tests/cases/console/libs/tasks/db_config.test.php
+++ b/cake/tests/cases/console/libs/tasks/db_config.test.php
@@ -33,7 +33,6 @@ if (!class_exists('ShellDispatcher')) {
require_once CAKE . 'console' . DS . 'libs' . DS . 'tasks' . DS . 'db_config.php';
//require_once CAKE . 'console' . DS . 'libs' . DS . 'tasks' . DS . 'template.php';
-
Mock::generatePartial(
'ShellDispatcher', 'TestDbConfigTaskMockShellDispatcher',
array('getInput', 'stdout', 'stderr', '_stop', '_initEnvironment')
@@ -54,7 +53,7 @@ class TEST_DATABASE_CONFIG {
'database' => 'database_name',
'prefix' => '',
);
-
+
var $otherOne = array(
'driver' => 'mysql',
'persistent' => false,
@@ -73,6 +72,7 @@ class TEST_DATABASE_CONFIG {
* @subpackage cake.tests.cases.console.libs.tasks
*/
class DbConfigTaskTest extends CakeTestCase {
+
/**
* startTest method
*
@@ -88,6 +88,7 @@ class DbConfigTaskTest extends CakeTestCase {
$this->Task->params['working'] = rtrim(APP, '/');
$this->Task->databaseClassName = 'TEST_DATABASE_CONFIG';
}
+
/**
* endTest method
*
@@ -98,6 +99,7 @@ class DbConfigTaskTest extends CakeTestCase {
unset($this->Task, $this->Dispatcher);
ClassRegistry::flush();
}
+
/**
* Test the getConfig method.
*
@@ -108,6 +110,7 @@ class DbConfigTaskTest extends CakeTestCase {
$result = $this->Task->getConfig();
$this->assertEqual($result, 'otherOne');
}
+
/**
* test that initialize sets the path up.
*
@@ -118,8 +121,9 @@ class DbConfigTaskTest extends CakeTestCase {
$this->Task->initialize();
$this->assertFalse(empty($this->Task->path));
$this->assertEqual($this->Task->path, APP . 'config' . DS);
-
+
}
+
/**
* test execute and by extension __interactive
*
diff --git a/cake/tests/cases/console/libs/tasks/fixture.test.php b/cake/tests/cases/console/libs/tasks/fixture.test.php
index 359dd4760..b4180ac23 100644
--- a/cake/tests/cases/console/libs/tasks/fixture.test.php
+++ b/cake/tests/cases/console/libs/tasks/fixture.test.php
@@ -47,6 +47,7 @@ Mock::generatePartial(
'Shell', 'MockFixtureModelTask',
array('in', 'out', 'err', 'createFile', '_stop', 'getName', 'getTable', 'listAll')
);
+
/**
* FixtureTaskTest class
*
@@ -54,12 +55,14 @@ Mock::generatePartial(
* @subpackage cake.tests.cases.console.libs.tasks
*/
class FixtureTaskTest extends CakeTestCase {
+
/**
* fixtures
*
* @var array
**/
var $fixtures = array('core.article', 'core.comment');
+
/**
* startTest method
*
@@ -75,6 +78,7 @@ class FixtureTaskTest extends CakeTestCase {
$this->Task->Dispatch->shellPaths = App::path('shells');
$this->Task->Template->initialize();
}
+
/**
* endTest method
*
@@ -85,6 +89,7 @@ class FixtureTaskTest extends CakeTestCase {
unset($this->Task, $this->Dispatcher);
ClassRegistry::flush();
}
+
/**
* test that initialize sets the path
*
@@ -97,6 +102,7 @@ class FixtureTaskTest extends CakeTestCase {
$expected = '/my/path/tests/fixtures/';
$this->assertEqual($Task->path, $expected);
}
+
/**
* test import option array generation
*
@@ -117,7 +123,7 @@ class FixtureTaskTest extends CakeTestCase {
$result = $this->Task->importOptions('Article');
$expected = array();
$this->assertEqual($result, $expected);
-
+
$this->Task->setReturnValueAt(5, 'in', 'n');
$this->Task->setReturnValueAt(6, 'in', 'n');
$this->Task->setReturnValueAt(7, 'in', 'y');
@@ -125,6 +131,7 @@ class FixtureTaskTest extends CakeTestCase {
$expected = array('fromTable' => true);
$this->assertEqual($result, $expected);
}
+
/**
* test generating a fixture with database conditions.
*
@@ -143,6 +150,7 @@ class FixtureTaskTest extends CakeTestCase {
$this->assertPattern('/Second Article/', $result, 'Missing import data %s');
$this->assertPattern('/Third Article/', $result, 'Missing import data %s');
}
+
/**
* test that execute passes runs bake depending with named model.
*
@@ -156,6 +164,7 @@ class FixtureTaskTest extends CakeTestCase {
$this->Task->expectAt(0, 'createFile', array($filename, new PatternExpectation('/class ArticleFixture/')));
$this->Task->execute();
}
+
/**
* test that execute runs all() when args[0] = all
*
@@ -175,6 +184,7 @@ class FixtureTaskTest extends CakeTestCase {
$this->Task->expectAt(1, 'createFile', array($filename, new PatternExpectation('/class CommentFixture/')));
$this->Task->execute();
}
+
/**
* test interactive mode of execute
*
@@ -183,7 +193,7 @@ class FixtureTaskTest extends CakeTestCase {
function testExecuteInteractive() {
$this->Task->connection = 'test_suite';
$this->Task->path = '/my/path/';
-
+
$this->Task->setReturnValue('in', 'y');
$this->Task->Model->setReturnValue('getName', 'Article');
$this->Task->Model->setReturnValue('getTable', 'articles', array('Article'));
@@ -192,6 +202,7 @@ class FixtureTaskTest extends CakeTestCase {
$this->Task->expectAt(0, 'createFile', array($filename, new PatternExpectation('/class ArticleFixture/')));
$this->Task->execute();
}
+
/**
* Test that bake works
*
@@ -225,6 +236,7 @@ class FixtureTaskTest extends CakeTestCase {
$this->assertNoPattern('/var \$fields/', $result);
$this->assertNoPattern('/var \$records/', $result);
}
+
/**
* Test that file generation includes headers and correct path for plugins.
*
@@ -241,6 +253,7 @@ class FixtureTaskTest extends CakeTestCase {
$this->Task->expectAt(1, 'createFile', array($filename, new PatternExpectation('/\<\?php(.*)\?\>/ms')));
$result = $this->Task->generateFixtureFile('Article', array());
}
+
/**
* test generating files into plugins.
*
diff --git a/cake/tests/cases/console/libs/tasks/test.test.php b/cake/tests/cases/console/libs/tasks/test.test.php
index 0283c5f70..8fd91fcc5 100644
--- a/cake/tests/cases/console/libs/tasks/test.test.php
+++ b/cake/tests/cases/console/libs/tasks/test.test.php
@@ -1,5 +1,6 @@
Task->Dispatch =& $this->Dispatcher;
$this->Task->Template =& new TemplateTask($this->Dispatcher);
}
+
/**
* endTest method
*
@@ -145,13 +149,14 @@ class TestTaskTest extends CakeTestCase {
function endTest() {
ClassRegistry::flush();
}
+
/**
* Test that file path generation doesn't continuously append paths.
*
* @access public
* @return void
*/
- function testFilePathGeneration () {
+ function testFilePathGeneration() {
$file = TESTS . 'cases' . DS . 'models' . DS . 'my_class.test.php';
$this->Task->Dispatch->expectNever('stderr');
@@ -168,8 +173,9 @@ class TestTaskTest extends CakeTestCase {
$this->Task->expectAt(2, 'createFile', array($file, '*'));
$this->Task->bake('Controller', 'Comments');
}
+
/**
- * Test that method introspection pulls all relevant non parent class
+ * Test that method introspection pulls all relevant non parent class
* methods into the test case.
*
* @return void
@@ -179,6 +185,7 @@ class TestTaskTest extends CakeTestCase {
$expected = array('doSomething', 'doSomethingElse');
$this->assertEqual($result, $expected);
}
+
/**
* test that the generation of fixtures works correctly.
*
@@ -187,11 +194,12 @@ class TestTaskTest extends CakeTestCase {
function testFixtureArrayGenerationFromModel() {
$subject = ClassRegistry::init('TestTaskArticle');
$result = $this->Task->generateFixtureList($subject);
- $expected = array('plugin.test_task.test_task_comment', 'app.articles_tags',
+ $expected = array('plugin.test_task.test_task_comment', 'app.articles_tags',
'app.test_task_article', 'app.test_task_tag');
$this->assertEqual(sort($result), sort($expected));
}
+
/**
* test that the generation of fixtures works correctly.
*
@@ -200,11 +208,12 @@ class TestTaskTest extends CakeTestCase {
function testFixtureArrayGenerationFromController() {
$subject = new TestTaskCommentsController();
$result = $this->Task->generateFixtureList($subject);
- $expected = array('plugin.test_task.test_task_comment', 'app.articles_tags',
+ $expected = array('plugin.test_task.test_task_comment', 'app.articles_tags',
'app.test_task_article', 'app.test_task_tag');
$this->assertEqual(sort($result), sort($expected));
}
+
/**
* test user interaction to get object type
*
@@ -219,6 +228,7 @@ class TestTaskTest extends CakeTestCase {
$result = $this->Task->getObjectType();
$this->assertEqual($result, $this->Task->classTypes[1]);
}
+
/**
* creating test subjects should clear the registry so the registry is always fresh
*
@@ -242,6 +252,7 @@ class TestTaskTest extends CakeTestCase {
$keys = ClassRegistry::keys();
$this->assertFalse(in_array('random', $keys));
}
+
/**
* test that getClassName returns the user choice as a classname.
*
@@ -262,6 +273,7 @@ class TestTaskTest extends CakeTestCase {
$options = Configure::listObjects('model');
$this->assertEqual($result, $options[0]);
}
+
/**
* Test the user interaction for defining additional fixtures.
*
@@ -274,6 +286,7 @@ class TestTaskTest extends CakeTestCase {
$expected = array('app.pizza', 'app.topping', 'app.side_dish');
$this->assertEqual($result, $expected);
}
+
/**
* test that resolving classnames works
*
@@ -295,6 +308,7 @@ class TestTaskTest extends CakeTestCase {
$result = $this->Task->getRealClassname('Component', 'Auth');
$this->assertEqual($result, 'AuthComponent');
}
+
/**
* test baking files.
*
@@ -323,6 +337,7 @@ class TestTaskTest extends CakeTestCase {
$this->assertPattern("/'app\.test_task_tag'/", $result);
$this->assertPattern("/'app\.articles_tag'/", $result);
}
+
/**
* test baking controller test files, ensure that the stub class is generated.
*
@@ -352,6 +367,7 @@ class TestTaskTest extends CakeTestCase {
$this->assertPattern("/'app\.test_task_tag'/", $result);
$this->assertPattern("/'app\.articles_tag'/", $result);
}
+
/**
* test Constructor generation ensure that constructClasses is called for controllers
*
@@ -370,6 +386,7 @@ class TestTaskTest extends CakeTestCase {
$expected = "new FormHelper()\n";
$this->assertEqual($result, $expected);
}
+
/**
* Test that mock class generation works for the appropriate classes
*
@@ -379,6 +396,7 @@ class TestTaskTest extends CakeTestCase {
$result = $this->Task->hasMockClass('controller');
$this->assertTrue($result);
}
+
/**
* test bake() with a -plugin param
*
@@ -391,6 +409,7 @@ class TestTaskTest extends CakeTestCase {
$this->Task->expectAt(0, 'createFile', array($path, '*'));
$this->Task->bake('Helper', 'Form');
}
+
/**
* Test filename generation for each type + plugins
*
@@ -424,6 +443,7 @@ class TestTaskTest extends CakeTestCase {
$expected = APP . 'plugins' . DS . 'test_test' . DS . 'tests' . DS . 'cases' . DS . 'models' . DS . 'post.test.php';
$this->assertEqual($result, $expected);
}
+
/**
* test execute with a type defined
*
@@ -436,6 +456,7 @@ class TestTaskTest extends CakeTestCase {
$this->Task->expectAt(0, 'createFile', array('*', new PatternExpectation('/class TestTaskTagTestCase extends CakeTestCase/')));
$this->Task->execute();
}
+
/**
* test execute with type and class name defined
*
diff --git a/cake/tests/cases/libs/controller/components/cookie.test.php b/cake/tests/cases/libs/controller/components/cookie.test.php
index 778444e92..804fdda12 100644
--- a/cake/tests/cases/libs/controller/components/cookie.test.php
+++ b/cake/tests/cases/libs/controller/components/cookie.test.php
@@ -27,6 +27,7 @@
*/
App::import('Controller', array('Component', 'Controller'), false);
App::import('Component', 'Cookie');
+
/**
* CookieComponentTestController class
*
diff --git a/cake/tests/cases/libs/model/model_delete.test.php b/cake/tests/cases/libs/model/model_delete.test.php
index 6d30d2bdf..6293014b6 100644
--- a/cake/tests/cases/libs/model/model_delete.test.php
+++ b/cake/tests/cases/libs/model/model_delete.test.php
@@ -1,5 +1,6 @@
assertFalse($result);
}
+
/**
* testDeleteArticleBLinks method
*
@@ -151,6 +155,7 @@ class ModelDeleteTest extends BaseModelTest {
);
$this->assertEqual($result, $expected);
}
+
/**
* testDeleteDependentWithConditions method
*
@@ -179,6 +184,7 @@ class ModelDeleteTest extends BaseModelTest {
$this->assertTrue(is_array($result));
$this->assertEqual($result, $expected);
}
+
/**
* testDel method
*
@@ -228,7 +234,6 @@ class ModelDeleteTest extends BaseModelTest {
$this->assertEqual($result, $expected);
-
// make sure deleting a non-existent record doesn't break save()
// ticket #6293
$this->loadFixtures('Uuid');
@@ -258,6 +263,7 @@ class ModelDeleteTest extends BaseModelTest {
'id' => 'B607DAB9-88A2-46CF-B57C-842CA9E3B3B3')));
$this->assertEqual($result, $expected);
}
+
/**
* testDeleteAll method
*
@@ -399,6 +405,7 @@ class ModelDeleteTest extends BaseModelTest {
$result = $TestModel->deleteAll(array('Article.user_id' => 999));
$this->assertTrue($result, 'deleteAll returned false when all no records matched conditions. %s');
}
+
/**
* testRecursiveDel method
*
@@ -434,6 +441,7 @@ class ModelDeleteTest extends BaseModelTest {
$result = $TestModel->Comment->Attachment->find('count');
$this->assertEqual($result, 0);
}
+
/**
* testDependentExclusiveDelete method
*
@@ -452,6 +460,7 @@ class ModelDeleteTest extends BaseModelTest {
$TestModel->delete(1);
$this->assertEqual($TestModel->Comment->find('count'), 2);
}
+
/**
* testDeleteLinks method
*
@@ -499,6 +508,7 @@ class ModelDeleteTest extends BaseModelTest {
$result = $TestModel->deleteAll(array('Article.user_id' => 999));
$this->assertTrue($result, 'deleteAll returned false when all no records matched conditions. %s');
}
+
/**
* testHabtmDeleteLinksWhenNoPrimaryKeyInJoinTable method
*
diff --git a/cake/tests/cases/libs/model/model_integration.test.php b/cake/tests/cases/libs/model/model_integration.test.php
index e213187b6..dda5578f1 100644
--- a/cake/tests/cases/libs/model/model_integration.test.php
+++ b/cake/tests/cases/libs/model/model_integration.test.php
@@ -1,5 +1,6 @@
assertEqual($TestModel2->ArticlesTag->primaryKey, 'article_id');
}
+
/**
* Tests that $cacheSources can only be disabled in the db using model settings, not enabled
*
@@ -64,6 +67,7 @@ class ModelIntegrationTest extends BaseModelTest {
$TestModel->setSource('join_as');
$this->assertFalse($this->db->cacheSources);
}
+
/**
* testPkInHabtmLinkModel method
*
@@ -92,6 +96,7 @@ class ModelIntegrationTest extends BaseModelTest {
$this->assertEqual($TestModel4->JoinAsJoinB->primaryKey, 'id');
}
+
/**
* testDynamicBehaviorAttachment method
*
@@ -128,6 +133,7 @@ class ModelIntegrationTest extends BaseModelTest {
$this->assertEqual($TestModel->Behaviors->attached(), array());
$this->assertFalse(isset($TestModel->Behaviors->Tree));
}
+
/**
* Tests cross database joins. Requires $test and $test2 to both be set in DATABASE_CONFIG
* NOTE: When testing on MySQL, you must set 'persistent' => false on *both* database connections,
@@ -490,6 +496,7 @@ class ModelIntegrationTest extends BaseModelTest {
$this->_fixtures[$this->_fixtureClassMap[$class]]->drop($db2);
}
}
+
/**
* testDisplayField method
*
@@ -506,6 +513,7 @@ class ModelIntegrationTest extends BaseModelTest {
$this->assertEqual($Person->displayField, 'name');
$this->assertEqual($Comment->displayField, 'id');
}
+
/**
* testSchema method
*
@@ -528,6 +536,7 @@ class ModelIntegrationTest extends BaseModelTest {
$this->assertEqual($Post->getColumnTypes(), array_combine($columns, $types));
}
+
/**
* test deconstruct() with time fields.
*
@@ -613,6 +622,7 @@ class ModelIntegrationTest extends BaseModelTest {
$TestModel->set($data);
$this->assertEqual($TestModel->data, $data);
}
+
/**
* testDeconstructFields with datetime, timestamp, and date fields
*
@@ -789,6 +799,7 @@ class ModelIntegrationTest extends BaseModelTest {
$TestModel->set($data);
$this->assertEqual($TestModel->data, $data);
}
+
/**
* testTablePrefixSwitching method
*
@@ -842,6 +853,7 @@ class ModelIntegrationTest extends BaseModelTest {
$this->assertEqual($db2->fullTableName($TestModel, false), 'apples');
$this->assertEqual($db1->fullTableName($TestModel, false), 'apples');
}
+
/**
* Tests validation parameter order in custom validation methods
*
@@ -852,6 +864,7 @@ class ModelIntegrationTest extends BaseModelTest {
$TestModel =& new ValidationTest1();
$this->assertNull($TestModel->getAssociated('Foo'));
}
+
/**
* testLoadModelSecondIteration method
*
@@ -868,6 +881,7 @@ class ModelIntegrationTest extends BaseModelTest {
$this->assertIsA($model->ModelC, 'ModelC');
$this->assertIsA($model->ModelC->ModelD, 'ModelD');
}
+
/**
* ensure that __exists is reset on create
*
@@ -889,6 +903,7 @@ class ModelIntegrationTest extends BaseModelTest {
$result = $Article->read(null, 2);
$this->assertEqual($result['Article']['title'], 'Staying alive');
}
+
/**
* testPluginAssociations method
*
@@ -1013,6 +1028,7 @@ class ModelIntegrationTest extends BaseModelTest {
$this->assertEqual($result, $expected);
}
+
/**
* Tests getAssociated method
*
@@ -1161,6 +1177,7 @@ class ModelIntegrationTest extends BaseModelTest {
$this->assertEqual($TestModel->Tag->name, 'Tag');
$this->assertEqual($TestFakeModel->Tag->name, 'Tag');
}
+
/**
* test Model::__construct
*
@@ -1181,6 +1198,7 @@ class ModelIntegrationTest extends BaseModelTest {
$this->assertEqual($TestModel->actsAs, $expected);
$this->assertTrue(isset($TestModel->Behaviors->Containable));
}
+
/**
* test Model::__construct
*
@@ -1198,6 +1216,7 @@ class ModelIntegrationTest extends BaseModelTest {
$NewVoid =& new TheVoid(null, false, 'other');
$this->assertEqual('other', $NewVoid->useDbConfig);
}
+
/**
* testColumnTypeFetching method
*
@@ -1216,6 +1235,7 @@ class ModelIntegrationTest extends BaseModelTest {
$this->assertEqual($model->getColumnType('Tag.id'), 'integer');
$this->assertEqual($model->getColumnType('Article.id'), 'integer');
}
+
/**
* testHabtmUniqueKey method
*
@@ -1226,6 +1246,7 @@ class ModelIntegrationTest extends BaseModelTest {
$model =& new Item();
$this->assertFalse($model->hasAndBelongsToMany['Portfolio']['unique']);
}
+
/**
* testIdentity method
*
@@ -1248,6 +1269,7 @@ class ModelIntegrationTest extends BaseModelTest {
$expected = 'AnotherTest';
$this->assertEqual($result, $expected);
}
+
/**
* testWithAssociation method
*
@@ -1499,6 +1521,7 @@ class ModelIntegrationTest extends BaseModelTest {
$this->assertEqual($result, $expected);
}
+
/**
* testFindSelfAssociations method
*
@@ -1608,6 +1631,7 @@ class ModelIntegrationTest extends BaseModelTest {
$this->assertEqual($result, $expected);
}
+
/**
* testDynamicAssociations method
*
@@ -1715,6 +1739,7 @@ class ModelIntegrationTest extends BaseModelTest {
$this->assertEqual($result, $expected);
}
+
/**
* testCreation method
*
diff --git a/cake/tests/cases/libs/model/model_read.test.php b/cake/tests/cases/libs/model/model_read.test.php
index 233a1b1e7..f6745d6d4 100644
--- a/cake/tests/cases/libs/model/model_read.test.php
+++ b/cake/tests/cases/libs/model/model_read.test.php
@@ -1,5 +1,6 @@
assertEqual($result['SomethingElse'][0]['JoinThing']['doomed'], 1);
$this->assertEqual($result['SomethingElse'][1]['JoinThing']['doomed'], 0);
}
+
/**
* testGroupBy method
*
@@ -196,28 +200,24 @@ class ModelReadTest extends BaseModelTest {
));
$this->assertEqual($result, $expected);
-
$result = $Thread->find('all', array(
'conditions' => array('Thread.project_id' => 1),
'group' => array('project_id')
));
$this->assertEqual($result, $expected);
-
$result = $Thread->find('all', array(
'conditions' => array('Thread.project_id' => 1),
'group' => array('project_id', 'Project.id')
));
$this->assertEqual($result, $expected);
-
$result = $Thread->find('all', array(
'conditions' => array('Thread.project_id' => 1),
'group' => array('Thread.project_id', 'Project.id')
));
$this->assertEqual($result, $expected);
-
$expected = array(
array('Product' => array('type' => 'Clothing'), array('price' => 32)),
array('Product' => array('type' => 'Food'), array('price' => 9)),
@@ -237,6 +237,7 @@ class ModelReadTest extends BaseModelTest {
'order' => 'Product.type ASC'));
$this->assertEqual($result, $expected);
}
+
/**
* testOldQuery method
*
@@ -272,6 +273,7 @@ class ModelReadTest extends BaseModelTest {
$this->assertTrue(isset($this->db->_queryCache[$query]));
$this->assertTrue(is_array($results));
}
+
/**
* testPreparedQuery method
*
@@ -353,6 +355,7 @@ class ModelReadTest extends BaseModelTest {
$this->assertTrue(isset($this->db->_queryCache[$expected]));
}
+
/**
* testParameterMismatch method
*
@@ -374,6 +377,7 @@ class ModelReadTest extends BaseModelTest {
ob_end_clean();
$this->assertEqual($result, null);
}
+
/**
* testVeryStrangeUseCase method
*
@@ -403,6 +407,7 @@ class ModelReadTest extends BaseModelTest {
$result = $Article->query($query, $param);
ob_end_clean();
}
+
/**
* testRecursiveUnbind method
*
@@ -2997,6 +3002,7 @@ class ModelReadTest extends BaseModelTest {
)));
$this->assertEqual($result, $expected);
}
+
/**
* testSelfAssociationAfterFind method
*
@@ -3024,6 +3030,7 @@ class ModelReadTest extends BaseModelTest {
}
$this->assertEqual($afterFindData, $noAfterFindData);
}
+
/**
* testFindAllThreaded method
*
@@ -3500,6 +3507,7 @@ class ModelReadTest extends BaseModelTest {
);
$this->assertEqual($result, $expected);
}
+
/**
* test find('neighbors')
*
@@ -3933,6 +3941,7 @@ class ModelReadTest extends BaseModelTest {
));
$this->assertEqual($result, $expected);
}
+
/**
* testSaveEmpty method
*
@@ -4045,7 +4054,6 @@ class ModelReadTest extends BaseModelTest {
$result = $TestModel->find('all', compact('conditions', 'recursive', 'order'));
$this->assertEqual($result, $expected);
-
$conditions = array('id' => array('1', 2, '3.0'));
$order = 'Article.id ASC';
$result = $TestModel->find('all', compact('recursive', 'conditions', 'order'));
@@ -4086,6 +4094,7 @@ class ModelReadTest extends BaseModelTest {
);
$this->assertEqual($result, $expected);
}
+
/**
* testBindUnbind method
*
@@ -4545,6 +4554,7 @@ class ModelReadTest extends BaseModelTest {
$this->assertEqual($TestModel2->hasMany['NewFeatureSet'], $expected);
$this->assertTrue(is_object($TestModel2->NewFeatureSet));
}
+
/**
* testBindMultipleTimes method
*
@@ -4825,6 +4835,7 @@ class ModelReadTest extends BaseModelTest {
);
$this->assertEqual($result[0]['Post'][0]['Comment'][0], $expected);
}
+
/**
* Tests that callbacks can be properly disabled
*
@@ -4851,6 +4862,7 @@ class ModelReadTest extends BaseModelTest {
$expected = array('mariano', 'nate', 'larry', 'garrett');
$this->assertEqual($result, $expected);
}
+
/**
* testMultipleBelongsToWithSameClass method
*
@@ -4949,6 +4961,7 @@ class ModelReadTest extends BaseModelTest {
$this->assertEqual($result, $expected);
}
+
/**
* testHabtmRecursiveBelongsTo method
*
@@ -5007,6 +5020,7 @@ class ModelReadTest extends BaseModelTest {
$this->assertEqual($result, $expected);
}
+
/**
* testHabtmFinderQuery method
*
@@ -5055,6 +5069,7 @@ class ModelReadTest extends BaseModelTest {
$this->assertEqual($result['Tag'], $expected);
}
+
/**
* testHabtmLimitOptimization method
*
@@ -5125,6 +5140,7 @@ class ModelReadTest extends BaseModelTest {
$this->assertEqual($result, $expected);
}
+
/**
* testHasManyLimitOptimization method
*
@@ -5239,6 +5255,7 @@ class ModelReadTest extends BaseModelTest {
$this->assertEqual($result, $expected);
}
+
/**
* testFindAllRecursiveSelfJoin method
*
@@ -5344,10 +5361,8 @@ class ModelReadTest extends BaseModelTest {
)))));
$this->assertEqual($result, $expected);
-
-
-
}
+
/**
* testFindAllRecursiveWithHabtm method
*
@@ -5416,6 +5431,7 @@ class ModelReadTest extends BaseModelTest {
$this->assertIdentical($result, $expected);
}
+
/**
* testReadFakeThread method
*
@@ -5480,6 +5496,7 @@ class ModelReadTest extends BaseModelTest {
$this->db->fullDebug = $fullDebug;
$this->assertEqual($result, $expected);
}
+
/**
* testFindFakeThread method
*
@@ -5544,6 +5561,7 @@ class ModelReadTest extends BaseModelTest {
$this->db->fullDebug = $fullDebug;
$this->assertEqual($result, $expected);
}
+
/**
* testFindAllFakeThread method
*
@@ -5764,6 +5782,7 @@ class ModelReadTest extends BaseModelTest {
$this->db->fullDebug = $fullDebug;
$this->assertEqual($result, $expected);
}
+
/**
* testConditionalNumerics method
*
@@ -6011,6 +6030,7 @@ class ModelReadTest extends BaseModelTest {
$this->assertEqual($result, $expected);
}
}
+
/**
* test find('list') method
*
@@ -6274,6 +6294,7 @@ class ModelReadTest extends BaseModelTest {
);
$this->assertEqual($result, $expected);
}
+
/**
* testFindField method
*
@@ -6303,6 +6324,7 @@ class ModelReadTest extends BaseModelTest {
$result = $TestModel->field('COUNT(*)', true);
$this->assertEqual($result, 4);
}
+
/**
* testFindUnique method
*
@@ -6325,6 +6347,7 @@ class ModelReadTest extends BaseModelTest {
'password' => '5f4dcc3b5aa765d61d8327deb882cf99'
)));
}
+
/**
* test find('count') method
*
@@ -6371,6 +6394,7 @@ class ModelReadTest extends BaseModelTest {
$result = $TestModel->find('count', array('fields' => 'DISTINCT name'));
$this->assertEqual($result, 4);
}
+
/**
* Test find(count) with Db::expression
*
@@ -6395,6 +6419,7 @@ class ModelReadTest extends BaseModelTest {
)));
$this->assertEqual($result, 1);
}
+
/**
* testFindMagic method
*
@@ -6426,6 +6451,7 @@ class ModelReadTest extends BaseModelTest {
));
$this->assertEqual($result, $expected);
}
+
/**
* testRead method
*
@@ -6506,6 +6532,7 @@ class ModelReadTest extends BaseModelTest {
)));
$this->assertEqual($result, $expected);
}
+
/**
* testRecursiveRead method
*
@@ -6932,6 +6959,7 @@ class ModelReadTest extends BaseModelTest {
)));
$this->assertEqual($result, $expected);
}
+
/**
* testRecursiveFindAllWithLimit method
*
diff --git a/cake/tests/cases/libs/model/model_validation.test.php b/cake/tests/cases/libs/model/model_validation.test.php
index b4dcf22fd..94a381502 100644
--- a/cake/tests/cases/libs/model/model_validation.test.php
+++ b/cake/tests/cases/libs/model/model_validation.test.php
@@ -1,5 +1,6 @@
assertEqual($TestModel->invalidFields(), $expected);
}
+
/**
* Tests validation parameter fieldList in invalidFields
*
diff --git a/cake/tests/cases/libs/model/model_write.test.php b/cake/tests/cases/libs/model/model_write.test.php
index c0f45af02..a7a00e58c 100644
--- a/cake/tests/cases/libs/model/model_write.test.php
+++ b/cake/tests/cases/libs/model/model_write.test.php
@@ -1,5 +1,6 @@
JoinAsJoinB->findById(1);
$this->assertEqual($result['JoinAsJoinB']['other'], $updatedValue);
}
+
/**
* testSaveDateAsFirstEntry method
*
@@ -117,6 +121,7 @@ class ModelWriteTest extends BaseModelTest {
$this->assertEqual($testResult['Article']['created'], '2008-01-01 00:00:00');
}
+
/**
* testUnderscoreFieldSave method
*
@@ -142,6 +147,7 @@ class ModelWriteTest extends BaseModelTest {
$currentCount = $UnderscoreField->find('count');
$this->assertEqual($currentCount, 4);
}
+
/**
* testAutoSaveUuid method
*
@@ -167,6 +173,7 @@ class ModelWriteTest extends BaseModelTest {
);
$this->assertEqual(strlen($result['Uuid']['id']), 36);
}
+
/**
* testZeroDefaultFieldValue method
*
@@ -187,6 +194,7 @@ class ModelWriteTest extends BaseModelTest {
$this->assertIdentical($result['DataTest']['count'], '0');
$this->assertIdentical($result['DataTest']['float'], '0');
}
+
/**
* testNonNumericHabtmJoinKey method
*
@@ -285,6 +293,7 @@ class ModelWriteTest extends BaseModelTest {
));
$this->assertEqual($result, $expected);
}
+
/**
* Tests validation parameter order in custom validation methods
*
@@ -305,6 +314,7 @@ class ModelWriteTest extends BaseModelTest {
));
$this->assertEqual($TestModel->data, $expected);
}
+
/**
* test that Caches are getting cleared on save().
* ensure that both inflections of controller names are getting cleared
@@ -342,6 +352,7 @@ class ModelWriteTest extends BaseModelTest {
Configure::write('Cache.check', $_back['check']);
Configure::write('Cache.disable', $_back['disable']);
}
+
/**
* testSaveWithCounterCache method
*
@@ -378,6 +389,7 @@ class ModelWriteTest extends BaseModelTest {
$result = $TestModel->findById(2);
$this->assertIdentical($result['Syfile']['item_count'], '0');
}
+
/**
* Tests that counter caches are updated when records are added
*
@@ -403,6 +415,7 @@ class ModelWriteTest extends BaseModelTest {
$expected = 3;
$this->assertEqual($result, $expected);
}
+
/**
* Tests that counter caches are updated when records are deleted
*
@@ -424,6 +437,7 @@ class ModelWriteTest extends BaseModelTest {
$expected = 1;
$this->assertEqual($result, $expected);
}
+
/**
* Tests that counter caches are updated when foreign keys of counted records change
*
@@ -446,6 +460,7 @@ class ModelWriteTest extends BaseModelTest {
$this->assertEqual($users[0]['User']['post_count'], 1);
$this->assertEqual($users[1]['User']['post_count'], 2);
}
+
/**
* Test counter cache with models that use a non-standard (i.e. not using 'id')
* as their primary key.
@@ -453,14 +468,14 @@ class ModelWriteTest extends BaseModelTest {
* @access public
* @return void
*/
- function testCounterCacheWithNonstandardPrimaryKey() {
- $this->loadFixtures(
+ function testCounterCacheWithNonstandardPrimaryKey() {
+ $this->loadFixtures(
'CounterCacheUserNonstandardPrimaryKey',
'CounterCachePostNonstandardPrimaryKey'
);
- $User = new CounterCacheUserNonstandardPrimaryKey();
- $Post = new CounterCachePostNonstandardPrimaryKey();
+ $User = new CounterCacheUserNonstandardPrimaryKey();
+ $Post = new CounterCachePostNonstandardPrimaryKey();
$data = $Post->find('first', array(
'conditions' => array('pid' => 1),
@@ -472,7 +487,7 @@ class ModelWriteTest extends BaseModelTest {
$users = $User->find('all',array('order' => 'User.uid'));
$this->assertEqual($users[0]['User']['post_count'], 1);
$this->assertEqual($users[1]['User']['post_count'], 2);
- }
+ }
/**
* test Counter Cache With Self Joining table
@@ -502,6 +517,7 @@ class ModelWriteTest extends BaseModelTest {
$expected = array_fill(0, 1, 1);
$this->assertEqual($result, $expected);
}
+
/**
* testSaveWithCounterCacheScope method
*
@@ -541,6 +557,7 @@ class ModelWriteTest extends BaseModelTest {
$result = $TestModel->findById(1);
$this->assertIdentical($result['Syfile']['item_count'], '1');
}
+
/**
* testValidatesBackwards method
*
@@ -606,6 +623,7 @@ class ModelWriteTest extends BaseModelTest {
$result = $TestModel->validates();
$this->assertTrue($result);
}
+
/**
* testValidates method
*
@@ -958,6 +976,7 @@ class ModelWriteTest extends BaseModelTest {
);
$this->assertEqual($result, $expected);
}
+
/**
* testSaveField method
*
@@ -1026,6 +1045,7 @@ class ModelWriteTest extends BaseModelTest {
$result = $Node->read();
$this->assertEqual(Set::extract('/ParentNode/name', $result), array('Second'));
}
+
/**
* testSaveWithCreate method
*
@@ -1247,6 +1267,7 @@ class ModelWriteTest extends BaseModelTest {
$this->assertEqual($result, $expected);
}
+
/**
* testSaveWithSet method
*
@@ -1374,6 +1395,7 @@ class ModelWriteTest extends BaseModelTest {
);
$this->assertEqual($result, $expected);
}
+
/**
* testSaveWithNonExistentFields method
*
@@ -1425,6 +1447,7 @@ class ModelWriteTest extends BaseModelTest {
$result = $TestModel->read(array('id', 'user_id', 'title', 'body', 'published'), 5);
$this->assertEqual($result, $expected);
}
+
/**
* testSaveFromXml method
*
@@ -1442,6 +1465,7 @@ class ModelWriteTest extends BaseModelTest {
$results = $Article->find(array('Article.title' => 'test xml'));
$this->assertTrue($results);
}
+
/**
* testSaveHabtm method
*
@@ -1913,6 +1937,7 @@ class ModelWriteTest extends BaseModelTest {
$expected = array('new record', 'new record');
$this->assertEqual(Set::extract('/JoinC/JoinAsJoinC/other', $result), $expected);
}
+
/**
* testSaveHabtmCustomKeys method
*
@@ -1963,6 +1988,7 @@ class ModelWriteTest extends BaseModelTest {
));
$this->assertEqual($result, $expected);
}
+
/**
* testHabtmSaveKeyResolution method
*
@@ -2052,6 +2078,7 @@ class ModelWriteTest extends BaseModelTest {
));
$this->assertEqual($result['Monkey'], $expected);
}
+
/**
* testCreationOfEmptyRecord method
*
@@ -2071,6 +2098,7 @@ class ModelWriteTest extends BaseModelTest {
$this->assertTrue(isset($result['Author']['updated']));
$this->assertEqual($TestModel->find('count'), 1);
}
+
/**
* testCreateWithPKFiltering method
*
@@ -2167,6 +2195,7 @@ class ModelWriteTest extends BaseModelTest {
$this->assertEqual($result, $expected);
$this->assertFalse($TestModel->id);
}
+
/**
* testCreationWithMultipleData method
*
@@ -2338,6 +2367,7 @@ class ModelWriteTest extends BaseModelTest {
))));
}
+
/**
* testCreationWithMultipleDataSameModel method
*
@@ -2396,6 +2426,7 @@ class ModelWriteTest extends BaseModelTest {
'title' => 'Brand New Article'
))));
}
+
/**
* testCreationWithMultipleDataSameModelManualInstances method
*
@@ -2434,6 +2465,7 @@ class ModelWriteTest extends BaseModelTest {
$result = $Primary->find('count');
$this->assertEqual($result, 2);
}
+
/**
* testRecordExists method
*
@@ -2457,6 +2489,7 @@ class ModelWriteTest extends BaseModelTest {
$TestModel->id = 5;
$this->assertFalse($TestModel->exists());
}
+
/**
* testUpdateExisting method
*
@@ -2504,6 +2537,7 @@ class ModelWriteTest extends BaseModelTest {
$result = $Comment->save($data);
$this->assertTrue($result);
}
+
/**
* testUpdateMultiple method
*
@@ -2537,6 +2571,7 @@ class ModelWriteTest extends BaseModelTest {
$expected = array_fill(0, 2, 'Updated today');
$this->assertEqual($result, $expected);
}
+
/**
* testHabtmUuidWithUuidId method
*
@@ -2556,6 +2591,7 @@ class ModelWriteTest extends BaseModelTest {
$this->assertEqual(1, count($result['Uuiditem']));
$this->assertEqual(strlen($result['Uuiditem'][0]['UuiditemsUuidportfolio']['id']), 36);
}
+
/**
* test HABTM saving when join table has no primary key and only 2 columns.
*
@@ -2579,6 +2615,7 @@ class ModelWriteTest extends BaseModelTest {
);
$this->assertTrue($Fruit->save($data));
}
+
/**
* test HABTM saving when join table has no primary key and only 2 columns, no with model is used.
*
@@ -2621,6 +2658,7 @@ class ModelWriteTest extends BaseModelTest {
$result = $TestModel->read(null, $id);
$this->assertEqual(1, count($result['Uuidportfolio']));
}
+
/**
* testSaveMultipleHabtm method
*
@@ -2739,6 +2777,7 @@ class ModelWriteTest extends BaseModelTest {
$this->assertEqual($result, $expected);
}
+
/**
* testSaveAll method
*
@@ -2878,6 +2917,7 @@ class ModelWriteTest extends BaseModelTest {
);
$this->assertEqual($result[6]['Attachment'], $expected);
}
+
/**
* Test SaveAll with Habtm relations
*
@@ -2909,6 +2949,7 @@ class ModelWriteTest extends BaseModelTest {
$this->assertEqual(count($result['Comment']), 1);
$this->assertEqual(count($result['Comment'][0]['comment']['Article comment']), 1);
}
+
/**
* Test SaveAll with Habtm relations and extra join table fields
*
@@ -2952,6 +2993,7 @@ class ModelWriteTest extends BaseModelTest {
$this->assertTrue(Set::matches('/SomethingElse[id=3]/JoinThing[something_else_id=3]', $result));
$this->assertTrue(Set::matches('/SomethingElse[id=3]/JoinThing[doomed=1]', $result));
}
+
/**
* testSaveAllHasOne method
*
@@ -2991,6 +3033,7 @@ class ModelWriteTest extends BaseModelTest {
)));
$this->assertEqual($result, $expected);
}
+
/**
* testSaveAllBelongsTo method
*
@@ -3030,6 +3073,7 @@ class ModelWriteTest extends BaseModelTest {
)));
$this->assertEqual($result, $expected);
}
+
/**
* testSaveAllHasOneValidation method
*
@@ -3076,6 +3120,7 @@ class ModelWriteTest extends BaseModelTest {
$this->assertEqual($model->validationErrors, $expected['Comment']);
$this->assertEqual($model->Attachment->validationErrors, $expected['Attachment']);
}
+
/**
* testSaveAllAtomic method
*
@@ -3149,6 +3194,7 @@ class ModelWriteTest extends BaseModelTest {
), array('atomic' => false));
$this->assertIdentical($result, array('Article' => true, 'Comment' => array(true, true)));
}
+
/**
* testSaveAllHasMany method
*
@@ -3225,6 +3271,7 @@ class ModelWriteTest extends BaseModelTest {
);
$this->assertEqual(Set::extract($result['Comment'], '{n}.comment'), $expected);
}
+
/**
* testSaveAllHasManyValidation method
*
@@ -3265,6 +3312,7 @@ class ModelWriteTest extends BaseModelTest {
))
), array('validate' => 'only'));
}
+
/**
* testSaveAllTransaction method
*
@@ -3654,6 +3702,7 @@ class ModelWriteTest extends BaseModelTest {
$TestModel->validate['body'] = 'notEmpty';
}
+
/**
* testSaveAllValidationOnly method
*
@@ -3706,6 +3755,7 @@ class ModelWriteTest extends BaseModelTest {
);
$this->assertEqual($TestModel->validationErrors, $expected);
}
+
/**
* testSaveAllValidateFirst method
*
@@ -3784,6 +3834,7 @@ class ModelWriteTest extends BaseModelTest {
);
$this->assertEqual($result[0]['Comment'][0]['comment'], 'Only new comment');
}
+
/**
* testUpdateWithCalculation method
*
@@ -3812,6 +3863,7 @@ class ModelWriteTest extends BaseModelTest {
$result = Set::extract('/DataTest/count', $model->find('all', array('fields' => 'count')));
$this->assertEqual($result, array(6, 4, 5, 2));
}
+
/**
* testSaveAllHasManyValidationOnly method
*
diff --git a/cake/tests/lib/cake_test_fixture.php b/cake/tests/lib/cake_test_fixture.php
index 2e75b36dd..e4ab3333b 100644
--- a/cake/tests/lib/cake_test_fixture.php
+++ b/cake/tests/lib/cake_test_fixture.php
@@ -40,6 +40,7 @@ class CakeTestFixture extends Object {
* @var string
**/
var $name = null;
+
/**
* Cake's DBO driver (e.g: DboMysql).
*
@@ -53,6 +54,7 @@ class CakeTestFixture extends Object {
* @access public
*/
var $table = null;
+
/**
* Instantiate the fixture.
*
diff --git a/cake/tests/test_app/views/layouts/cache_layout.ctp b/cake/tests/test_app/views/layouts/cache_layout.ctp
index 46784c1df..7ac370f3b 100644
--- a/cake/tests/test_app/views/layouts/cache_layout.ctp
+++ b/cake/tests/test_app/views/layouts/cache_layout.ctp
@@ -35,5 +35,4 @@
-Additional regular text.
-
+Additional regular text.
\ No newline at end of file
diff --git a/cake/tests/test_app/views/layouts/email/text/default.ctp b/cake/tests/test_app/views/layouts/email/text/default.ctp
index bfc1ef552..5fc1645ac 100644
--- a/cake/tests/test_app/views/layouts/email/text/default.ctp
+++ b/cake/tests/test_app/views/layouts/email/text/default.ctp
@@ -26,4 +26,4 @@
-This email was sent using the CakePHP Framework, http://cakephp.org.
+This email was sent using the CakePHP Framework, http://cakephp.org.
\ No newline at end of file
From d666af202e2bf61c1f1a5334ab09129624c97b3f Mon Sep 17 00:00:00 2001
From: AD7six
Date: Sun, 26 Jul 2009 12:01:36 +0200
Subject: [PATCH 04/31] whitespace normalization
---
app/config/bootstrap.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/config/bootstrap.php b/app/config/bootstrap.php
index 2c9b9f45d..d0dcb91e5 100644
--- a/app/config/bootstrap.php
+++ b/app/config/bootstrap.php
@@ -48,4 +48,4 @@
* Inflector::rule('plural', array('rules' => array(), 'irregular' => array(), 'uninflected' => array()));
*
*/
-?>
+?>
\ No newline at end of file
From 76927b35bae61bebebeba64a7a447e51297ecf8c Mon Sep 17 00:00:00 2001
From: AD7six
Date: Sun, 26 Jul 2009 12:04:07 +0200
Subject: [PATCH 05/31] whitespace normalization
---
cake/console/libs/api.php | 2 +-
cake/console/libs/templates/skel/views/layouts/flash.ctp | 1 -
2 files changed, 1 insertion(+), 2 deletions(-)
diff --git a/cake/console/libs/api.php b/cake/console/libs/api.php
index 8da6f9092..6513b7e91 100644
--- a/cake/console/libs/api.php
+++ b/cake/console/libs/api.php
@@ -47,7 +47,7 @@ class ApiShell extends Shell {
*
* @access public
*/
- function initialize () {
+ function initialize() {
$this->paths = array_merge($this->paths, array(
'behavior' => LIBS . 'model' . DS . 'behaviors' . DS,
'cache' => LIBS . 'cache' . DS,
diff --git a/cake/console/libs/templates/skel/views/layouts/flash.ctp b/cake/console/libs/templates/skel/views/layouts/flash.ctp
index e59354eed..9596dae4d 100644
--- a/cake/console/libs/templates/skel/views/layouts/flash.ctp
+++ b/cake/console/libs/templates/skel/views/layouts/flash.ctp
@@ -29,7 +29,6 @@
charset(); ?>
-
From fd0aaefb398c58c477c9e0f28d7a387053acea2c Mon Sep 17 00:00:00 2001
From: AD7six
Date: Sun, 26 Jul 2009 12:46:07 +0200
Subject: [PATCH 06/31] whitespace normalization
---
cake/libs/cake_session.php | 2 +-
.../controller/components/request_handler.php | 2 +-
cake/libs/debugger.php | 1 -
cake/libs/model/cake_schema.php | 1 -
.../libs/model/datasources/dbo/dbo_oracle.php | 27 +++++++-------
cake/libs/multibyte.php | 2 +-
cake/libs/security.php | 36 +++++++++----------
cake/libs/set.php | 2 +-
cake/libs/validation.php | 2 +-
cake/libs/view/helpers/ajax.php | 4 +--
cake/libs/view/helpers/xml.php | 1 -
cake/libs/view/theme.php | 2 +-
12 files changed, 39 insertions(+), 43 deletions(-)
diff --git a/cake/libs/cake_session.php b/cake/libs/cake_session.php
index 387f6088a..1b29f0779 100644
--- a/cake/libs/cake_session.php
+++ b/cake/libs/cake_session.php
@@ -746,7 +746,7 @@ class CakeSession extends Object {
return false;
}
- return $row[$model->alias]['data'];
+ return $row[$model->alias]['data'];
}
/**
diff --git a/cake/libs/controller/components/request_handler.php b/cake/libs/controller/components/request_handler.php
index 7a1988f43..88b31cd1c 100644
--- a/cake/libs/controller/components/request_handler.php
+++ b/cake/libs/controller/components/request_handler.php
@@ -581,7 +581,7 @@ class RequestHandlerComponent extends Object {
} elseif (count($types) === 1) {
return ($types[0] === $accepts[0]);
} elseif (count($accepts) === 1) {
- return $accepts[0];
+ return $accepts[0];
}
$acceptedTypes = array();
diff --git a/cake/libs/debugger.php b/cake/libs/debugger.php
index 41bf616c9..ae4af85ec 100644
--- a/cake/libs/debugger.php
+++ b/cake/libs/debugger.php
@@ -165,7 +165,6 @@ class Debugger extends Object {
$this->_templates['js']['code'] = '_templates['js']['code'] .= 'style="display: none;">
{:code}
';
-
$e = '{:error} ({:code}) : {:description} ';
$e .= '[{:path}, line {:line}]
';
$this->_templates['html']['error'] = $e;
diff --git a/cake/libs/model/cake_schema.php b/cake/libs/model/cake_schema.php
index deed6c838..20a4dce4d 100644
--- a/cake/libs/model/cake_schema.php
+++ b/cake/libs/model/cake_schema.php
@@ -366,7 +366,6 @@ class CakeSchema extends Object {
}
$out .="}\n";
-
$File =& new File($path . DS . $file, true);
$header = '$Id';
$content = "";
diff --git a/cake/libs/model/datasources/dbo/dbo_oracle.php b/cake/libs/model/datasources/dbo/dbo_oracle.php
index 5c19c709c..6658b7e12 100644
--- a/cake/libs/model/datasources/dbo/dbo_oracle.php
+++ b/cake/libs/model/datasources/dbo/dbo_oracle.php
@@ -204,10 +204,11 @@ class DboOracle extends DboSource {
}
return $this->connected;
}
- /**
- * Keeps track of the most recent Oracle error
- *
- */
+
+/**
+ * Keeps track of the most recent Oracle error
+ *
+ */
function _setError($source = null, $clear = false) {
if ($source) {
$e = ocierror($source);
@@ -1069,7 +1070,6 @@ class DboOracle extends DboSource {
$q = str_replace('= (', 'IN (', $q);
$q = str_replace(' WHERE 1 = 1', '', $q);
-
$q = $this->insertQueryData($q, null, $association, $assocData, $model, $linkModel, $stack);
if ($q != false) {
$res = $this->fetchAll($q, $model->cacheQueries, $model->alias);
@@ -1139,14 +1139,15 @@ class DboOracle extends DboSource {
}
}
}
- /**
- * Generate a "drop table" statement for the given Schema object
- *
- * @param object $schema An instance of a subclass of CakeSchema
- * @param string $table Optional. If specified only the table name given will be generated.
- * Otherwise, all tables defined in the schema are generated.
- * @return string
- */
+
+/**
+ * Generate a "drop table" statement for the given Schema object
+ *
+ * @param object $schema An instance of a subclass of CakeSchema
+ * @param string $table Optional. If specified only the table name given will be generated.
+ * Otherwise, all tables defined in the schema are generated.
+ * @return string
+ */
function dropSchema($schema, $table = null) {
if (!is_a($schema, 'CakeSchema')) {
trigger_error(__('Invalid schema object', true), E_USER_WARNING);
diff --git a/cake/libs/multibyte.php b/cake/libs/multibyte.php
index 2d5814153..fe8c7f4f4 100644
--- a/cake/libs/multibyte.php
+++ b/cake/libs/multibyte.php
@@ -1063,7 +1063,7 @@ class Multibyte extends Object {
* @return string
* @access private
*/
- function __codepoint ($decimal) {
+ function __codepoint($decimal) {
if ($decimal > 128 && $decimal < 256) {
$return = '0080_00ff'; // Latin-1 Supplement
} elseif ($decimal < 384) {
diff --git a/cake/libs/security.php b/cake/libs/security.php
index 72513fcd8..680a06914 100644
--- a/cake/libs/security.php
+++ b/cake/libs/security.php
@@ -45,12 +45,12 @@ class Security extends Object {
var $hashType = null;
/**
- * Singleton implementation to get object instance.
- *
- * @return object
- * @access public
- * @static
- */
+ * Singleton implementation to get object instance.
+ *
+ * @return object
+ * @access public
+ * @static
+ */
function &getInstance() {
static $instance = array();
if (!$instance) {
@@ -60,12 +60,12 @@ class Security extends Object {
}
/**
- * Get allowed minutes of inactivity based on security level.
- *
- * @return integer Allowed inactivity in minutes
- * @access public
- * @static
- */
+ * Get allowed minutes of inactivity based on security level.
+ *
+ * @return integer Allowed inactivity in minutes
+ * @access public
+ * @static
+ */
function inactiveMins() {
$_this =& Security::getInstance();
switch (Configure::read('Security.level')) {
@@ -83,12 +83,12 @@ class Security extends Object {
}
/**
- * Generate authorization hash.
- *
- * @return string Hash
- * @access public
- * @static
- */
+ * Generate authorization hash.
+ *
+ * @return string Hash
+ * @access public
+ * @static
+ */
function generateAuthKey() {
if (!class_exists('String')) {
App::import('Core', 'String');
diff --git a/cake/libs/set.php b/cake/libs/set.php
index 0d103986e..d1fea29b2 100644
--- a/cake/libs/set.php
+++ b/cake/libs/set.php
@@ -422,7 +422,7 @@ class Set extends Object {
$context['key'] = array_pop($context['trace']);
if (isset($context['trace'][1]) && $context['trace'][1] > 0) {
$context['item'] = $context['item'][0];
- } else if(!empty($context['item'][$key])){
+ } elseif (!empty($context['item'][$key])) {
$context['item'] = $context['item'][$key];
} else {
$context['item'] = array_shift($context['item']);
diff --git a/cake/libs/validation.php b/cake/libs/validation.php
index a33e2d9a8..fd2606c5f 100644
--- a/cake/libs/validation.php
+++ b/cake/libs/validation.php
@@ -778,7 +778,7 @@ class Validation extends Object {
* @return boolean Success
* @access public
*/
- function range($check, $lower = null, $upper = null ) {
+ function range($check, $lower = null, $upper = null) {
if (!is_numeric($check)) {
return false;
}
diff --git a/cake/libs/view/helpers/ajax.php b/cake/libs/view/helpers/ajax.php
index 708a89b87..479f04df4 100644
--- a/cake/libs/view/helpers/ajax.php
+++ b/cake/libs/view/helpers/ajax.php
@@ -508,7 +508,6 @@ class AjaxHelper extends AppHelper {
$options = $this->_optionsToString($options, array('paramName', 'indicator'));
$options = $this->_buildOptions($options, $this->autoCompleteOptions);
-
$text = $this->Form->text($field, $htmlOptions);
$div = $this->Html->div(null, '', $divOptions);
$script = "{$var}new Ajax.Autocompleter('{$htmlOptions['id']}', '{$divOptions['id']}', '";
@@ -903,7 +902,7 @@ class AjaxHelper extends AppHelper {
$callback = $this->remoteFunction($options);
$hasFrequency = !(!isset($options['frequency']) || intval($options['frequency']) == 0);
- $frequency = $hasFrequency ? $options['frequency'] . ', ' : '';
+ $frequency = $hasFrequency ? $options['frequency'] . ', ' : '';
return "new $klass('$name', {$frequency}function(element, value) {{$callback}})";
}
@@ -1018,5 +1017,4 @@ class AjaxHelper extends AppHelper {
}
}
}
-
?>
\ No newline at end of file
diff --git a/cake/libs/view/helpers/xml.php b/cake/libs/view/helpers/xml.php
index 2a2bb3f52..521ee0d91 100644
--- a/cake/libs/view/helpers/xml.php
+++ b/cake/libs/view/helpers/xml.php
@@ -168,5 +168,4 @@ class XmlHelper extends AppHelper {
return $data->toString($options + array('header' => false));
}
}
-
?>
\ No newline at end of file
diff --git a/cake/libs/view/theme.php b/cake/libs/view/theme.php
index 697328fbb..435d3086c 100644
--- a/cake/libs/view/theme.php
+++ b/cake/libs/view/theme.php
@@ -58,7 +58,7 @@ class ThemeView extends View {
*
* @param unknown_type $controller
*/
- function __construct (&$controller) {
+ function __construct(&$controller) {
parent::__construct($controller);
$this->theme =& $controller->theme;
From 99fc6458a45c24c0fce55545ef9104a56e31bd28 Mon Sep 17 00:00:00 2001
From: AD7six
Date: Sun, 26 Jul 2009 19:23:46 +0200
Subject: [PATCH 07/31] allow running all core test cases via the console
---
cake/console/libs/testsuite.php | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/cake/console/libs/testsuite.php b/cake/console/libs/testsuite.php
index 4915412e6..7038cd9fd 100644
--- a/cake/console/libs/testsuite.php
+++ b/cake/console/libs/testsuite.php
@@ -94,7 +94,7 @@ class TestSuiteShell extends Shell {
if (isset($corePath[0])) {
define('TEST_CAKE_CORE_INCLUDE_PATH', rtrim($corePath[0], DS) . DS);
} else {
- define('TEST_CAKE_CORE_INCLUDE_PATH', CAKE_CORE_INCLUDE_PATH);
+ define('TEST_CAKE_CORE_INCLUDE_PATH', CAKE_CORE_INCLUDE_PATH . DS . 'cake' . DS);
}
$this->__installSimpleTest();
@@ -236,8 +236,13 @@ class TestSuiteShell extends Shell {
return true;
}
- if ($this->category == 'core' && file_exists($folder.DS.'cases'.DS.'libs'.DS.$this->file.'.test.php')) {
- return true;
+ if ($this->category == 'core') {
+ if (file_exists($folder.DS.'cases'.DS.$this->file.'.test.php')) {
+ return true;
+ }
+ if (file_exists($folder.DS.'cases'.DS.'libs'.DS.$this->file.'.test.php')) {
+ return true;
+ }
}
if ($isPlugin && file_exists($folder.DS.'cases'.DS.$this->file.'.test.php')) {
@@ -292,7 +297,11 @@ class TestSuiteShell extends Shell {
return $result;
}
- $case = 'libs'.DS.$this->file.'.test.php';
+ if (file_exists(CORE_TEST_CASES . DS . $this->file . '.test.php')) {
+ $case = $this->file . '.test.php';
+ } else {
+ $case = 'libs' . DS . $this->file . '.test.php';
+ }
if ($this->category == 'app') {
$case = $this->file.'.test.php';
} elseif ($this->isPluginTest) {
From ee8d12c939040a033c4db50f4689a210ce7add1c Mon Sep 17 00:00:00 2001
From: "renan.saddam"
Date: Wed, 29 Jul 2009 22:30:20 +0000
Subject: [PATCH 08/31] Fixing issue with "DEFAULT NULL NULL" generated by
buildColumn. Making the tests pass by just changing the start and end quotes.
Providing "created" values for CakeTestFixtureTestFixture Fixture.
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@8262 3807eeeb-6ff5-0310-8944-8be069107fe0
---
cake/libs/model/datasources/dbo/dbo_mssql.php | 22 +---
.../cases/libs/cake_test_fixture.test.php | 6 +-
.../model/datasources/dbo/dbo_mssql.test.php | 109 +++++++++++++++++-
.../model/datasources/dbo_source.test.php | 3 +
4 files changed, 118 insertions(+), 22 deletions(-)
diff --git a/cake/libs/model/datasources/dbo/dbo_mssql.php b/cake/libs/model/datasources/dbo/dbo_mssql.php
index 766b70be1..4e5fb73ce 100644
--- a/cake/libs/model/datasources/dbo/dbo_mssql.php
+++ b/cake/libs/model/datasources/dbo/dbo_mssql.php
@@ -211,9 +211,10 @@ class DboMssql extends DboSource {
return $cache;
}
- $fields = false;
- $cols = $this->fetchAll("SELECT COLUMN_NAME as Field, DATA_TYPE as Type, COL_LENGTH('" . $this->fullTableName($model, false) . "', COLUMN_NAME) as Length, IS_NULLABLE As [Null], COLUMN_DEFAULT as [Default], COLUMNPROPERTY(OBJECT_ID('" . $this->fullTableName($model, false) . "'), COLUMN_NAME, 'IsIdentity') as [Key], NUMERIC_SCALE as Size FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = '" . $this->fullTableName($model, false) . "'", false);
+ $table = $this->fullTableName($model, false);
+ $cols = $this->fetchAll("SELECT COLUMN_NAME as Field, DATA_TYPE as Type, COL_LENGTH('" . $table . "', COLUMN_NAME) as Length, IS_NULLABLE As [Null], COLUMN_DEFAULT as [Default], COLUMNPROPERTY(OBJECT_ID('" . $table . "'), COLUMN_NAME, 'IsIdentity') as [Key], NUMERIC_SCALE as Size FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = '" . $table . "'", false);
+ $fields = false;
foreach ($cols as $column) {
$field = $column[0]['Field'];
$fields[$field] = array(
@@ -659,23 +660,11 @@ class DboMssql extends DboSource {
* Generate a database-native column schema string
*
* @param array $column An array structured like the following: array('name'=>'value', 'type'=>'value'[, options]),
- * where options can be 'default', 'length', or 'key'.
+ * where options can be 'default', 'length', or 'key'.
* @return string
*/
function buildColumn($column) {
- $result = preg_replace('/(int|integer)\([0-9]+\)/i', '$1', parent::buildColumn($column));
- $null = (
- (isset($column['null']) && $column['null'] == true) ||
- (array_key_exists('default', $column) && $column['default'] === null) ||
- (array_keys($column) == array('type', 'name'))
- );
- $primaryKey = (isset($column['key']) && $column['key'] == 'primary');
- $stringKey = ($primaryKey && $column['type'] != 'integer');
-
- if ($null && !$primaryKey) {
- $result .= " NULL";
- }
- return $result;
+ return preg_replace('/(int|integer)\([0-9]+\)/i', '$1', parent::buildColumn($column));
}
/**
* Format indexes for create table
@@ -723,7 +712,6 @@ class DboMssql extends DboSource {
return $field;
}
}
-
return null;
}
}
diff --git a/cake/tests/cases/libs/cake_test_fixture.test.php b/cake/tests/cases/libs/cake_test_fixture.test.php
index 03a712a56..d5844bc6c 100644
--- a/cake/tests/cases/libs/cake_test_fixture.test.php
+++ b/cake/tests/cases/libs/cake_test_fixture.test.php
@@ -60,9 +60,9 @@ class CakeTestFixtureTestFixture extends CakeTestFixture {
* @var array
*/
var $records = array(
- array('name' => 'Gandalf'),
- array('name' => 'Captain Picard'),
- array('name' => 'Chewbacca')
+ array('name' => 'Gandalf', 'created' => '2009-04-28 19:20:00'),
+ array('name' => 'Captain Picard', 'created' => '2009-04-28 19:20:00'),
+ array('name' => 'Chewbacca', 'created' => '2009-04-28 19:20:00')
);
}
/**
diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_mssql.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_mssql.test.php
index 1cd3268fa..bd6060b8a 100644
--- a/cake/tests/cases/libs/model/datasources/dbo/dbo_mssql.test.php
+++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_mssql.test.php
@@ -43,6 +43,13 @@ class DboMssqlTestDb extends DboMssql {
* @access public
*/
var $simulated = array();
+/**
+ * simalate property
+ *
+ * @var array
+ * @access public
+ */
+ var $simulate = true;
/**
* fetchAllResultsStack
*
@@ -58,8 +65,12 @@ class DboMssqlTestDb extends DboMssql {
* @return void
*/
function _execute($sql) {
- $this->simulated[] = $sql;
- return null;
+ if ($this->simulate) {
+ $this->simulated[] = $sql;
+ return null;
+ } else {
+ return parent::_execute($sql);
+ }
}
/**
* fetchAll method
@@ -203,6 +214,20 @@ class DboMssqlTest extends CakeTestCase {
* @access public
*/
var $db = null;
+/**
+ * autoFixtures property
+ *
+ * @var bool false
+ * @access public
+ */
+ var $autoFixtures = false;
+/**
+ * fixtures property
+ *
+ * @var array
+ * @access public
+ */
+ var $fixtures = array('core.category');
/**
* Skip if cannot connect to mssql
*
@@ -212,6 +237,26 @@ class DboMssqlTest extends CakeTestCase {
$this->_initDb();
$this->skipUnless($this->db->config['driver'] == 'mssql', '%s SQL Server connection not available');
}
+/**
+ * Make sure all fixtures tables are being created
+ *
+ * @access public
+ */
+ function start() {
+ $this->db->simulate = false;
+ parent::start();
+ $this->db->simulate = true;
+ }
+/**
+ * Make sure all fixtures tables are being dropped
+ *
+ * @access public
+ */
+ function end() {
+ $this->db->simulate = false;
+ parent::end();
+ $this->db->simulate = true;
+ }
/**
* Sets up a Dbo class instance for testing
*
@@ -330,6 +375,59 @@ class DboMssqlTest extends CakeTestCase {
);
$this->assertEqual($result, $expected);
}
+/**
+ * testBuildColumn
+ *
+ * @return unknown_type
+ * @access public
+ */
+ function testBuildColumn() {
+ $column = array('name' => 'id', 'type' => 'integer', 'null' => '', 'default' => '', 'length' => '8', 'key' => 'primary');
+ $result = $this->db->buildColumn($column);
+ $expected = '[id] int IDENTITY (1, 1) NOT NULL';
+ $this->assertEqual($result, $expected);
+
+ $column = array('name' => 'client_id', 'type' => 'integer', 'null' => '', 'default' => '0', 'length' => '11');
+ $result = $this->db->buildColumn($column);
+ $expected = '[client_id] int DEFAULT 0 NOT NULL';
+ $this->assertEqual($result, $expected);
+
+ // 'name' => 'type' format
+ $column = array('name' => 'client_id', 'type' => 'integer');
+ $result = $this->db->buildColumn($column);
+ $expected = '[client_id] int';
+ $this->assertEqual($result, $expected);
+
+ $column = array('name' => 'client_id', 'type' => 'integer', 'null' => true);
+ $result = $this->db->buildColumn($column);
+ $expected = '[client_id] int DEFAULT NULL';
+ $this->assertEqual($result, $expected);
+
+ $column = array('name' => 'name', 'type' => 'string', 'null' => '', 'default' => '', 'length' => '255');
+ $result = $this->db->buildColumn($column);
+ $expected = '[name] varchar(255) DEFAULT \'\' NOT NULL';
+ $this->assertEqual($result, $expected);
+
+ $column = array('name' => 'name', 'type' => 'string', 'null' => false, 'length' => '255');
+ $result = $this->db->buildColumn($column);
+ $expected = '[name] varchar(255) NOT NULL';
+ $this->assertEqual($result, $expected);
+
+ $column = array('name' => 'name', 'type' => 'string', 'null' => false, 'default' => null, 'length' => '255');
+ $result = $this->db->buildColumn($column);
+ $expected = '[name] varchar(255) NOT NULL';
+ $this->assertEqual($result, $expected);
+
+ $column = array('name' => 'name', 'type' => 'string', 'null' => true, 'default' => null, 'length' => '255');
+ $result = $this->db->buildColumn($column);
+ $expected = '[name] varchar(255) DEFAULT NULL';
+ $this->assertEqual($result, $expected);
+
+ $column = array('name' => 'name', 'type' => 'string', 'null' => true, 'default' => '', 'length' => '255');
+ $result = $this->db->buildColumn($column);
+ $expected = '[name] varchar(255) DEFAULT \'\'';
+ $this->assertEqual($result, $expected);
+ }
/**
* testUpdateAllSyntax method
*
@@ -353,6 +451,7 @@ class DboMssqlTest extends CakeTestCase {
* @access public
*/
function testGetPrimaryKey() {
+ // When param is a model
$result = $this->db->getPrimaryKey($this->model);
$this->assertEqual($result, 'id');
@@ -361,6 +460,12 @@ class DboMssqlTest extends CakeTestCase {
$this->model->setSchema($schema);
$result = $this->db->getPrimaryKey($this->model);
$this->assertNull($result);
+
+ // When param is a table name
+ $this->db->simulate = false;
+ $this->loadFixtures('Category');
+ $result = $this->db->getPrimaryKey('categories');
+ $this->assertEqual($result, 'id');
}
/**
* testInsertMulti
diff --git a/cake/tests/cases/libs/model/datasources/dbo_source.test.php b/cake/tests/cases/libs/model/datasources/dbo_source.test.php
index 5cd392f26..943571579 100644
--- a/cake/tests/cases/libs/model/datasources/dbo_source.test.php
+++ b/cake/tests/cases/libs/model/datasources/dbo_source.test.php
@@ -1211,6 +1211,8 @@ class DboSourceTest extends CakeTestCase {
$this->testDb =& new DboTest($this->__config);
$this->testDb->cacheSources = false;
+ $this->testDb->startQuote = '`';
+ $this->testDb->endQuote = '`';
Configure::write('debug', 1);
$this->debug = Configure::read('debug');
$this->Model =& new TestModel();
@@ -1235,6 +1237,7 @@ class DboSourceTest extends CakeTestCase {
function testFieldDoubleEscaping() {
$config = array_merge($this->__config, array('driver' => 'test'));
$test =& ConnectionManager::create('quoteTest', $config);
+ $test->simulated = array();
$this->Model =& new Article2(array('alias' => 'Article', 'ds' => 'quoteTest'));
$this->Model->setDataSource('quoteTest');
From 90445e91198c668bc4e20883b7a7592143c10af7 Mon Sep 17 00:00:00 2001
From: "renan.saddam"
Date: Thu, 30 Jul 2009 00:00:19 +0000
Subject: [PATCH 09/31] Fixing "DEFAULT NULL" sentence, which for some reason
does not work. It needs to be only "NULL", and "DEFAULT NULL NULL" works too.
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@8263 3807eeeb-6ff5-0310-8944-8be069107fe0
---
cake/libs/model/datasources/dbo/dbo_mssql.php | 6 +++++-
.../cases/libs/model/datasources/dbo/dbo_mssql.test.php | 4 ++--
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/cake/libs/model/datasources/dbo/dbo_mssql.php b/cake/libs/model/datasources/dbo/dbo_mssql.php
index 4e5fb73ce..6bed2e36f 100644
--- a/cake/libs/model/datasources/dbo/dbo_mssql.php
+++ b/cake/libs/model/datasources/dbo/dbo_mssql.php
@@ -664,7 +664,11 @@ class DboMssql extends DboSource {
* @return string
*/
function buildColumn($column) {
- return preg_replace('/(int|integer)\([0-9]+\)/i', '$1', parent::buildColumn($column));
+ $column = preg_replace('/(int|integer)\([0-9]+\)/i', '$1', parent::buildColumn($column));
+ if (strpos($column, 'DEFAULT NULL') !== null) {
+ $column = str_replace('DEFAULT NULL', 'NULL', $column);
+ }
+ return $column;
}
/**
* Format indexes for create table
diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_mssql.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_mssql.test.php
index bd6060b8a..ba3f6df3b 100644
--- a/cake/tests/cases/libs/model/datasources/dbo/dbo_mssql.test.php
+++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_mssql.test.php
@@ -400,7 +400,7 @@ class DboMssqlTest extends CakeTestCase {
$column = array('name' => 'client_id', 'type' => 'integer', 'null' => true);
$result = $this->db->buildColumn($column);
- $expected = '[client_id] int DEFAULT NULL';
+ $expected = '[client_id] int NULL';
$this->assertEqual($result, $expected);
$column = array('name' => 'name', 'type' => 'string', 'null' => '', 'default' => '', 'length' => '255');
@@ -420,7 +420,7 @@ class DboMssqlTest extends CakeTestCase {
$column = array('name' => 'name', 'type' => 'string', 'null' => true, 'default' => null, 'length' => '255');
$result = $this->db->buildColumn($column);
- $expected = '[name] varchar(255) DEFAULT NULL';
+ $expected = '[name] varchar(255) NULL';
$this->assertEqual($result, $expected);
$column = array('name' => 'name', 'type' => 'string', 'null' => true, 'default' => '', 'length' => '255');
From bc28dd834e01c426eb9dc40c0488e48b1de89fbb Mon Sep 17 00:00:00 2001
From: jperras
Date: Thu, 30 Jul 2009 15:29:16 -0400
Subject: [PATCH 10/31] Adding additional plural inflection rule.
---
cake/libs/inflector.php | 2 +-
cake/tests/cases/libs/inflector.test.php | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/cake/libs/inflector.php b/cake/libs/inflector.php
index c7df92ad9..e31835057 100644
--- a/cake/libs/inflector.php
+++ b/cake/libs/inflector.php
@@ -124,7 +124,7 @@ class Inflector extends Object {
'/(alumn|bacill|cact|foc|fung|nucle|radi|stimul|syllab|termin|viri?)i$/i' => '\1us',
'/([ftw]ax)es/' => '\1',
'/(cris|ax|test)es$/i' => '\1is',
- '/(shoe)s$/i' => '\1',
+ '/(shoe|slave)s$/i' => '\1',
'/(o)es$/i' => '\1',
'/ouses$/' => 'ouse',
'/uses$/' => 'us',
diff --git a/cake/tests/cases/libs/inflector.test.php b/cake/tests/cases/libs/inflector.test.php
index 76c2debfd..f0c22cfba 100644
--- a/cake/tests/cases/libs/inflector.test.php
+++ b/cake/tests/cases/libs/inflector.test.php
@@ -99,6 +99,7 @@ class InflectorTest extends CakeTestCase {
$this->assertEqual(Inflector::singularize('lives'), 'life');
$this->assertEqual(Inflector::singularize('knives'), 'knife');
$this->assertEqual(Inflector::singularize('wolves'), 'wolf');
+ $this->assertEqual(Inflector::singularize('slaves'), 'slave');
$this->assertEqual(Inflector::singularize('shelves'), 'shelf');
$this->assertEqual(Inflector::singularize('taxis'), 'taxi');
$this->assertEqual(Inflector::singularize('taxes'), 'tax');
From 9e1dec3ff3e116259eb5e390154c0f7fff4f6aeb Mon Sep 17 00:00:00 2001
From: gwoo
Date: Fri, 31 Jul 2009 01:50:14 +0000
Subject: [PATCH 11/31] fixes #6538, xml serialization on multi dimensional
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@8264 3807eeeb-6ff5-0310-8944-8be069107fe0
---
cake/libs/xml.php | 20 ++++++++++--------
.../cases/libs/view/helpers/xml.test.php | 20 +++++++++++++++++-
cake/tests/cases/libs/xml.test.php | 21 ++++++++++++++++++-
3 files changed, 50 insertions(+), 11 deletions(-)
diff --git a/cake/libs/xml.php b/cake/libs/xml.php
index 3c79eb630..1a2048800 100644
--- a/cake/libs/xml.php
+++ b/cake/libs/xml.php
@@ -201,6 +201,7 @@ class XmlNode extends Object {
}
$tagOpts = $this->__tagOptions($name);
+
if ($tagOpts === false) {
return;
}
@@ -221,7 +222,6 @@ class XmlNode extends Object {
$attributes = array();
$children = array();
$chldObjs = array();
- $document =& $this->document();
if (is_object($object)) {
$chldObjs = get_object_vars($object);
@@ -239,7 +239,12 @@ class XmlNode extends Object {
$node->createTextNode($chldObjs[$tagOpts['value']]);
unset($chldObjs[$tagOpts['value']]);
}
- unset($chldObjs['_name_']);
+
+ $n = $name;
+ if (!empty($chldObjs['_name_'])) {
+ $n = null;
+ unset($chldObjs['_name_']);
+ }
$c = 0;
foreach ($chldObjs as $key => $val) {
@@ -247,14 +252,11 @@ class XmlNode extends Object {
$attributes[$key] = $val;
} else {
if (!isset($tagOpts['children']) || $tagOpts['children'] === array() || (is_array($tagOpts['children']) && in_array($key, $tagOpts['children']))) {
- $n = $key;
-
- if (is_numeric($n)) {
- $n = $name;
+ if (!is_numeric($key)) {
+ $n = $key;
}
if (is_array($val)) {
- foreach ($val as $i => $obj2) {
- $n2 = $i;
+ foreach ($val as $n2 => $obj2) {
if (is_numeric($n2)) {
$n2 = $n;
}
@@ -262,6 +264,7 @@ class XmlNode extends Object {
}
} else {
if (is_object($val)) {
+
$node->normalize($val, $n, $options);
} elseif ($options['format'] == 'tags' && $this->__tagOptions($key) !== false) {
$tmp =& $node->createElement($key);
@@ -630,7 +633,6 @@ class XmlNode extends Object {
if ($options['whitespace']) {
$d .= "\n";
}
-
$count = count($this->children);
$cDepth = $depth + 1;
for ($i = 0; $i < $count; $i++) {
diff --git a/cake/tests/cases/libs/view/helpers/xml.test.php b/cake/tests/cases/libs/view/helpers/xml.test.php
index 514de9495..c7b1bae73 100644
--- a/cake/tests/cases/libs/view/helpers/xml.test.php
+++ b/cake/tests/cases/libs/view/helpers/xml.test.php
@@ -202,7 +202,7 @@ class XmlHelperTest extends CakeTestCase {
$result = $this->Xml->serialize($data, array('format' => 'tags'));
$expected = '12';
$this->assertIdentical($result, $expected);
-
+
$data = array(
'Pages' => array('id' => 2, 'url' => 'http://www.url.com/rb/153/?id=bbbb&t=access')
);
@@ -210,6 +210,24 @@ class XmlHelperTest extends CakeTestCase {
$expected = '';
$this->assertIdentical($result, $expected);
}
+/**
+ * testSerializeOnMultiDimensionalArray method
+ *
+ * @access public
+ * @return void
+ */
+ function testSerializeOnMultiDimensionalArray() {
+ $data = array(
+ 'Statuses' => array(
+ array('Status' => array('id' => 1)),
+ array('Status' => array('id' => 2))
+ )
+ );
+ $result = $this->Xml->serialize($data, array('format' => 'tags'));
+ $expected = '12';
+ $this->assertIdentical($result, $expected);
+
+ }
/**
* testHeader method
*
diff --git a/cake/tests/cases/libs/xml.test.php b/cake/tests/cases/libs/xml.test.php
index 386a9d94b..e53a452e8 100644
--- a/cake/tests/cases/libs/xml.test.php
+++ b/cake/tests/cases/libs/xml.test.php
@@ -98,6 +98,25 @@ class XmlTest extends CakeTestCase {
$this->assertEqual($result, $expected);
}
+/**
+ * testSerializeOnMultiDimensionalArray method
+ *
+ * @access public
+ * @return void
+ */
+ function testSerializeOnMultiDimensionalArray() {
+ $data = array(
+ 'Statuses' => array(
+ array('Status' => array('id' => 1)),
+ array('Status' => array('id' => 2))
+ )
+ );
+ $result =& new Xml($data, array('format' => 'tags'));
+ $expected = '12';
+ $this->assertIdentical($result->toString(), $expected);
+
+ }
+
/**
* test serialization of boolean and null values. false = 0, true = 1, null = ''
*
@@ -118,7 +137,7 @@ class XmlTest extends CakeTestCase {
$result = $xml->toString(false);
$expected = '';
$this->assertEqual($result, $expected, 'Boolean values incorrectly handled. %s');
-
+
$xml =& new Xml(array('data' => array('example' => 0)));
$result = $xml->toString(false);
$expected = '';
From 76e50ef625996da0a593c3671db437b47e6b3579 Mon Sep 17 00:00:00 2001
From: "renan.saddam"
Date: Fri, 31 Jul 2009 02:08:20 +0000
Subject: [PATCH 12/31] Adding support for Model.* syntax, which translates to
a list of fields from Model. Fixing buildColumn for null values. Fixing small
containable merge, it was duplicating values, tests added.
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@8265 3807eeeb-6ff5-0310-8944-8be069107fe0
---
cake/libs/model/behaviors/containable.php | 4 +-
cake/libs/model/datasources/dbo/dbo_mssql.php | 39 +++--
cake/libs/model/datasources/dbo_source.php | 1 +
.../libs/model/behaviors/containable.test.php | 139 +++++++++---------
.../libs/model/behaviors/translate.test.php | 17 ++-
.../model/datasources/dbo/dbo_mssql.test.php | 119 +++++++++++++--
.../cases/libs/model/model_write.test.php | 8 +-
cake/tests/fixtures/uuid_tree_fixture.php | 2 +-
8 files changed, 222 insertions(+), 107 deletions(-)
diff --git a/cake/libs/model/behaviors/containable.php b/cake/libs/model/behaviors/containable.php
index edcadd51b..a602efff3 100644
--- a/cake/libs/model/behaviors/containable.php
+++ b/cake/libs/model/behaviors/containable.php
@@ -48,7 +48,7 @@ class ContainableBehavior extends ModelBehavior {
var $runtime = array();
/**
* Initiate behavior for the model using specified settings.
- *
+ *
* Available settings:
*
* - recursive: (boolean, optional) set to true to allow containable to automatically
@@ -313,7 +313,7 @@ class ContainableBehavior extends ModelBehavior {
$option = 'conditions';
$val = $Model->{$name}->alias.'.'.$key;
}
- $children[$option] = isset($children[$option]) ? array_merge((array) $children[$option], (array) $val) : $val;
+ $children[$option] = is_array($val) ? $val : array($val);
$newChildren = null;
if (!empty($name) && !empty($children[$key])) {
$newChildren = $children[$key];
diff --git a/cake/libs/model/datasources/dbo/dbo_mssql.php b/cake/libs/model/datasources/dbo/dbo_mssql.php
index 6bed2e36f..7bd0d5179 100644
--- a/cake/libs/model/datasources/dbo/dbo_mssql.php
+++ b/cake/libs/model/datasources/dbo/dbo_mssql.php
@@ -296,7 +296,8 @@ class DboMssql extends DboSource {
$fields = parent::fields($model, $alias, $fields, false);
$count = count($fields);
- if ($count >= 1 && $fields[0] != '*' && strpos($fields[0], 'COUNT(*)') === false) {
+ if ($count >= 1 && strpos($fields[0], 'COUNT(*)') === false) {
+ $result = array();
for ($i = 0; $i < $count; $i++) {
$prepend = '';
@@ -307,6 +308,19 @@ class DboMssql extends DboSource {
$fieldAlias = count($this->__fieldMappings);
if (!preg_match('/\s+AS\s+/i', $fields[$i])) {
+ if (substr($fields[$i], -1) == '*') {
+ if (strpos($fields[$i], '.') !== false && $fields[$i] != $alias . '.*') {
+ $build = explode('.', $fields[$i]);
+ $AssociatedModel = $model->{$build[0]};
+ } else {
+ $AssociatedModel = $model;
+ }
+
+ $_fields = $this->fields($AssociatedModel, $AssociatedModel->alias, array_keys($AssociatedModel->schema()));
+ $result = array_merge($result, $_fields);
+ continue;
+ }
+
if (strpos($fields[$i], '.') === false) {
$this->__fieldMappings[$alias . '__' . $fieldAlias] = $alias . '.' . $fields[$i];
$fieldName = $this->name($alias . '.' . $fields[$i]);
@@ -322,10 +336,12 @@ class DboMssql extends DboSource {
}
$fields[$i] = "{$fieldName} AS {$fieldAlias}";
}
- $fields[$i] = $prepend . $fields[$i];
+ $result[] = $prepend . $fields[$i];
}
+ return $result;
+ } else {
+ return $fields;
}
- return $fields;
}
/**
* Generates and executes an SQL INSERT statement for given model, fields, and values.
@@ -374,6 +390,9 @@ class DboMssql extends DboSource {
if (isset($fields[$model->primaryKey])) {
unset($fields[$model->primaryKey]);
}
+ if (empty($fields)) {
+ return true;
+ }
return parent::update($model, array_keys($fields), array_values($fields), $conditions);
}
/**
@@ -461,8 +480,8 @@ class DboMssql extends DboSource {
}
return $col;
}
- $col = str_replace(')', '', $real);
- $limit = null;
+ $col = str_replace(')', '', $real);
+ $limit = null;
if (strpos($col, '(') !== false) {
list($col, $limit) = explode('(', $col);
}
@@ -664,11 +683,13 @@ class DboMssql extends DboSource {
* @return string
*/
function buildColumn($column) {
- $column = preg_replace('/(int|integer)\([0-9]+\)/i', '$1', parent::buildColumn($column));
- if (strpos($column, 'DEFAULT NULL') !== null) {
- $column = str_replace('DEFAULT NULL', 'NULL', $column);
+ $result = preg_replace('/(int|integer)\([0-9]+\)/i', '$1', parent::buildColumn($column));
+ if (strpos($result, 'DEFAULT NULL') !== false) {
+ $result = str_replace('DEFAULT NULL', 'NULL', $result);
+ } else if (array_keys($column) == array('type', 'name')) {
+ $result .= ' NULL';
}
- return $column;
+ return $result;
}
/**
* Format indexes for create table
diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php
index 318593f95..98d0f6756 100644
--- a/cake/libs/model/datasources/dbo_source.php
+++ b/cake/libs/model/datasources/dbo_source.php
@@ -1405,6 +1405,7 @@ class DboSource extends DataSource {
function _prepareUpdateFields(&$model, $fields, $quoteValues = true, $alias = false) {
$quotedAlias = $this->startQuote . $model->alias . $this->endQuote;
+ $updates = array();
foreach ($fields as $field => $value) {
if ($alias && strpos($field, '.') === false) {
$quoted = $model->escapeField($field);
diff --git a/cake/tests/cases/libs/model/behaviors/containable.test.php b/cake/tests/cases/libs/model/behaviors/containable.test.php
index d7cf0d0c5..ca16f3188 100644
--- a/cake/tests/cases/libs/model/behaviors/containable.test.php
+++ b/cake/tests/cases/libs/model/behaviors/containable.test.php
@@ -1982,70 +1982,76 @@ class ContainableBehaviorTest extends CakeTestCase {
);
$this->assertEqual($result, $expected);
- $result = $this->User->find('all', array('contain' => array(
- 'ArticleFeatured' => array(
- 'title', 'order' => 'title DESC',
- 'Featured' => array(
- 'category_id',
- 'Category' => 'name'
- )
- )
- )));
- $expected = array(
- array(
- 'User' => array(
- 'id' => 1, 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99',
- 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31'
- ),
- 'ArticleFeatured' => array(
- array(
- 'title' => 'Third Article', 'id' => 3, 'user_id' => 1,
- 'Featured' => array()
- ),
- array(
- 'title' => 'First Article', 'id' => 1, 'user_id' => 1,
- 'Featured' => array(
- 'category_id' => 1, 'id' => 1,
- 'Category' => array(
- 'name' => 'Category 1'
- )
- )
- )
- )
- ),
- array(
- 'User' => array(
- 'id' => 2, 'user' => 'nate', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99',
- 'created' => '2007-03-17 01:18:23', 'updated' => '2007-03-17 01:20:31'
- ),
- 'ArticleFeatured' => array()
- ),
- array(
- 'User' => array(
- 'id' => 3, 'user' => 'larry', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99',
- 'created' => '2007-03-17 01:20:23', 'updated' => '2007-03-17 01:22:31'
- ),
- 'ArticleFeatured' => array(
- array(
- 'title' => 'Second Article', 'id' => 2, 'user_id' => 3,
- 'Featured' => array(
- 'category_id' => 1, 'id' => 2,
- 'Category' => array(
- 'name' => 'Category 1'
- )
- )
- )
- )
- ),
- array(
- 'User' => array(
- 'id' => 4, 'user' => 'garrett', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99',
- 'created' => '2007-03-17 01:22:23', 'updated' => '2007-03-17 01:24:31'
- ),
- 'ArticleFeatured' => array()
- )
+ $orders = array(
+ 'title DESC', 'title DESC, published DESC',
+ array('title' => 'DESC'), array('title' => 'DESC', 'published' => 'DESC'),
);
- $this->assertEqual($result, $expected);
+ foreach ($orders as $order) {
+ $result = $this->User->find('all', array('contain' => array(
+ 'ArticleFeatured' => array(
+ 'title', 'order' => $order,
+ 'Featured' => array(
+ 'category_id',
+ 'Category' => 'name'
+ )
+ )
+ )));
+ $expected = array(
+ array(
+ 'User' => array(
+ 'id' => 1, 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99',
+ 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31'
+ ),
+ 'ArticleFeatured' => array(
+ array(
+ 'title' => 'Third Article', 'id' => 3, 'user_id' => 1,
+ 'Featured' => array()
+ ),
+ array(
+ 'title' => 'First Article', 'id' => 1, 'user_id' => 1,
+ 'Featured' => array(
+ 'category_id' => 1, 'id' => 1,
+ 'Category' => array(
+ 'name' => 'Category 1'
+ )
+ )
+ )
+ )
+ ),
+ array(
+ 'User' => array(
+ 'id' => 2, 'user' => 'nate', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99',
+ 'created' => '2007-03-17 01:18:23', 'updated' => '2007-03-17 01:20:31'
+ ),
+ 'ArticleFeatured' => array()
+ ),
+ array(
+ 'User' => array(
+ 'id' => 3, 'user' => 'larry', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99',
+ 'created' => '2007-03-17 01:20:23', 'updated' => '2007-03-17 01:22:31'
+ ),
+ 'ArticleFeatured' => array(
+ array(
+ 'title' => 'Second Article', 'id' => 2, 'user_id' => 3,
+ 'Featured' => array(
+ 'category_id' => 1, 'id' => 2,
+ 'Category' => array(
+ 'name' => 'Category 1'
+ )
+ )
+ )
+ )
+ ),
+ array(
+ 'User' => array(
+ 'id' => 4, 'user' => 'garrett', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99',
+ 'created' => '2007-03-17 01:22:23', 'updated' => '2007-03-17 01:24:31'
+ ),
+ 'ArticleFeatured' => array()
+ )
+ );
+ $this->assertEqual($result, $expected);
+ }
}
/**
* testFindThirdLevelNonReset method
@@ -3225,7 +3231,6 @@ class ContainableBehaviorTest extends CakeTestCase {
$options = array(
'conditions' => array(
- 'Comment.comment !=' => 'Crazy',
'Comment.published' => 'Y',
),
'contain' => 'User',
@@ -3236,7 +3241,6 @@ class ContainableBehaviorTest extends CakeTestCase {
$dummyResult = $this->Article->Comment->find('all', array(
'conditions' => array(
- 'Comment.comment !=' => 'Silly',
'User.user' => 'mariano'
),
'fields' => array('User.password'),
@@ -3320,7 +3324,6 @@ class ContainableBehaviorTest extends CakeTestCase {
$initialOptions = array(
'conditions' => array(
- 'Comment.comment' => '!= Crazy',
'Comment.published' => 'Y',
),
'contain' => 'User',
@@ -3331,7 +3334,6 @@ class ContainableBehaviorTest extends CakeTestCase {
$findOptions = array(
'conditions' => array(
- 'Comment.comment !=' => 'Silly',
'User.user' => 'mariano',
),
'fields' => array('User.password'),
@@ -3409,7 +3411,8 @@ class ContainableBehaviorTest extends CakeTestCase {
'joinTable' => 'articles_tags',
'foreignKey' => 'article_id',
'associationForeignKey' => 'tag_id',
- 'conditions' => 'LENGTH(ShortTag.tag) <= 3'
+ // LENGHT function mysql-only, using LIKE does almost the same
+ 'conditions' => 'ShortTag.tag LIKE "???"'
)
)
);
diff --git a/cake/tests/cases/libs/model/behaviors/translate.test.php b/cake/tests/cases/libs/model/behaviors/translate.test.php
index 20eb3651c..3ec69f02b 100644
--- a/cake/tests/cases/libs/model/behaviors/translate.test.php
+++ b/cake/tests/cases/libs/model/behaviors/translate.test.php
@@ -427,15 +427,18 @@ class TranslateBehaviorTest extends CakeTestCase {
$expected = array(1 => 'Titel #1', 2 => 'Titel #2', 3 => 'Titel #3');
$this->assertEqual($result, $expected);
- $debug = Configure::read('debug');
- Configure::write('debug', 0);
+ // MSSQL trigger an error and stops the page even if the debug = 0
+ if ($this->db->config['driver'] != 'mssql') {
+ $debug = Configure::read('debug');
+ Configure::write('debug', 0);
- $result = $TestModel->find('list', array('recursive' => 1, 'callbacks' => false));
- $this->assertEqual($result, array());
+ $result = $TestModel->find('list', array('recursive' => 1, 'callbacks' => false));
+ $this->assertEqual($result, array());
- $result = $TestModel->find('list', array('recursive' => 1, 'callbacks' => 'after'));
- $this->assertEqual($result, array());
- Configure::write('debug', $debug);
+ $result = $TestModel->find('list', array('recursive' => 1, 'callbacks' => 'after'));
+ $this->assertEqual($result, array());
+ Configure::write('debug', $debug);
+ }
$result = $TestModel->find('list', array('recursive' => 1, 'callbacks' => 'before'));
$expected = array(1 => null, 2 => null, 3 => null);
diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_mssql.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_mssql.test.php
index ba3f6df3b..04ab3baed 100644
--- a/cake/tests/cases/libs/model/datasources/dbo/dbo_mssql.test.php
+++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_mssql.test.php
@@ -115,6 +115,15 @@ class DboMssqlTestDb extends DboMssql {
function getPrimaryKey($model) {
return parent::_getPrimaryKey($model);
}
+/**
+ * clearFieldMappings method
+ *
+ * @access public
+ * @return void
+ */
+ function clearFieldMappings() {
+ $this->__fieldMappings = array();
+ }
}
/**
* MssqlTestModel class
@@ -163,6 +172,17 @@ class MssqlTestModel extends Model {
'created' => array('type' => 'date', 'null' => '1', 'default' => '', 'length' => ''),
'updated' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null)
);
+/**
+ * belongsTo property
+ *
+ * @var array
+ * @access public
+ */
+ var $belongsTo = array(
+ 'MssqlClientTestModel' => array(
+ 'foreignKey' => 'client_id'
+ )
+ );
/**
* find method
*
@@ -200,6 +220,41 @@ class MssqlTestModel extends Model {
$this->_schema = $schema;
}
}
+/**
+ * MssqlClientTestModel class
+ *
+ * @package cake
+ * @subpackage cake.tests.cases.libs.model.datasources
+ */
+class MssqlClientTestModel extends Model {
+/**
+ * name property
+ *
+ * @var string 'MssqlAssociatedTestModel'
+ * @access public
+ */
+ var $name = 'MssqlClientTestModel';
+/**
+ * useTable property
+ *
+ * @var bool false
+ * @access public
+ */
+ var $useTable = false;
+/**
+ * _schema property
+ *
+ * @var array
+ * @access protected
+ */
+ var $_schema = array(
+ 'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8', 'key' => 'primary'),
+ 'name' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'),
+ 'email' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
+ 'created' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => ''),
+ 'updated' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null)
+ );
+}
/**
* DboMssqlTest class
*
@@ -283,8 +338,22 @@ class DboMssqlTest extends CakeTestCase {
* @return void
*/
function testQuoting() {
- $result = $this->db->fields($this->model);
- $expected = array(
+ $expected = "1.2";
+ $result = $this->db->value(1.2, 'float');
+ $this->assertIdentical($expected, $result);
+
+ $expected = "'1,2'";
+ $result = $this->db->value('1,2', 'float');
+ $this->assertIdentical($expected, $result);
+ }
+/**
+ * testFields method
+ *
+ * @access public
+ * @return void
+ */
+ function testFields() {
+ $fields = array(
'[MssqlTestModel].[id] AS [MssqlTestModel__0]',
'[MssqlTestModel].[client_id] AS [MssqlTestModel__1]',
'[MssqlTestModel].[name] AS [MssqlTestModel__2]',
@@ -304,15 +373,32 @@ class DboMssqlTest extends CakeTestCase {
'[MssqlTestModel].[created] AS [MssqlTestModel__16]',
'CONVERT(VARCHAR(20), [MssqlTestModel].[updated], 20) AS [MssqlTestModel__17]'
);
+
+ $result = $this->db->fields($this->model);
+ $expected = $fields;
$this->assertEqual($result, $expected);
- $expected = "1.2";
- $result = $this->db->value(1.2, 'float');
- $this->assertIdentical($expected, $result);
+ $this->db->clearFieldMappings();
+ $result = $this->db->fields($this->model, null, 'MssqlTestModel.*');
+ $expected = $fields;
+ $this->assertEqual($result, $expected);
- $expected = "'1,2'";
- $result = $this->db->value('1,2', 'float');
- $this->assertIdentical($expected, $result);
+ $this->db->clearFieldMappings();
+ $result = $this->db->fields($this->model, null, array('*', 'AnotherModel.id', 'AnotherModel.name'));
+ $expected = array_merge($fields, array(
+ '[AnotherModel].[id] AS [AnotherModel__18]',
+ '[AnotherModel].[name] AS [AnotherModel__19]'));
+ $this->assertEqual($result, $expected);
+
+ $this->db->clearFieldMappings();
+ $result = $this->db->fields($this->model, null, array('*', 'MssqlClientTestModel.*'));
+ $expected = array_merge($fields, array(
+ '[MssqlClientTestModel].[id] AS [MssqlClientTestModel__18]',
+ '[MssqlClientTestModel].[name] AS [MssqlClientTestModel__19]',
+ '[MssqlClientTestModel].[email] AS [MssqlClientTestModel__20]',
+ 'CONVERT(VARCHAR(20), [MssqlClientTestModel].[created], 20) AS [MssqlClientTestModel__21]',
+ 'CONVERT(VARCHAR(20), [MssqlClientTestModel].[updated], 20) AS [MssqlClientTestModel__22]'));
+ $this->assertEqual($result, $expected);
}
/**
* testDistinctFields method
@@ -392,17 +478,22 @@ class DboMssqlTest extends CakeTestCase {
$expected = '[client_id] int DEFAULT 0 NOT NULL';
$this->assertEqual($result, $expected);
- // 'name' => 'type' format
- $column = array('name' => 'client_id', 'type' => 'integer');
- $result = $this->db->buildColumn($column);
- $expected = '[client_id] int';
- $this->assertEqual($result, $expected);
-
$column = array('name' => 'client_id', 'type' => 'integer', 'null' => true);
$result = $this->db->buildColumn($column);
$expected = '[client_id] int NULL';
$this->assertEqual($result, $expected);
+ // 'name' => 'type' format for columns
+ $column = array('type' => 'integer', 'name' => 'client_id');
+ $result = $this->db->buildColumn($column);
+ $expected = '[client_id] int NULL';
+ $this->assertEqual($result, $expected);
+
+ $column = array('type' => 'string', 'name' => 'name');
+ $result = $this->db->buildColumn($column);
+ $expected = '[name] varchar(255) NULL';
+ $this->assertEqual($result, $expected);
+
$column = array('name' => 'name', 'type' => 'string', 'null' => '', 'default' => '', 'length' => '255');
$result = $this->db->buildColumn($column);
$expected = '[name] varchar(255) DEFAULT \'\' NOT NULL';
diff --git a/cake/tests/cases/libs/model/model_write.test.php b/cake/tests/cases/libs/model/model_write.test.php
index c0f45af02..1b058d44e 100644
--- a/cake/tests/cases/libs/model/model_write.test.php
+++ b/cake/tests/cases/libs/model/model_write.test.php
@@ -149,12 +149,8 @@ class ModelWriteTest extends BaseModelTest {
* @return void
*/
function testAutoSaveUuid() {
- // SQLite does not support non-integer primary keys, and SQL Server
- // is still having problems with custom PK's
- $this->skipIf(
- $this->db->config['driver'] == 'sqlite'
- || $this->db->config['driver'] == 'mssql'
- );
+ // SQLite does not support non-integer primary keys
+ $this->skipIf($this->db->config['driver'] == 'sqlite');
$this->loadFixtures('Uuid');
$TestModel =& new Uuid();
diff --git a/cake/tests/fixtures/uuid_tree_fixture.php b/cake/tests/fixtures/uuid_tree_fixture.php
index 6cc36c43b..d17ffc51c 100644
--- a/cake/tests/fixtures/uuid_tree_fixture.php
+++ b/cake/tests/fixtures/uuid_tree_fixture.php
@@ -46,7 +46,7 @@ class UuidTreeFixture extends CakeTestFixture {
var $fields = array(
'id' => array('type' => 'string', 'length' => 36, 'key' => 'primary'),
'name' => array('type' => 'string','null' => false),
- 'parent_id' => array('type' => 'string', 'length' => 36),
+ 'parent_id' => array('type' => 'string', 'length' => 36, 'null' => true),
'lft' => array('type' => 'integer','null' => false),
'rght' => array('type' => 'integer','null' => false)
);
From 878f3367d440091cd6d08900baec405dc80e8cc7 Mon Sep 17 00:00:00 2001
From: mark_story
Date: Sat, 1 Aug 2009 06:24:55 +0000
Subject: [PATCH 13/31] Updating doc block on JavascriptHelper::object().
Thanks BrendonKox. Fixes #6540.
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@8266 3807eeeb-6ff5-0310-8944-8be069107fe0
---
cake/libs/view/helpers/javascript.php | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/cake/libs/view/helpers/javascript.php b/cake/libs/view/helpers/javascript.php
index 7f4145d7c..9756d62ed 100644
--- a/cake/libs/view/helpers/javascript.php
+++ b/cake/libs/view/helpers/javascript.php
@@ -572,6 +572,15 @@ class JavascriptHelper extends AppHelper {
* Generates a JavaScript object in JavaScript Object Notation (JSON)
* from an array
*
+ * ### Options
+ *
+ * - block - Wraps the return value in a script tag if true. Default is false
+ * - prefix - Prepends the string to the returned data. Default is ''
+ * - postfix - Appends the string to the returned data. Default is ''
+ * - stringKeys - A list of array keys to be treated as a string.
+ * - quoteKeys - If false treats $stringKeys as a list of keys **not** to be quoted. Default is true.
+ * - q - The type of quote to use. Default is "'"
+ *
* @param array $data Data to be converted
* @param array $options Set of options: block, prefix, postfix, stringKeys, quoteKeys, q
* @param string $prefix DEPRECATED, use $options['prefix'] instead. Prepends the string to the returned data
From 887f8335eef0400c119cd874b718f7ca9f9d9d27 Mon Sep 17 00:00:00 2001
From: gwoo
Date: Sat, 1 Aug 2009 18:25:25 +0000
Subject: [PATCH 14/31] fixes #6539 quoting in buildIndex
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@8267 3807eeeb-6ff5-0310-8944-8be069107fe0
---
cake/libs/model/datasources/dbo_source.php | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php
index 98d0f6756..8a4d9b2bc 100644
--- a/cake/libs/model/datasources/dbo_source.php
+++ b/cake/libs/model/datasources/dbo_source.php
@@ -2388,11 +2388,12 @@ class DboSource extends DataSource {
if (!empty($value['unique'])) {
$out .= 'UNIQUE ';
}
+ $name = $this->startQuote . $name . $this->endQuote;
}
if (is_array($value['column'])) {
- $out .= 'KEY '. $name .' (' . join(', ', array_map(array(&$this, 'name'), $value['column'])) . ')';
+ $out .= 'KEY ' . $name . ' (' . join(', ', array_map(array(&$this, 'name'), $value['column'])) . ')';
} else {
- $out .= 'KEY '. $name .' (' . $this->name($value['column']) . ')';
+ $out .= 'KEY ' . $name . ' (' . $this->name($value['column']) . ')';
}
$join[] = $out;
}
From 5172035e0245f62258f537f82bbf793587d364b1 Mon Sep 17 00:00:00 2001
From: jperras
Date: Sat, 1 Aug 2009 19:40:52 +0000
Subject: [PATCH 15/31] Adding table prefix detection for sequence maps in
DboOracle::describe(). Fixes #6527.
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@8268 3807eeeb-6ff5-0310-8944-8be069107fe0
---
cake/libs/model/datasources/dbo/dbo_oracle.php | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/cake/libs/model/datasources/dbo/dbo_oracle.php b/cake/libs/model/datasources/dbo/dbo_oracle.php
index 92ffc76dd..1b87ec1a5 100644
--- a/cake/libs/model/datasources/dbo/dbo_oracle.php
+++ b/cake/libs/model/datasources/dbo/dbo_oracle.php
@@ -465,11 +465,12 @@ class DboOracle extends DboSource {
* @access public
*/
function describe(&$model) {
+ $table = $model->fullTableName($model, false);
if (!empty($model->sequence)) {
- $this->_sequenceMap[$model->table] = $model->sequence;
+ $this->_sequenceMap[$table] = $model->sequence;
} elseif (!empty($model->table)) {
- $this->_sequenceMap[$model->table] = $model->table . '_seq';
+ $this->_sequenceMap[$table] = $model->table . '_seq';
}
$cache = parent::describe($model);
@@ -477,12 +478,14 @@ class DboOracle extends DboSource {
if ($cache != null) {
return $cache;
}
+
$sql = 'SELECT COLUMN_NAME, DATA_TYPE, DATA_LENGTH FROM all_tab_columns WHERE table_name = \'';
$sql .= strtoupper($this->fullTableName($model)) . '\'';
if (!$this->execute($sql)) {
return false;
}
+
$fields = array();
for ($i = 0; $row = $this->fetchRow(); $i++) {
From b2ac7661b38c1e5668fabf5b3b977889b0849c84 Mon Sep 17 00:00:00 2001
From: mark_story
Date: Sat, 1 Aug 2009 17:49:21 -0400
Subject: [PATCH 16/31] Adding E_DEPRECATED to console environment.
---
cake/console/cake.php | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/cake/console/cake.php b/cake/console/cake.php
index 7864a82bc..5f887179c 100644
--- a/cake/console/cake.php
+++ b/cake/console/cake.php
@@ -1,7 +1,5 @@
#!/usr/bin/php -q
Date: Sat, 1 Aug 2009 17:50:03 -0400
Subject: [PATCH 17/31] Correcting path that CakeSchema looks for schema files
in.
---
cake/libs/model/cake_schema.php | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/cake/libs/model/cake_schema.php b/cake/libs/model/cake_schema.php
index 0718895ba..1a6f72587 100644
--- a/cake/libs/model/cake_schema.php
+++ b/cake/libs/model/cake_schema.php
@@ -90,7 +90,7 @@ class CakeSchema extends Object {
}
if (empty($options['path'])) {
- $this->path = CONFIGS . 'sql';
+ $this->path = CONFIGS . 'schema';
}
$options = array_merge(get_object_vars($this), $options);
@@ -161,6 +161,7 @@ class CakeSchema extends Object {
extract(get_object_vars($this));
$class = $name .'Schema';
+
if (!class_exists($class)) {
if (file_exists($path . DS . $file) && is_file($path . DS . $file)) {
require_once($path . DS . $file);
From 449c390d48e9d3a85a84d4f192850f95222f7188 Mon Sep 17 00:00:00 2001
From: mark_story
Date: Sat, 1 Aug 2009 18:57:54 -0400
Subject: [PATCH 18/31] Refactoring out Model.fk parsing. Updating create().
Adding tests.
---
cake/console/libs/acl.php | 51 +++++++++++-----------
cake/tests/cases/console/libs/acl.test.php | 50 ++++++++++++++++++++-
2 files changed, 74 insertions(+), 27 deletions(-)
diff --git a/cake/console/libs/acl.php b/cake/console/libs/acl.php
index c62f91ba3..cc7e80e31 100644
--- a/cake/console/libs/acl.php
+++ b/cake/console/libs/acl.php
@@ -137,25 +137,16 @@ class AclShell extends Shell {
* @access public
*/
function create() {
-
$this->_checkArgs(3, 'create');
$this->checkNodeType();
extract($this->__dataVars());
$class = ucfirst($this->args[0]);
- $object = new $class();
-
- if (preg_match('/^([\w]+)\.(.*)$/', $this->args[1], $matches) && count($matches) == 3) {
- $parent = array(
- 'model' => $matches[1],
- 'foreign_key' => $matches[2],
- );
- } else {
- $parent = $this->args[1];
- }
+ $object = ClassRegistry::init($class);
+ $parent = $this->parseIdentifier($this->args[1]);
if (!empty($parent) && $parent != '/' && $parent != 'root') {
- @$parent = $object->node($parent);
+ $parent = $object->node($parent);
if (empty($parent)) {
$this->err(sprintf(__('Could not find parent node using reference "%s"', true), $this->args[1]));
return;
@@ -166,22 +157,15 @@ class AclShell extends Shell {
$parent = null;
}
- if (preg_match('/^([\w]+)\.(.*)$/', $this->args[2], $matches) && count($matches) == 3) {
- $data = array(
- 'model' => $matches[1],
- 'foreign_key' => $matches[2],
- );
- } else {
- if (!($this->args[2] == '/')) {
- $data = array('alias' => $this->args[2]);
- } else {
- $this->error(__('/ can not be used as an alias!', true), __('\t/ is the root, please supply a sub alias', true));
- }
+ $data = $this->parseIdentifier($this->args[2]);
+ if (is_string($data) && !$data == '/') {
+ $data = array('alias' => $data);
+ } else if (is_string($data)) {
+ $this->error(__('/ can not be used as an alias!', true), __('\t/ is the root, please supply a sub alias', true));
}
$data['parent_id'] = $parent;
$object->create();
-
if ($object->save($data)) {
$this->out(sprintf(__("New %s '%s' created.\n", true), $class, $this->args[2]), true);
} else {
@@ -486,6 +470,23 @@ class AclShell extends Shell {
return $possibility;
}
+/**
+ * Parse an identifier into Model.foriegnKey or an alias.
+ * Takes an identifier determines its type and returns the result as used by other methods.
+ *
+ * @param string $identifier Identifier to parse
+ * @return mixed a string for aliases, and an array for model.foreignKey
+ **/
+ function parseIdentifier($identifier) {
+ if (preg_match('/^([\w]+)\.(.*)$/', $identifier, $matches)) {
+ return array(
+ 'model' => $matches[1],
+ 'foreign_key' => $matches[2],
+ );
+ }
+ return $identifier;
+ }
+
/**
* get params for standard Acl methods
*
@@ -533,7 +534,7 @@ class AclShell extends Shell {
}
$vars = array();
$class = ucwords($type);
- $vars['secondary_id'] = ife(strtolower($class) == 'aro', 'foreign_key', 'object_id');
+ $vars['secondary_id'] = (strtolower($class) == 'aro') ? 'foreign_key' : 'object_id';
$vars['data_name'] = $type;
$vars['table_name'] = $type . 's';
$vars['class'] = $class;
diff --git a/cake/tests/cases/console/libs/acl.test.php b/cake/tests/cases/console/libs/acl.test.php
index 69185f12f..30f90235b 100644
--- a/cake/tests/cases/console/libs/acl.test.php
+++ b/cake/tests/cases/console/libs/acl.test.php
@@ -49,6 +49,8 @@ Mock::generatePartial(
array('in', 'out', 'hr', 'createFile')
);
+Mock::generate('AclComponent', 'MockAclShellAclComponent');
+
/**
* AclShellTest class
*
@@ -82,7 +84,7 @@ class AclShellTest extends CakeTestCase {
}
/**
- * setUp method
+ * startTest method
*
* @return void
* @access public
@@ -95,7 +97,7 @@ class AclShellTest extends CakeTestCase {
}
/**
- * tearDown method
+ * endTest method
*
* @return void
* @access public
@@ -128,5 +130,49 @@ class AclShellTest extends CakeTestCase {
$this->Task->view();
}
+/**
+ * test the method that splits model.foreign key. and that it returns an array.
+ *
+ * @return void
+ **/
+ function testParsingModelAndForeignKey() {
+ $result = $this->Task->parseIdentifier('Model.foreignKey');
+ $expected = array('model' => 'Model', 'foreign_key' => 'foreignKey');
+
+ $result = $this->Task->parseIdentifier('mySuperUser');
+ $this->assertEqual($result, 'mySuperUser');
+
+ $result = $this->Task->parseIdentifier('111234');
+ $this->assertEqual($result, '111234');
+ }
+
+/**
+ * test creating aro/aco nodes
+ *
+ * @return void
+ **/
+ function testCreate() {
+ $this->Task->args = array('aro', 'root', 'User.1');
+ $this->Task->expectAt(0, 'out', array(new PatternExpectation('/created/'), '*'));
+ $this->Task->create();
+
+ $Aro =& ClassRegistry::init('Aro');
+ $Aro->cacheQueries = false;
+ $result = $Aro->read();
+ $this->assertEqual($result['Aro']['model'], 'User');
+ $this->assertEqual($result['Aro']['foreign_key'], 1);
+ $this->assertEqual($result['Aro']['parent_id'], null);
+ $id = $result['Aro']['id'];
+
+ $this->Task->args = array('aro', 'User.1', 'User.3');
+ $this->Task->expectAt(1, 'out', array(new PatternExpectation('/created/'), '*'));
+ $this->Task->create();
+
+ $Aro =& ClassRegistry::init('Aro');
+ $result = $Aro->read();
+ $this->assertEqual($result['Aro']['model'], 'User');
+ $this->assertEqual($result['Aro']['foreign_key'], 3);
+ $this->assertEqual($result['Aro']['parent_id'], $id);
+ }
}
?>
\ No newline at end of file
From 12e4db08100c13022e0480c0b4946b99612020d4 Mon Sep 17 00:00:00 2001
From: jperras
Date: Sat, 1 Aug 2009 23:38:26 +0000
Subject: [PATCH 19/31] Rewriting HttpSocket::parseCookies() to not use a
negative lookbehind regex, due to a bug in PCRE engine in PHP 5.1.x. Fixes
#6533.
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@8269 3807eeeb-6ff5-0310-8944-8be069107fe0
---
cake/libs/http_socket.php | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/cake/libs/http_socket.php b/cake/libs/http_socket.php
index 544de704f..76d12d710 100644
--- a/cake/libs/http_socket.php
+++ b/cake/libs/http_socket.php
@@ -852,9 +852,16 @@ class HttpSocket extends CakeSocket {
$cookies = array();
foreach ((array)$header['Set-Cookie'] as $cookie) {
- $parts = preg_split('/(?
Date: Sat, 1 Aug 2009 20:17:44 -0400
Subject: [PATCH 20/31] Updating delete() and adding test cases. Refactoring
out common methods.
---
cake/console/libs/acl.php | 44 ++++++++++++++--------
cake/tests/cases/console/libs/acl.test.php | 31 ++++++++++++++-
2 files changed, 59 insertions(+), 16 deletions(-)
diff --git a/cake/console/libs/acl.php b/cake/console/libs/acl.php
index cc7e80e31..581425041 100644
--- a/cake/console/libs/acl.php
+++ b/cake/console/libs/acl.php
@@ -142,31 +142,24 @@ class AclShell extends Shell {
extract($this->__dataVars());
$class = ucfirst($this->args[0]);
- $object = ClassRegistry::init($class);
$parent = $this->parseIdentifier($this->args[1]);
if (!empty($parent) && $parent != '/' && $parent != 'root') {
- $parent = $object->node($parent);
- if (empty($parent)) {
- $this->err(sprintf(__('Could not find parent node using reference "%s"', true), $this->args[1]));
- return;
- } else {
- $parent = Set::extract($parent, "0.{$class}.id");
- }
+ $parent = $this->_getNodeId($class, $parent);
} else {
$parent = null;
}
$data = $this->parseIdentifier($this->args[2]);
- if (is_string($data) && !$data == '/') {
+ if (is_string($data) && $data != '/') {
$data = array('alias' => $data);
- } else if (is_string($data)) {
- $this->error(__('/ can not be used as an alias!', true), __('\t/ is the root, please supply a sub alias', true));
+ } elseif (is_string($data)) {
+ $this->error(__('/ can not be used as an alias!', true), __("\t/ is the root, please supply a sub alias", true));
}
$data['parent_id'] = $parent;
- $object->create();
- if ($object->save($data)) {
+ $this->Acl->{$class}->create();
+ if ($this->Acl->{$class}->save($data)) {
$this->out(sprintf(__("New %s '%s' created.\n", true), $class, $this->args[2]), true);
} else {
$this->err(sprintf(__("There was a problem creating a new %s '%s'.", true), $class, $this->args[2]));
@@ -182,7 +175,11 @@ class AclShell extends Shell {
$this->_checkArgs(2, 'delete');
$this->checkNodeType();
extract($this->__dataVars());
- if (!$this->Acl->{$class}->delete($this->args[1])) {
+
+ $identifier = $this->parseIdentifier($this->args[1]);
+ $nodeId = $this->_getNodeId($class, $identifier);
+
+ if (!$this->Acl->{$class}->delete($nodeId)) {
$this->error(__("Node Not Deleted", true), sprintf(__("There was an error deleting the %s. Check that the node exists", true), $class) . ".\n");
}
$this->out(sprintf(__("%s deleted", true), $class) . ".\n", true);
@@ -461,7 +458,7 @@ class AclShell extends Shell {
return false;
}
extract($this->__dataVars($this->args[0]));
- $key = (ife(is_numeric($this->args[1]), $secondary_id, 'alias'));
+ $key = is_numeric($this->args[1]) ? $secondary_id : 'alias';
$conditions = array($class . '.' . $key => $this->args[1]);
$possibility = $this->Acl->{$class}->find('all', compact('conditions'));
if (empty($possibility)) {
@@ -487,6 +484,23 @@ class AclShell extends Shell {
return $identifier;
}
+/**
+ * Get the node for a given identifier. $identifier can either be a string alias
+ * or an array of properties to use in AcoNode::node()
+ *
+ * @param string $class Class type you want (Aro/Aco)
+ * @param mixed $identifier A mixed identifier for finding the node.
+ * @return int Integer of NodeId. Will trigger an error if nothing is found.
+ **/
+ function _getNodeId($class, $identifier) {
+ $node = $this->Acl->{$class}->node($identifier);
+ if (empty($node)) {
+ $this->error(sprintf(__('Could not find node using reference "%s"', true), $identifier));
+ return;
+ }
+ return Set::extract($node, "0.{$class}.id");
+ }
+
/**
* get params for standard Acl methods
*
diff --git a/cake/tests/cases/console/libs/acl.test.php b/cake/tests/cases/console/libs/acl.test.php
index 30f90235b..afe052ca3 100644
--- a/cake/tests/cases/console/libs/acl.test.php
+++ b/cake/tests/cases/console/libs/acl.test.php
@@ -46,7 +46,7 @@ Mock::generatePartial(
);
Mock::generatePartial(
'AclShell', 'MockAclShell',
- array('in', 'out', 'hr', 'createFile')
+ array('in', 'out', 'hr', 'createFile', 'error', 'err')
);
Mock::generate('AclComponent', 'MockAclShellAclComponent');
@@ -94,6 +94,9 @@ class AclShellTest extends CakeTestCase {
$this->Task =& new MockAclShell($this->Dispatcher);
$this->Task->Dispatch = new $this->Dispatcher;
$this->Task->params['datasource'] = 'test_suite';
+ $this->Task->Acl =& new AclComponent();
+ $controller = null;
+ $this->Task->Acl->startup($controller);
}
/**
@@ -173,6 +176,32 @@ class AclShellTest extends CakeTestCase {
$this->assertEqual($result['Aro']['model'], 'User');
$this->assertEqual($result['Aro']['foreign_key'], 3);
$this->assertEqual($result['Aro']['parent_id'], $id);
+
+ $this->Task->args = array('aro', 'root', 'somealias');
+ $this->Task->expectAt(2, 'out', array(new PatternExpectation('/created/'), '*'));
+ $this->Task->create();
+
+ $Aro =& ClassRegistry::init('Aro');
+ $result = $Aro->read();
+ $this->assertEqual($result['Aro']['alias'], 'somealias');
+ $this->assertEqual($result['Aro']['model'], null);
+ $this->assertEqual($result['Aro']['foreign_key'], null);
+ $this->assertEqual($result['Aro']['parent_id'], null);
+ }
+
+/**
+ * test the delete method with different node types.
+ *
+ * @return void
+ **/
+ function testDelete() {
+ $this->Task->args = array('aro', 'AuthUser.1');
+ $this->Task->expectAt(0, 'out', array(new NoPatternExpectation('/not/'), true));
+ $this->Task->delete();
+
+ $Aro =& ClassRegistry::init('Aro');
+ $result = $Aro->read(null, 3);
+ $this->assertFalse($result);
}
}
?>
\ No newline at end of file
From a599f53c63d19f3e0653cdf08e1cb60102f454d9 Mon Sep 17 00:00:00 2001
From: mark_story
Date: Sat, 1 Aug 2009 20:21:22 -0400
Subject: [PATCH 21/31] Fixing _getNodeId()
---
cake/console/libs/acl.php | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/cake/console/libs/acl.php b/cake/console/libs/acl.php
index 581425041..62d518f97 100644
--- a/cake/console/libs/acl.php
+++ b/cake/console/libs/acl.php
@@ -495,8 +495,10 @@ class AclShell extends Shell {
function _getNodeId($class, $identifier) {
$node = $this->Acl->{$class}->node($identifier);
if (empty($node)) {
+ if (is_array($identifier)) {
+ $identifier = var_export($identifier, true);
+ }
$this->error(sprintf(__('Could not find node using reference "%s"', true), $identifier));
- return;
}
return Set::extract($node, "0.{$class}.id");
}
From ca8744c8b90d46a4fbf6deeda53cc3dca2fdfa2c Mon Sep 17 00:00:00 2001
From: mark_story
Date: Sat, 1 Aug 2009 20:56:58 -0400
Subject: [PATCH 22/31] Updating setParent() to use either Model.key or alias.
Tests added.
---
cake/console/libs/acl.php | 7 +++++--
cake/tests/cases/console/libs/acl.test.php | 14 ++++++++++++++
2 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/cake/console/libs/acl.php b/cake/console/libs/acl.php
index 62d518f97..c94a1cef8 100644
--- a/cake/console/libs/acl.php
+++ b/cake/console/libs/acl.php
@@ -194,10 +194,13 @@ class AclShell extends Shell {
$this->_checkArgs(3, 'setParent');
$this->checkNodeType();
extract($this->__dataVars());
+ $target = $this->parseIdentifier($this->args[1]);
+ $parent = $this->parseIdentifier($this->args[2]);
+
$data = array(
$class => array(
- 'id' => $this->args[1],
- 'parent_id' => $this->args[2]
+ 'id' => $this->_getNodeId($class, $target),
+ 'parent_id' => $this->_getNodeId($class, $parent)
)
);
$this->Acl->{$class}->create();
diff --git a/cake/tests/cases/console/libs/acl.test.php b/cake/tests/cases/console/libs/acl.test.php
index afe052ca3..9d9a710a9 100644
--- a/cake/tests/cases/console/libs/acl.test.php
+++ b/cake/tests/cases/console/libs/acl.test.php
@@ -203,5 +203,19 @@ class AclShellTest extends CakeTestCase {
$result = $Aro->read(null, 3);
$this->assertFalse($result);
}
+
+/**
+ * test setParent method.
+ *
+ * @return void
+ **/
+ function testSetParent() {
+ $this->Task->args = array('aro', 'AuthUser.2', 'root');
+ $this->Task->setParent();
+
+ $Aro =& ClassRegistry::init('Aro');
+ $result = $Aro->read(null, 4);
+ $this->assertEqual($result['Aro']['parent_id'], null);
+ }
}
?>
\ No newline at end of file
From 1a1fef6030d728c4ff11e6e855289085b9f20259 Mon Sep 17 00:00:00 2001
From: davidpersson
Date: Sun, 2 Aug 2009 03:13:37 +0200
Subject: [PATCH 23/31] Updating commented Inflector code in app bootstrap.
---
app/config/bootstrap.php | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/app/config/bootstrap.php b/app/config/bootstrap.php
index 924147237..eb73d8dec 100644
--- a/app/config/bootstrap.php
+++ b/app/config/bootstrap.php
@@ -39,8 +39,8 @@
/**
* As of 1.3, additional rules for the inflector are added below
*
- * Inflector::rule('singular', array('rules' => array(), irregular' => array(), 'uninflected' => array()));
- * Inflector::rule('plural', array('rules' => array(), 'irregular' => array(), 'uninflected' => array()));
+ * Inflector::rules('singular', array('rules' => array(), 'irregular' => array(), 'uninflected' => array()));
+ * Inflector::rules('plural', array('rules' => array(), 'irregular' => array(), 'uninflected' => array()));
*
*/
-?>
+?>
\ No newline at end of file
From ce64f2fa6e111b481e5db9e7045c169f08c4f632 Mon Sep 17 00:00:00 2001
From: mark_story
Date: Sat, 1 Aug 2009 21:23:06 -0400
Subject: [PATCH 24/31] reformatting help() to fit on 80 col displays.
---
cake/console/libs/acl.php | 111 ++++++++++++++++++++++----------------
1 file changed, 64 insertions(+), 47 deletions(-)
diff --git a/cake/console/libs/acl.php b/cake/console/libs/acl.php
index c94a1cef8..18d73fe7c 100644
--- a/cake/console/libs/acl.php
+++ b/cake/console/libs/acl.php
@@ -362,64 +362,81 @@ class AclShell extends Shell {
* @access public
*/
function help() {
- $head = __("Usage: cake acl ...", true) . "\n";
+ $head = "-----------------------------------------------\n";
+ $head .= __("Usage: cake acl ...", true) . "\n";
$head .= "-----------------------------------------------\n";
- $head .= __("Commands:", true) . "\n\n";
+ $head .= __("Commands:", true) . "\n";
$commands = array(
- 'create' => "\tcreate aro|aco \n" .
- "\t\t" . __("Creates a new ACL object under the parent specified by , an id/alias.", true) . "\n" .
- "\t\t" . __("The and references can be in one of the following formats:", true) . "\n" .
- "\t\t\t- " . __(". - The node will be bound to a specific record of the given model", true) . "\n" .
- "\t\t\t- " . __(" - The node will be given a string alias (or path, in the case of ),", true) . "\n" .
- "\t\t\t " . __("i.e. 'John'. When used with , this takes the form of an alias path,", true) . "\n" .
- "\t\t\t " . __("i.e. //.", true) . "\n" .
- "\t\t" . __("To add a node at the root level, enter 'root' or '/' as the parameter.", true) . "\n",
+ 'create' => "create aro|aco \n" .
+ "\t" . __("Creates a new ACL object under the parent", true) . "\n" .
+ "\t" . __("specified by , an id/alias.", true) . "\n" .
+ "\t" . __("The and references can be", true) . "\n" .
+ "\t" . __("in one of the following formats:", true) . "\n\n" .
+ "\t\t- " . __(". - The node will be bound to a", true) . "\n" .
+ "\t\t" . __("specific record of the given model.", true) . "\n\n" .
+ "\t\t- " . __(" - The node will be given a string alias,", true) . "\n" .
+ "\t\t" . __(" (or path, in the case of )", true) . "\n" .
+ "\t\t " . __("i.e. 'John'. When used with ,", true) . "\n" .
+ "\t\t" . __("this takes the form of an alias path,", true) . "\n" .
+ "\t\t " . __("i.e. //.", true) . "\n\n" .
+ "\t" . __("To add a node at the root level,", true) . "\n" .
+ "\t" . __("enter 'root' or '/' as the parameter.", true) . "\n",
- 'delete' => "\tdelete aro|aco \n" .
- "\t\t" . __("Deletes the ACL object with the given reference (see 'create' for info on node references).", true) . "\n",
+ 'delete' => "delete aro|aco \n" .
+ "\t" . __("Deletes the ACL object with the given reference", true) . "\n" .
+ "\t" . __("For more detailed parameter usage info,", true) . "\n" .
+ "\t" . __("see help for the 'create' command.", true),
- 'setparent' => "\tsetParent aro|aco \n" .
- "\t\t" . __("Moves the ACL object specified by beneath the parent ACL object specified by .", true) . "\n" .
- "\t\t" . __("To identify the node and parent, use the row id.", true) . "\n",
+ 'setparent' => "setParent aro|aco \n" .
+ "\t" . __("Moves the ACL object specified by beneath", true) . "\n" .
+ "\t" . __("the parent ACL object specified by .", true) . "\n" .
+ "\t" . __("For more detailed parameter usage info,", true) . "\n" .
+ "\t" . __("see help for the 'create' command.", true),
- 'getpath' => "\tgetPath aro|aco \n" .
- "\t\t" . __("Returns the path to the ACL object specified by . This command", true) . "\n" .
- "\t\t" . __("is useful in determining the inhertiance of permissions for a certain", true) . "\n" .
- "\t\t" . __("object in the tree.", true) . "\n" .
- "\t\t" . __("For more detailed parameter usage info, see help for the 'create' command.", true) . "\n",
+ 'getpath' => "getPath aro|aco \n" .
+ "\t" . __("Returns the path to the ACL object specified by . This command", true) . "\n" .
+ "\t" . __("is useful in determining the inhertiance of permissions for a certain", true) . "\n" .
+ "\t" . __("object in the tree.", true) . "\n" .
+ "\t" . __("For more detailed parameter usage info,", true) . "\n" .
+ "\t" . __("see help for the 'create' command.", true),
- 'check' => "\tcheck [] " . __("or", true) . " all\n" .
- "\t\t" . __("Use this command to check ACL permissions.", true) . "\n" .
- "\t\t" . __("For more detailed parameter usage info, see help for the 'create' command.", true) . "\n",
+ 'check' => "check [] " . __("or", true) . " all\n" .
+ "\t" . __("Use this command to check ACL permissions.", true) . "\n" .
+ "\t" . __("For more detailed parameter usage info,", true) . "\n" .
+ "\t" . __("see help for the 'create' command.", true),
- 'grant' => "\tgrant [] " . __("or", true) . " all\n" .
- "\t\t" . __("Use this command to grant ACL permissions. Once executed, the ARO", true) . "\n" .
- "\t\t" . __("specified (and its children, if any) will have ALLOW access to the", true) . "\n" .
- "\t\t" . __("specified ACO action (and the ACO's children, if any).", true) . "\n" .
- "\t\t" . __("For more detailed parameter usage info, see help for the 'create' command.", true) . "\n",
+ 'grant' => "grant [] " . __("or", true) . " all\n" .
+ "\t" . __("Use this command to grant ACL permissions. Once executed, the ARO", true) . "\n" .
+ "\t" . __("specified (and its children, if any) will have ALLOW access to the", true) . "\n" .
+ "\t" . __("specified ACO action (and the ACO's children, if any).", true) . "\n" .
+ "\t" . __("For more detailed parameter usage info,", true) . "\n" .
+ "\t" . __("see help for the 'create' command.", true),
- 'deny' => "\tdeny []" . __("or", true) . " all\n" .
- "\t\t" . __("Use this command to deny ACL permissions. Once executed, the ARO", true) . "\n" .
- "\t\t" . __("specified (and its children, if any) will have DENY access to the", true) . "\n" .
- "\t\t" . __("specified ACO action (and the ACO's children, if any).", true) . "\n" .
- "\t\t" . __("For more detailed parameter usage info, see help for the 'create' command.", true) . "\n",
+ 'deny' => "deny []" . __("or", true) . " all\n" .
+ "\t" . __("Use this command to deny ACL permissions. Once executed, the ARO", true) . "\n" .
+ "\t" . __("specified (and its children, if any) will have DENY access to the", true) . "\n" .
+ "\t" . __("specified ACO action (and the ACO's children, if any).", true) . "\n" .
+ "\t" . __("For more detailed parameter usage info,", true) . "\n" .
+ "\t" . __("see help for the 'create' command.", true),
- 'inherit' => "\tinherit []" . __("or", true) . " all\n" .
- "\t\t" . __("Use this command to force a child ARO object to inherit its", true) . "\n" .
- "\t\t" . __("permissions settings from its parent.", true) . "\n" .
- "\t\t" . __("For more detailed parameter usage info, see help for the 'create' command.", true) . "\n",
+ 'inherit' => "inherit []" . __("or", true) . " all\n" .
+ "\t" . __("Use this command to force a child ARO object to inherit its", true) . "\n" .
+ "\t" . __("permissions settings from its parent.", true) . "\n" .
+ "\t" . __("For more detailed parameter usage info,", true) . "\n" .
+ "\t" . __("see help for the 'create' command.", true),
- 'view' => "\tview aro|aco []\n" .
- "\t\t" . __("The view command will return the ARO or ACO tree. The optional", true) . "\n" .
- "\t\t" . __("id/alias parameter allows you to return only a portion of the requested tree.", true) . "\n" .
- "\t\t" . __("For more detailed parameter usage info, see help for the 'create' command.", true) . "\n",
+ 'view' => "view aro|aco []\n" .
+ "\t" . __("The view command will return the ARO or ACO tree.", true) . "\n" .
+ "\t" . __("The optional id/alias parameter allows you to return\n\tonly a portion of the requested tree.", true) . "\n" .
+ "\t" . __("For more detailed parameter usage info,", true) . "\n" .
+ "\t" . __("see help for the 'create' command.", true),
- 'initdb' => "\tinitdb\n".
- "\t\t" . __("Uses this command : cake schema run create DbAcl", true) . "\n",
+ 'initdb' => "initdb\n".
+ "\t" . __("Uses this command : cake schema run create DbAcl", true),
- 'help' => "\thelp []\n" .
- "\t\t" . __("Displays this help message, or a message on a specific command.", true) . "\n"
+ 'help' => "help []\n" .
+ "\t" . __("Displays this help message, or a message on a specific command.", true)
);
$this->out($head);
@@ -427,8 +444,8 @@ class AclShell extends Shell {
foreach ($commands as $cmd) {
$this->out("{$cmd}\n\n");
}
- } elseif (isset($commands[low($this->args[0])])) {
- $this->out($commands[low($this->args[0])] . "\n\n");
+ } elseif (isset($commands[strtolower($this->args[0])])) {
+ $this->out($commands[strtolower($this->args[0])] . "\n\n");
} else {
$this->out(sprintf(__("Command '%s' not found", true), $this->args[0]));
}
From 38221e7aa29ff742c9d66161ed4815b2cda2f1fb Mon Sep 17 00:00:00 2001
From: gwoo
Date: Sat, 1 Aug 2009 23:47:28 -0700
Subject: [PATCH 25/31] Merge branch '1.2' into 1.3
---
cake/libs/http_socket.php | 9 +-
cake/libs/model/behaviors/containable.php | 2 +-
cake/libs/model/datasources/dbo/dbo_mssql.php | 51 +++--
.../libs/model/datasources/dbo/dbo_oracle.php | 7 +-
cake/libs/model/datasources/dbo_source.php | 6 +-
cake/libs/view/helpers/javascript.php | 9 +
cake/libs/xml.php | 20 +-
.../cases/libs/cake_test_fixture.test.php | 6 +-
.../libs/model/behaviors/containable.test.php | 139 +++++------
.../libs/model/behaviors/translate.test.php | 17 +-
.../model/datasources/dbo/dbo_mssql.test.php | 216 +++++++++++++++++-
.../model/datasources/dbo_source.test.php | 3 +
.../cases/libs/model/model_write.test.php | 8 +-
.../cases/libs/view/helpers/xml.test.php | 20 +-
cake/tests/cases/libs/xml.test.php | 19 ++
cake/tests/fixtures/uuid_tree_fixture.php | 2 +-
16 files changed, 404 insertions(+), 130 deletions(-)
diff --git a/cake/libs/http_socket.php b/cake/libs/http_socket.php
index 58e5bc152..b2af778a7 100644
--- a/cake/libs/http_socket.php
+++ b/cake/libs/http_socket.php
@@ -877,9 +877,16 @@ class HttpSocket extends CakeSocket {
$cookies = array();
foreach ((array)$header['Set-Cookie'] as $cookie) {
- $parts = preg_split('/(?{$name}->alias.'.'.$key;
}
- $children[$option] = isset($children[$option]) ? array_merge((array) $children[$option], (array) $val) : $val;
+ $children[$option] = is_array($val) ? $val : array($val);
$newChildren = null;
if (!empty($name) && !empty($children[$key])) {
$newChildren = $children[$key];
diff --git a/cake/libs/model/datasources/dbo/dbo_mssql.php b/cake/libs/model/datasources/dbo/dbo_mssql.php
index cb3932e3e..56911273b 100644
--- a/cake/libs/model/datasources/dbo/dbo_mssql.php
+++ b/cake/libs/model/datasources/dbo/dbo_mssql.php
@@ -226,9 +226,10 @@ class DboMssql extends DboSource {
return $cache;
}
- $fields = false;
- $cols = $this->fetchAll("SELECT COLUMN_NAME as Field, DATA_TYPE as Type, COL_LENGTH('" . $this->fullTableName($model, false) . "', COLUMN_NAME) as Length, IS_NULLABLE As [Null], COLUMN_DEFAULT as [Default], COLUMNPROPERTY(OBJECT_ID('" . $this->fullTableName($model, false) . "'), COLUMN_NAME, 'IsIdentity') as [Key], NUMERIC_SCALE as Size FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = '" . $this->fullTableName($model, false) . "'", false);
+ $table = $this->fullTableName($model, false);
+ $cols = $this->fetchAll("SELECT COLUMN_NAME as Field, DATA_TYPE as Type, COL_LENGTH('" . $table . "', COLUMN_NAME) as Length, IS_NULLABLE As [Null], COLUMN_DEFAULT as [Default], COLUMNPROPERTY(OBJECT_ID('" . $table . "'), COLUMN_NAME, 'IsIdentity') as [Key], NUMERIC_SCALE as Size FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = '" . $table . "'", false);
+ $fields = false;
foreach ($cols as $column) {
$field = $column[0]['Field'];
$fields[$field] = array(
@@ -312,7 +313,8 @@ class DboMssql extends DboSource {
$fields = parent::fields($model, $alias, $fields, false);
$count = count($fields);
- if ($count >= 1 && $fields[0] != '*' && strpos($fields[0], 'COUNT(*)') === false) {
+ if ($count >= 1 && strpos($fields[0], 'COUNT(*)') === false) {
+ $result = array();
for ($i = 0; $i < $count; $i++) {
$prepend = '';
@@ -323,6 +325,19 @@ class DboMssql extends DboSource {
$fieldAlias = count($this->__fieldMappings);
if (!preg_match('/\s+AS\s+/i', $fields[$i])) {
+ if (substr($fields[$i], -1) == '*') {
+ if (strpos($fields[$i], '.') !== false && $fields[$i] != $alias . '.*') {
+ $build = explode('.', $fields[$i]);
+ $AssociatedModel = $model->{$build[0]};
+ } else {
+ $AssociatedModel = $model;
+ }
+
+ $_fields = $this->fields($AssociatedModel, $AssociatedModel->alias, array_keys($AssociatedModel->schema()));
+ $result = array_merge($result, $_fields);
+ continue;
+ }
+
if (strpos($fields[$i], '.') === false) {
$this->__fieldMappings[$alias . '__' . $fieldAlias] = $alias . '.' . $fields[$i];
$fieldName = $this->name($alias . '.' . $fields[$i]);
@@ -338,10 +353,12 @@ class DboMssql extends DboSource {
}
$fields[$i] = "{$fieldName} AS {$fieldAlias}";
}
- $fields[$i] = $prepend . $fields[$i];
+ $result[] = $prepend . $fields[$i];
}
+ return $result;
+ } else {
+ return $fields;
}
- return $fields;
}
/**
@@ -392,6 +409,9 @@ class DboMssql extends DboSource {
if (isset($fields[$model->primaryKey])) {
unset($fields[$model->primaryKey]);
}
+ if (empty($fields)) {
+ return true;
+ }
return parent::update($model, array_keys($fields), array_values($fields), $conditions);
}
@@ -485,8 +505,8 @@ class DboMssql extends DboSource {
}
return $col;
}
- $col = str_replace(')', '', $real);
- $limit = null;
+ $col = str_replace(')', '', $real);
+ $limit = null;
if (strpos($col, '(') !== false) {
list($col, $limit) = explode('(', $col);
}
@@ -692,21 +712,15 @@ class DboMssql extends DboSource {
* Generate a database-native column schema string
*
* @param array $column An array structured like the following: array('name'=>'value', 'type'=>'value'[, options]),
- * where options can be 'default', 'length', or 'key'.
+ * where options can be 'default', 'length', or 'key'.
* @return string
*/
function buildColumn($column) {
$result = preg_replace('/(int|integer)\([0-9]+\)/i', '$1', parent::buildColumn($column));
- $null = (
- (isset($column['null']) && $column['null'] == true) ||
- (array_key_exists('default', $column) && $column['default'] === null) ||
- (array_keys($column) == array('type', 'name'))
- );
- $primaryKey = (isset($column['key']) && $column['key'] == 'primary');
- $stringKey = ($primaryKey && $column['type'] != 'integer');
-
- if ($null && !$primaryKey) {
- $result .= " NULL";
+ if (strpos($result, 'DEFAULT NULL') !== false) {
+ $result = str_replace('DEFAULT NULL', 'NULL', $result);
+ } else if (array_keys($column) == array('type', 'name')) {
+ $result .= ' NULL';
}
return $result;
}
@@ -758,7 +772,6 @@ class DboMssql extends DboSource {
return $field;
}
}
-
return null;
}
}
diff --git a/cake/libs/model/datasources/dbo/dbo_oracle.php b/cake/libs/model/datasources/dbo/dbo_oracle.php
index 5c19c709c..54f2811da 100644
--- a/cake/libs/model/datasources/dbo/dbo_oracle.php
+++ b/cake/libs/model/datasources/dbo/dbo_oracle.php
@@ -497,11 +497,12 @@ class DboOracle extends DboSource {
* @access public
*/
function describe(&$model) {
+ $table = $model->fullTableName($model, false);
if (!empty($model->sequence)) {
- $this->_sequenceMap[$model->table] = $model->sequence;
+ $this->_sequenceMap[$table] = $model->sequence;
} elseif (!empty($model->table)) {
- $this->_sequenceMap[$model->table] = $model->table . '_seq';
+ $this->_sequenceMap[$table] = $model->table . '_seq';
}
$cache = parent::describe($model);
@@ -509,12 +510,14 @@ class DboOracle extends DboSource {
if ($cache != null) {
return $cache;
}
+
$sql = 'SELECT COLUMN_NAME, DATA_TYPE, DATA_LENGTH FROM all_tab_columns WHERE table_name = \'';
$sql .= strtoupper($this->fullTableName($model)) . '\'';
if (!$this->execute($sql)) {
return false;
}
+
$fields = array();
for ($i = 0; $row = $this->fetchRow(); $i++) {
diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php
index 201fe3c49..a62f9b190 100644
--- a/cake/libs/model/datasources/dbo_source.php
+++ b/cake/libs/model/datasources/dbo_source.php
@@ -1447,6 +1447,7 @@ class DboSource extends DataSource {
function _prepareUpdateFields(&$model, $fields, $quoteValues = true, $alias = false) {
$quotedAlias = $this->startQuote . $model->alias . $this->endQuote;
+ $updates = array();
foreach ($fields as $field => $value) {
if ($alias && strpos($field, '.') === false) {
$quoted = $model->escapeField($field);
@@ -2459,11 +2460,12 @@ class DboSource extends DataSource {
if (!empty($value['unique'])) {
$out .= 'UNIQUE ';
}
+ $name = $this->startQuote . $name . $this->endQuote;
}
if (is_array($value['column'])) {
- $out .= 'KEY '. $name .' (' . join(', ', array_map(array(&$this, 'name'), $value['column'])) . ')';
+ $out .= 'KEY ' . $name . ' (' . join(', ', array_map(array(&$this, 'name'), $value['column'])) . ')';
} else {
- $out .= 'KEY '. $name .' (' . $this->name($value['column']) . ')';
+ $out .= 'KEY ' . $name . ' (' . $this->name($value['column']) . ')';
}
$join[] = $out;
}
diff --git a/cake/libs/view/helpers/javascript.php b/cake/libs/view/helpers/javascript.php
index ba2c5a383..ff439571e 100644
--- a/cake/libs/view/helpers/javascript.php
+++ b/cake/libs/view/helpers/javascript.php
@@ -598,6 +598,15 @@ class JavascriptHelper extends AppHelper {
* Generates a JavaScript object in JavaScript Object Notation (JSON)
* from an array
*
+ * ### Options
+ *
+ * - block - Wraps the return value in a script tag if true. Default is false
+ * - prefix - Prepends the string to the returned data. Default is ''
+ * - postfix - Appends the string to the returned data. Default is ''
+ * - stringKeys - A list of array keys to be treated as a string.
+ * - quoteKeys - If false treats $stringKeys as a list of keys **not** to be quoted. Default is true.
+ * - q - The type of quote to use. Default is "'"
+ *
* @param array $data Data to be converted
* @param array $options Set of options: block, prefix, postfix, stringKeys, quoteKeys, q
* @param string $prefix DEPRECATED, use $options['prefix'] instead. Prepends the string to the returned data
diff --git a/cake/libs/xml.php b/cake/libs/xml.php
index 3d908bea6..7aa0aa860 100644
--- a/cake/libs/xml.php
+++ b/cake/libs/xml.php
@@ -216,6 +216,7 @@ class XmlNode extends Object {
}
$tagOpts = $this->__tagOptions($name);
+
if ($tagOpts === false) {
return;
}
@@ -236,7 +237,6 @@ class XmlNode extends Object {
$attributes = array();
$children = array();
$chldObjs = array();
- $document =& $this->document();
if (is_object($object)) {
$chldObjs = get_object_vars($object);
@@ -254,7 +254,12 @@ class XmlNode extends Object {
$node->createTextNode($chldObjs[$tagOpts['value']]);
unset($chldObjs[$tagOpts['value']]);
}
- unset($chldObjs['_name_']);
+
+ $n = $name;
+ if (!empty($chldObjs['_name_'])) {
+ $n = null;
+ unset($chldObjs['_name_']);
+ }
$c = 0;
foreach ($chldObjs as $key => $val) {
@@ -262,14 +267,11 @@ class XmlNode extends Object {
$attributes[$key] = $val;
} else {
if (!isset($tagOpts['children']) || $tagOpts['children'] === array() || (is_array($tagOpts['children']) && in_array($key, $tagOpts['children']))) {
- $n = $key;
-
- if (is_numeric($n)) {
- $n = $name;
+ if (!is_numeric($key)) {
+ $n = $key;
}
if (is_array($val)) {
- foreach ($val as $i => $obj2) {
- $n2 = $i;
+ foreach ($val as $n2 => $obj2) {
if (is_numeric($n2)) {
$n2 = $n;
}
@@ -277,6 +279,7 @@ class XmlNode extends Object {
}
} else {
if (is_object($val)) {
+
$node->normalize($val, $n, $options);
} elseif ($options['format'] == 'tags' && $this->__tagOptions($key) !== false) {
$tmp =& $node->createElement($key);
@@ -661,7 +664,6 @@ class XmlNode extends Object {
if ($options['whitespace']) {
$d .= "\n";
}
-
$count = count($this->children);
$cDepth = $depth + 1;
for ($i = 0; $i < $count; $i++) {
diff --git a/cake/tests/cases/libs/cake_test_fixture.test.php b/cake/tests/cases/libs/cake_test_fixture.test.php
index 1c4d166a3..139b5b5be 100644
--- a/cake/tests/cases/libs/cake_test_fixture.test.php
+++ b/cake/tests/cases/libs/cake_test_fixture.test.php
@@ -66,9 +66,9 @@ class CakeTestFixtureTestFixture extends CakeTestFixture {
* @var array
*/
var $records = array(
- array('name' => 'Gandalf'),
- array('name' => 'Captain Picard'),
- array('name' => 'Chewbacca')
+ array('name' => 'Gandalf', 'created' => '2009-04-28 19:20:00'),
+ array('name' => 'Captain Picard', 'created' => '2009-04-28 19:20:00'),
+ array('name' => 'Chewbacca', 'created' => '2009-04-28 19:20:00')
);
}
diff --git a/cake/tests/cases/libs/model/behaviors/containable.test.php b/cake/tests/cases/libs/model/behaviors/containable.test.php
index 6601ae1c1..17ee4c330 100644
--- a/cake/tests/cases/libs/model/behaviors/containable.test.php
+++ b/cake/tests/cases/libs/model/behaviors/containable.test.php
@@ -1999,70 +1999,76 @@ class ContainableBehaviorTest extends CakeTestCase {
);
$this->assertEqual($result, $expected);
- $result = $this->User->find('all', array('contain' => array(
- 'ArticleFeatured' => array(
- 'title', 'order' => 'title DESC',
- 'Featured' => array(
- 'category_id',
- 'Category' => 'name'
- )
- )
- )));
- $expected = array(
- array(
- 'User' => array(
- 'id' => 1, 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99',
- 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31'
- ),
- 'ArticleFeatured' => array(
- array(
- 'title' => 'Third Article', 'id' => 3, 'user_id' => 1,
- 'Featured' => array()
- ),
- array(
- 'title' => 'First Article', 'id' => 1, 'user_id' => 1,
- 'Featured' => array(
- 'category_id' => 1, 'id' => 1,
- 'Category' => array(
- 'name' => 'Category 1'
- )
- )
- )
- )
- ),
- array(
- 'User' => array(
- 'id' => 2, 'user' => 'nate', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99',
- 'created' => '2007-03-17 01:18:23', 'updated' => '2007-03-17 01:20:31'
- ),
- 'ArticleFeatured' => array()
- ),
- array(
- 'User' => array(
- 'id' => 3, 'user' => 'larry', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99',
- 'created' => '2007-03-17 01:20:23', 'updated' => '2007-03-17 01:22:31'
- ),
- 'ArticleFeatured' => array(
- array(
- 'title' => 'Second Article', 'id' => 2, 'user_id' => 3,
- 'Featured' => array(
- 'category_id' => 1, 'id' => 2,
- 'Category' => array(
- 'name' => 'Category 1'
- )
- )
- )
- )
- ),
- array(
- 'User' => array(
- 'id' => 4, 'user' => 'garrett', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99',
- 'created' => '2007-03-17 01:22:23', 'updated' => '2007-03-17 01:24:31'
- ),
- 'ArticleFeatured' => array()
- )
+ $orders = array(
+ 'title DESC', 'title DESC, published DESC',
+ array('title' => 'DESC'), array('title' => 'DESC', 'published' => 'DESC'),
);
- $this->assertEqual($result, $expected);
+ foreach ($orders as $order) {
+ $result = $this->User->find('all', array('contain' => array(
+ 'ArticleFeatured' => array(
+ 'title', 'order' => $order,
+ 'Featured' => array(
+ 'category_id',
+ 'Category' => 'name'
+ )
+ )
+ )));
+ $expected = array(
+ array(
+ 'User' => array(
+ 'id' => 1, 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99',
+ 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31'
+ ),
+ 'ArticleFeatured' => array(
+ array(
+ 'title' => 'Third Article', 'id' => 3, 'user_id' => 1,
+ 'Featured' => array()
+ ),
+ array(
+ 'title' => 'First Article', 'id' => 1, 'user_id' => 1,
+ 'Featured' => array(
+ 'category_id' => 1, 'id' => 1,
+ 'Category' => array(
+ 'name' => 'Category 1'
+ )
+ )
+ )
+ )
+ ),
+ array(
+ 'User' => array(
+ 'id' => 2, 'user' => 'nate', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99',
+ 'created' => '2007-03-17 01:18:23', 'updated' => '2007-03-17 01:20:31'
+ ),
+ 'ArticleFeatured' => array()
+ ),
+ array(
+ 'User' => array(
+ 'id' => 3, 'user' => 'larry', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99',
+ 'created' => '2007-03-17 01:20:23', 'updated' => '2007-03-17 01:22:31'
+ ),
+ 'ArticleFeatured' => array(
+ array(
+ 'title' => 'Second Article', 'id' => 2, 'user_id' => 3,
+ 'Featured' => array(
+ 'category_id' => 1, 'id' => 2,
+ 'Category' => array(
+ 'name' => 'Category 1'
+ )
+ )
+ )
+ )
+ ),
+ array(
+ 'User' => array(
+ 'id' => 4, 'user' => 'garrett', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99',
+ 'created' => '2007-03-17 01:22:23', 'updated' => '2007-03-17 01:24:31'
+ ),
+ 'ArticleFeatured' => array()
+ )
+ );
+ $this->assertEqual($result, $expected);
+ }
}
/**
@@ -3249,7 +3255,6 @@ class ContainableBehaviorTest extends CakeTestCase {
$options = array(
'conditions' => array(
- 'Comment.comment !=' => 'Crazy',
'Comment.published' => 'Y',
),
'contain' => 'User',
@@ -3260,7 +3265,6 @@ class ContainableBehaviorTest extends CakeTestCase {
$dummyResult = $this->Article->Comment->find('all', array(
'conditions' => array(
- 'Comment.comment !=' => 'Silly',
'User.user' => 'mariano'
),
'fields' => array('User.password'),
@@ -3345,7 +3349,6 @@ class ContainableBehaviorTest extends CakeTestCase {
$initialOptions = array(
'conditions' => array(
- 'Comment.comment' => '!= Crazy',
'Comment.published' => 'Y',
),
'contain' => 'User',
@@ -3356,7 +3359,6 @@ class ContainableBehaviorTest extends CakeTestCase {
$findOptions = array(
'conditions' => array(
- 'Comment.comment !=' => 'Silly',
'User.user' => 'mariano',
),
'fields' => array('User.password'),
@@ -3436,7 +3438,8 @@ class ContainableBehaviorTest extends CakeTestCase {
'joinTable' => 'articles_tags',
'foreignKey' => 'article_id',
'associationForeignKey' => 'tag_id',
- 'conditions' => 'LENGTH(ShortTag.tag) <= 3'
+ // LENGHT function mysql-only, using LIKE does almost the same
+ 'conditions' => 'ShortTag.tag LIKE "???"'
)
)
);
diff --git a/cake/tests/cases/libs/model/behaviors/translate.test.php b/cake/tests/cases/libs/model/behaviors/translate.test.php
index a8d50bd46..2c75ca9c5 100644
--- a/cake/tests/cases/libs/model/behaviors/translate.test.php
+++ b/cake/tests/cases/libs/model/behaviors/translate.test.php
@@ -441,15 +441,18 @@ class TranslateBehaviorTest extends CakeTestCase {
$expected = array(1 => 'Titel #1', 2 => 'Titel #2', 3 => 'Titel #3');
$this->assertEqual($result, $expected);
- $debug = Configure::read('debug');
- Configure::write('debug', 0);
+ // MSSQL trigger an error and stops the page even if the debug = 0
+ if ($this->db->config['driver'] != 'mssql') {
+ $debug = Configure::read('debug');
+ Configure::write('debug', 0);
- $result = $TestModel->find('list', array('recursive' => 1, 'callbacks' => false));
- $this->assertEqual($result, array());
+ $result = $TestModel->find('list', array('recursive' => 1, 'callbacks' => false));
+ $this->assertEqual($result, array());
- $result = $TestModel->find('list', array('recursive' => 1, 'callbacks' => 'after'));
- $this->assertEqual($result, array());
- Configure::write('debug', $debug);
+ $result = $TestModel->find('list', array('recursive' => 1, 'callbacks' => 'after'));
+ $this->assertEqual($result, array());
+ Configure::write('debug', $debug);
+ }
$result = $TestModel->find('list', array('recursive' => 1, 'callbacks' => 'before'));
$expected = array(1 => null, 2 => null, 3 => null);
diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_mssql.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_mssql.test.php
index fec6782b1..5aa9c0606 100644
--- a/cake/tests/cases/libs/model/datasources/dbo/dbo_mssql.test.php
+++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_mssql.test.php
@@ -47,6 +47,13 @@ class DboMssqlTestDb extends DboMssql {
*/
var $simulated = array();
+/**
+ * simalate property
+ *
+ * @var array
+ * @access public
+ */
+ var $simulate = true;
/**
* fetchAllResultsStack
*
@@ -63,8 +70,12 @@ class DboMssqlTestDb extends DboMssql {
* @return void
*/
function _execute($sql) {
- $this->simulated[] = $sql;
- return null;
+ if ($this->simulate) {
+ $this->simulated[] = $sql;
+ return null;
+ } else {
+ return parent::_execute($sql);
+ }
}
/**
@@ -113,6 +124,15 @@ class DboMssqlTestDb extends DboMssql {
function getPrimaryKey($model) {
return parent::_getPrimaryKey($model);
}
+/**
+ * clearFieldMappings method
+ *
+ * @access public
+ * @return void
+ */
+ function clearFieldMappings() {
+ $this->__fieldMappings = array();
+ }
}
/**
@@ -166,6 +186,17 @@ class MssqlTestModel extends Model {
'updated' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null)
);
+/**
+ * belongsTo property
+ *
+ * @var array
+ * @access public
+ */
+ var $belongsTo = array(
+ 'MssqlClientTestModel' => array(
+ 'foreignKey' => 'client_id'
+ )
+ );
/**
* find method
*
@@ -206,6 +237,41 @@ class MssqlTestModel extends Model {
}
}
+/**
+ * MssqlClientTestModel class
+ *
+ * @package cake
+ * @subpackage cake.tests.cases.libs.model.datasources
+ */
+class MssqlClientTestModel extends Model {
+/**
+ * name property
+ *
+ * @var string 'MssqlAssociatedTestModel'
+ * @access public
+ */
+ var $name = 'MssqlClientTestModel';
+/**
+ * useTable property
+ *
+ * @var bool false
+ * @access public
+ */
+ var $useTable = false;
+/**
+ * _schema property
+ *
+ * @var array
+ * @access protected
+ */
+ var $_schema = array(
+ 'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8', 'key' => 'primary'),
+ 'name' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'),
+ 'email' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
+ 'created' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => ''),
+ 'updated' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null)
+ );
+}
/**
* DboMssqlTest class
*
@@ -222,6 +288,20 @@ class DboMssqlTest extends CakeTestCase {
*/
var $db = null;
+/**
+ * autoFixtures property
+ *
+ * @var bool false
+ * @access public
+ */
+ var $autoFixtures = false;
+/**
+ * fixtures property
+ *
+ * @var array
+ * @access public
+ */
+ var $fixtures = array('core.category');
/**
* Skip if cannot connect to mssql
*
@@ -232,6 +312,26 @@ class DboMssqlTest extends CakeTestCase {
$this->skipUnless($this->db->config['driver'] == 'mssql', '%s SQL Server connection not available');
}
+/**
+ * Make sure all fixtures tables are being created
+ *
+ * @access public
+ */
+ function start() {
+ $this->db->simulate = false;
+ parent::start();
+ $this->db->simulate = true;
+ }
+/**
+ * Make sure all fixtures tables are being dropped
+ *
+ * @access public
+ */
+ function end() {
+ $this->db->simulate = false;
+ parent::end();
+ $this->db->simulate = true;
+ }
/**
* Sets up a Dbo class instance for testing
*
@@ -260,8 +360,22 @@ class DboMssqlTest extends CakeTestCase {
* @return void
*/
function testQuoting() {
- $result = $this->db->fields($this->model);
- $expected = array(
+ $expected = "1.2";
+ $result = $this->db->value(1.2, 'float');
+ $this->assertIdentical($expected, $result);
+
+ $expected = "'1,2'";
+ $result = $this->db->value('1,2', 'float');
+ $this->assertIdentical($expected, $result);
+ }
+/**
+ * testFields method
+ *
+ * @access public
+ * @return void
+ */
+ function testFields() {
+ $fields = array(
'[MssqlTestModel].[id] AS [MssqlTestModel__0]',
'[MssqlTestModel].[client_id] AS [MssqlTestModel__1]',
'[MssqlTestModel].[name] AS [MssqlTestModel__2]',
@@ -281,15 +395,32 @@ class DboMssqlTest extends CakeTestCase {
'[MssqlTestModel].[created] AS [MssqlTestModel__16]',
'CONVERT(VARCHAR(20), [MssqlTestModel].[updated], 20) AS [MssqlTestModel__17]'
);
+
+ $result = $this->db->fields($this->model);
+ $expected = $fields;
$this->assertEqual($result, $expected);
- $expected = "1.2";
- $result = $this->db->value(1.2, 'float');
- $this->assertIdentical($expected, $result);
+ $this->db->clearFieldMappings();
+ $result = $this->db->fields($this->model, null, 'MssqlTestModel.*');
+ $expected = $fields;
+ $this->assertEqual($result, $expected);
- $expected = "'1,2'";
- $result = $this->db->value('1,2', 'float');
- $this->assertIdentical($expected, $result);
+ $this->db->clearFieldMappings();
+ $result = $this->db->fields($this->model, null, array('*', 'AnotherModel.id', 'AnotherModel.name'));
+ $expected = array_merge($fields, array(
+ '[AnotherModel].[id] AS [AnotherModel__18]',
+ '[AnotherModel].[name] AS [AnotherModel__19]'));
+ $this->assertEqual($result, $expected);
+
+ $this->db->clearFieldMappings();
+ $result = $this->db->fields($this->model, null, array('*', 'MssqlClientTestModel.*'));
+ $expected = array_merge($fields, array(
+ '[MssqlClientTestModel].[id] AS [MssqlClientTestModel__18]',
+ '[MssqlClientTestModel].[name] AS [MssqlClientTestModel__19]',
+ '[MssqlClientTestModel].[email] AS [MssqlClientTestModel__20]',
+ 'CONVERT(VARCHAR(20), [MssqlClientTestModel].[created], 20) AS [MssqlClientTestModel__21]',
+ 'CONVERT(VARCHAR(20), [MssqlClientTestModel].[updated], 20) AS [MssqlClientTestModel__22]'));
+ $this->assertEqual($result, $expected);
}
/**
@@ -356,6 +487,64 @@ class DboMssqlTest extends CakeTestCase {
$this->assertEqual($result, $expected);
}
+/**
+ * testBuildColumn
+ *
+ * @return unknown_type
+ * @access public
+ */
+ function testBuildColumn() {
+ $column = array('name' => 'id', 'type' => 'integer', 'null' => '', 'default' => '', 'length' => '8', 'key' => 'primary');
+ $result = $this->db->buildColumn($column);
+ $expected = '[id] int IDENTITY (1, 1) NOT NULL';
+ $this->assertEqual($result, $expected);
+
+ $column = array('name' => 'client_id', 'type' => 'integer', 'null' => '', 'default' => '0', 'length' => '11');
+ $result = $this->db->buildColumn($column);
+ $expected = '[client_id] int DEFAULT 0 NOT NULL';
+ $this->assertEqual($result, $expected);
+
+ $column = array('name' => 'client_id', 'type' => 'integer', 'null' => true);
+ $result = $this->db->buildColumn($column);
+ $expected = '[client_id] int NULL';
+ $this->assertEqual($result, $expected);
+
+ // 'name' => 'type' format for columns
+ $column = array('type' => 'integer', 'name' => 'client_id');
+ $result = $this->db->buildColumn($column);
+ $expected = '[client_id] int NULL';
+ $this->assertEqual($result, $expected);
+
+ $column = array('type' => 'string', 'name' => 'name');
+ $result = $this->db->buildColumn($column);
+ $expected = '[name] varchar(255) NULL';
+ $this->assertEqual($result, $expected);
+
+ $column = array('name' => 'name', 'type' => 'string', 'null' => '', 'default' => '', 'length' => '255');
+ $result = $this->db->buildColumn($column);
+ $expected = '[name] varchar(255) DEFAULT \'\' NOT NULL';
+ $this->assertEqual($result, $expected);
+
+ $column = array('name' => 'name', 'type' => 'string', 'null' => false, 'length' => '255');
+ $result = $this->db->buildColumn($column);
+ $expected = '[name] varchar(255) NOT NULL';
+ $this->assertEqual($result, $expected);
+
+ $column = array('name' => 'name', 'type' => 'string', 'null' => false, 'default' => null, 'length' => '255');
+ $result = $this->db->buildColumn($column);
+ $expected = '[name] varchar(255) NOT NULL';
+ $this->assertEqual($result, $expected);
+
+ $column = array('name' => 'name', 'type' => 'string', 'null' => true, 'default' => null, 'length' => '255');
+ $result = $this->db->buildColumn($column);
+ $expected = '[name] varchar(255) NULL';
+ $this->assertEqual($result, $expected);
+
+ $column = array('name' => 'name', 'type' => 'string', 'null' => true, 'default' => '', 'length' => '255');
+ $result = $this->db->buildColumn($column);
+ $expected = '[name] varchar(255) DEFAULT \'\'';
+ $this->assertEqual($result, $expected);
+ }
/**
* testUpdateAllSyntax method
*
@@ -380,6 +569,7 @@ class DboMssqlTest extends CakeTestCase {
* @access public
*/
function testGetPrimaryKey() {
+ // When param is a model
$result = $this->db->getPrimaryKey($this->model);
$this->assertEqual($result, 'id');
@@ -388,6 +578,12 @@ class DboMssqlTest extends CakeTestCase {
$this->model->setSchema($schema);
$result = $this->db->getPrimaryKey($this->model);
$this->assertNull($result);
+
+ // When param is a table name
+ $this->db->simulate = false;
+ $this->loadFixtures('Category');
+ $result = $this->db->getPrimaryKey('categories');
+ $this->assertEqual($result, 'id');
}
/**
diff --git a/cake/tests/cases/libs/model/datasources/dbo_source.test.php b/cake/tests/cases/libs/model/datasources/dbo_source.test.php
index 8fe318d1b..138de0e3b 100644
--- a/cake/tests/cases/libs/model/datasources/dbo_source.test.php
+++ b/cake/tests/cases/libs/model/datasources/dbo_source.test.php
@@ -1332,6 +1332,8 @@ class DboSourceTest extends CakeTestCase {
$this->testDb =& new DboTest($this->__config);
$this->testDb->cacheSources = false;
+ $this->testDb->startQuote = '`';
+ $this->testDb->endQuote = '`';
Configure::write('debug', 1);
$this->debug = Configure::read('debug');
$this->Model =& new TestModel();
@@ -1358,6 +1360,7 @@ class DboSourceTest extends CakeTestCase {
function testFieldDoubleEscaping() {
$config = array_merge($this->__config, array('driver' => 'test'));
$test =& ConnectionManager::create('quoteTest', $config);
+ $test->simulated = array();
$this->Model =& new Article2(array('alias' => 'Article', 'ds' => 'quoteTest'));
$this->Model->setDataSource('quoteTest');
diff --git a/cake/tests/cases/libs/model/model_write.test.php b/cake/tests/cases/libs/model/model_write.test.php
index c0f45af02..1b058d44e 100644
--- a/cake/tests/cases/libs/model/model_write.test.php
+++ b/cake/tests/cases/libs/model/model_write.test.php
@@ -149,12 +149,8 @@ class ModelWriteTest extends BaseModelTest {
* @return void
*/
function testAutoSaveUuid() {
- // SQLite does not support non-integer primary keys, and SQL Server
- // is still having problems with custom PK's
- $this->skipIf(
- $this->db->config['driver'] == 'sqlite'
- || $this->db->config['driver'] == 'mssql'
- );
+ // SQLite does not support non-integer primary keys
+ $this->skipIf($this->db->config['driver'] == 'sqlite');
$this->loadFixtures('Uuid');
$TestModel =& new Uuid();
diff --git a/cake/tests/cases/libs/view/helpers/xml.test.php b/cake/tests/cases/libs/view/helpers/xml.test.php
index 4a74943c4..462c61b30 100644
--- a/cake/tests/cases/libs/view/helpers/xml.test.php
+++ b/cake/tests/cases/libs/view/helpers/xml.test.php
@@ -215,7 +215,7 @@ class XmlHelperTest extends CakeTestCase {
$result = $this->Xml->serialize($data, array('format' => 'tags'));
$expected = '12';
$this->assertIdentical($result, $expected);
-
+
$data = array(
'Pages' => array('id' => 2, 'url' => 'http://www.url.com/rb/153/?id=bbbb&t=access')
);
@@ -224,6 +224,24 @@ class XmlHelperTest extends CakeTestCase {
$this->assertIdentical($result, $expected);
}
+/**
+ * testSerializeOnMultiDimensionalArray method
+ *
+ * @access public
+ * @return void
+ */
+ function testSerializeOnMultiDimensionalArray() {
+ $data = array(
+ 'Statuses' => array(
+ array('Status' => array('id' => 1)),
+ array('Status' => array('id' => 2))
+ )
+ );
+ $result = $this->Xml->serialize($data, array('format' => 'tags'));
+ $expected = '12';
+ $this->assertIdentical($result, $expected);
+
+ }
/**
* testHeader method
*
diff --git a/cake/tests/cases/libs/xml.test.php b/cake/tests/cases/libs/xml.test.php
index 88f70c55c..d39546022 100644
--- a/cake/tests/cases/libs/xml.test.php
+++ b/cake/tests/cases/libs/xml.test.php
@@ -103,6 +103,25 @@ class XmlTest extends CakeTestCase {
$this->assertEqual($result, $expected);
}
+/**
+ * testSerializeOnMultiDimensionalArray method
+ *
+ * @access public
+ * @return void
+ */
+ function testSerializeOnMultiDimensionalArray() {
+ $data = array(
+ 'Statuses' => array(
+ array('Status' => array('id' => 1)),
+ array('Status' => array('id' => 2))
+ )
+ );
+ $result =& new Xml($data, array('format' => 'tags'));
+ $expected = '12';
+ $this->assertIdentical($result->toString(), $expected);
+
+ }
+
/**
* test serialization of boolean and null values. false = 0, true = 1, null = ''
*
diff --git a/cake/tests/fixtures/uuid_tree_fixture.php b/cake/tests/fixtures/uuid_tree_fixture.php
index 6b487c665..224dd8a06 100644
--- a/cake/tests/fixtures/uuid_tree_fixture.php
+++ b/cake/tests/fixtures/uuid_tree_fixture.php
@@ -50,7 +50,7 @@ class UuidTreeFixture extends CakeTestFixture {
var $fields = array(
'id' => array('type' => 'string', 'length' => 36, 'key' => 'primary'),
'name' => array('type' => 'string','null' => false),
- 'parent_id' => array('type' => 'string', 'length' => 36),
+ 'parent_id' => array('type' => 'string', 'length' => 36, 'null' => true),
'lft' => array('type' => 'integer','null' => false),
'rght' => array('type' => 'integer','null' => false)
);
From e9e8951a278ba15c91b20f81b9b65ecc90bca129 Mon Sep 17 00:00:00 2001
From: jperras
Date: Sun, 2 Aug 2009 18:52:55 +0000
Subject: [PATCH 26/31] Updating doc blocks for datasource - thanks to savant
for patch. Fixes #5738.
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@8270 3807eeeb-6ff5-0310-8944-8be069107fe0
---
cake/libs/model/datasources/datasource.php | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/cake/libs/model/datasources/datasource.php b/cake/libs/model/datasources/datasource.php
index 4fa8fba2e..b1b2baefb 100644
--- a/cake/libs/model/datasources/datasource.php
+++ b/cake/libs/model/datasources/datasource.php
@@ -91,28 +91,28 @@ class DataSource extends Object {
* Enter description here...
*
* @var array
- * @access private
+ * @access protected
*/
var $_result = null;
/**
* Queries count.
*
* @var int
- * @access private
+ * @access protected
*/
var $_queriesCnt = 0;
/**
* Total duration of all queries.
*
* @var unknown_type
- * @access private
+ * @access protected
*/
var $_queriesTime = null;
/**
* Log of queries executed by this DataSource
*
* @var unknown_type
- * @access private
+ * @access protected
*/
var $_queriesLog = array();
/**
@@ -121,21 +121,21 @@ class DataSource extends Object {
* >6000 queries on one system.
*
* @var int Maximum number of queries in the queries log.
- * @access private
+ * @access protected
*/
var $_queriesLogMax = 200;
/**
* Caches serialzed results of executed queries
*
* @var array Maximum number of queries in the queries log.
- * @access private
+ * @access protected
*/
var $_queryCache = array();
/**
* The default configuration of a specific DataSource
*
* @var array
- * @access public
+ * @access protected
*/
var $_baseConfig = array();
/**
From 70c331f5db2ab35c27fb78dedfc54f610549d52d Mon Sep 17 00:00:00 2001
From: jperras
Date: Sun, 2 Aug 2009 18:55:37 +0000
Subject: [PATCH 27/31] Updating doc blocks for paginator helper. Thanks to
savant for the patch. Fixes #4994.
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@8271 3807eeeb-6ff5-0310-8944-8be069107fe0
---
cake/libs/view/helpers/paginator.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/cake/libs/view/helpers/paginator.php b/cake/libs/view/helpers/paginator.php
index 2a8f37433..7b5dd09a2 100644
--- a/cake/libs/view/helpers/paginator.php
+++ b/cake/libs/view/helpers/paginator.php
@@ -67,10 +67,10 @@ class PaginatorHelper extends AppHelper {
*/
var $options = array();
/**
- * Gets the current page of the in the recordset for the given model
+ * Gets the current paging parameters from the resultset for the given model
*
* @param string $model Optional model name. Uses the default if none is specified.
- * @return string The current page number of the paginated resultset.
+ * @return array The array of paging parameters for the paginated resultset.
*/
function params($model = null) {
if (empty($model)) {
From f426017a9ece7d6e621fd3f46f16df594aca1d76 Mon Sep 17 00:00:00 2001
From: jperras
Date: Sun, 2 Aug 2009 19:00:30 +0000
Subject: [PATCH 28/31] Changing l10n language name from 'Slovack' to 'Slovak',
as per ISO 693-1 guidelines. Thanks to savant for the patch. Fixes #5870.
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@8272 3807eeeb-6ff5-0310-8944-8be069107fe0
---
cake/libs/l10n.php | 6 +++---
cake/tests/cases/libs/l10n.test.php | 2 +-
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/cake/libs/l10n.php b/cake/libs/l10n.php
index 0df50204a..95f66c257 100644
--- a/cake/libs/l10n.php
+++ b/cake/libs/l10n.php
@@ -150,8 +150,8 @@ class L10n extends Object {
/* Sami (Lappish) */ 'smi' => 'sz',
/* Serbian */ 'scc' => 'sr',
/* Serbian */ 'srp' => 'sr',
- /* Slovack */ 'slo' => 'sk',
- /* Slovack */ 'slk' => 'sk',
+ /* Slovak */ 'slo' => 'sk',
+ /* Slovak */ 'slk' => 'sk',
/* Slovenian */ 'slv' => 'sl',
/* Sorbian */ 'wen' => 'sb',
/* Spanish (Spain - Traditional) */ 'spa' => 'es',
@@ -290,7 +290,7 @@ class L10n extends Object {
'ro-mo' => array('language' => 'Romanian (Moldavia)', 'locale' => 'ro_mo', 'localeFallback' => 'rum', 'charset' => 'utf-8'),
'ru-mo' => array('language' => 'Russian (Moldavia)', 'locale' => 'ru_mo', 'localeFallback' => 'rus', 'charset' => 'utf-8'),
'sb' => array('language' => 'Sorbian', 'locale' => 'wen', 'localeFallback' => 'wen', 'charset' => 'utf-8'),
- 'sk' => array('language' => 'Slovack', 'locale' => 'slo', 'localeFallback' => 'slo', 'charset' => 'utf-8'),
+ 'sk' => array('language' => 'Slovak', 'locale' => 'slo', 'localeFallback' => 'slo', 'charset' => 'utf-8'),
'sl' => array('language' => 'Slovenian', 'locale' => 'slv', 'localeFallback' => 'slv', 'charset' => 'utf-8'),
'sq' => array('language' => 'Albanian', 'locale' => 'alb', 'localeFallback' => 'alb', 'charset' => 'utf-8'),
'sr' => array('language' => 'Serbian', 'locale' => 'scc', 'localeFallback' => 'scc', 'charset' => 'utf-8'),
diff --git a/cake/tests/cases/libs/l10n.test.php b/cake/tests/cases/libs/l10n.test.php
index f3aaea211..48df8fa3c 100644
--- a/cake/tests/cases/libs/l10n.test.php
+++ b/cake/tests/cases/libs/l10n.test.php
@@ -848,7 +848,7 @@ class L10nTest extends CakeTestCase {
$result = $l10n->catalog(array('sk'));
$expected = array(
- 'sk' => array('language' => 'Slovack', 'locale' => 'slo', 'localeFallback' => 'slo', 'charset' => 'utf-8')
+ 'sk' => array('language' => 'Slovak', 'locale' => 'slo', 'localeFallback' => 'slo', 'charset' => 'utf-8')
);
$this->assertEqual($result, $expected);
From 6b0bbc44bb0505c92e7a45ae6444a63e3d974edd Mon Sep 17 00:00:00 2001
From: jperras
Date: Sun, 2 Aug 2009 19:12:02 +0000
Subject: [PATCH 29/31] Updating doc block for Object::requestAction. Fixes
#6391.
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@8273 3807eeeb-6ff5-0310-8944-8be069107fe0
---
cake/libs/object.php | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/cake/libs/object.php b/cake/libs/object.php
index 358fd759f..61c0896cd 100644
--- a/cake/libs/object.php
+++ b/cake/libs/object.php
@@ -77,9 +77,10 @@ class Object {
/**
* Calls a controller's method from any location.
*
- * @param string $url URL in the form of Cake URL ("/controller/method/parameter")
+ * @param mixed $url String or array-based url.
* @param array $extra if array includes the key "return" it sets the AutoRender to true.
- * @return mixed Success (true/false) or contents if 'return' is set in $extra
+ * @return mixed Boolean true or false on success/failure, or contents
+ * of rendered action if 'return' is set in $extra.
* @access public
*/
function requestAction($url, $extra = array()) {
From 3f46bf9568a5b8d0458ad757a060bbf3bedda97d Mon Sep 17 00:00:00 2001
From: jperras
Date: Sun, 2 Aug 2009 19:18:54 +0000
Subject: [PATCH 30/31] Updating doc block for Model::invalidate. Fixes #4583.
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@8274 3807eeeb-6ff5-0310-8944-8be069107fe0
---
cake/libs/model/model.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/cake/libs/model/model.php b/cake/libs/model/model.php
index 58fa4c826..657aa61dc 100644
--- a/cake/libs/model/model.php
+++ b/cake/libs/model/model.php
@@ -2488,8 +2488,8 @@ class Model extends Overloadable {
* rule (in case of multiple validation for field) that was broken.
*
* @param string $field The name of the field to invalidate
- * @param mixed $value Name of validation rule that was not failed. If no validation key
- * is provided, defaults to true.
+ * @param mixed $value Name of validation rule that was not failed, or validation message to
+ * be returned. If no validation key is provided, defaults to true.
* @access public
*/
function invalidate($field, $value = true) {
From 9e4cb97026571b2ba4ac6c1d5b955a3b51845152 Mon Sep 17 00:00:00 2001
From: gwoo
Date: Sun, 2 Aug 2009 13:19:16 -0700
Subject: [PATCH 31/31] Revert "allow running all core test cases via the
console"
This reverts commit 86e5cc5a89e7307ebf827c688311cdbe945feb85.
---
cake/console/libs/testsuite.php | 17 ++++-------------
1 file changed, 4 insertions(+), 13 deletions(-)
diff --git a/cake/console/libs/testsuite.php b/cake/console/libs/testsuite.php
index 7038cd9fd..4915412e6 100644
--- a/cake/console/libs/testsuite.php
+++ b/cake/console/libs/testsuite.php
@@ -94,7 +94,7 @@ class TestSuiteShell extends Shell {
if (isset($corePath[0])) {
define('TEST_CAKE_CORE_INCLUDE_PATH', rtrim($corePath[0], DS) . DS);
} else {
- define('TEST_CAKE_CORE_INCLUDE_PATH', CAKE_CORE_INCLUDE_PATH . DS . 'cake' . DS);
+ define('TEST_CAKE_CORE_INCLUDE_PATH', CAKE_CORE_INCLUDE_PATH);
}
$this->__installSimpleTest();
@@ -236,13 +236,8 @@ class TestSuiteShell extends Shell {
return true;
}
- if ($this->category == 'core') {
- if (file_exists($folder.DS.'cases'.DS.$this->file.'.test.php')) {
- return true;
- }
- if (file_exists($folder.DS.'cases'.DS.'libs'.DS.$this->file.'.test.php')) {
- return true;
- }
+ if ($this->category == 'core' && file_exists($folder.DS.'cases'.DS.'libs'.DS.$this->file.'.test.php')) {
+ return true;
}
if ($isPlugin && file_exists($folder.DS.'cases'.DS.$this->file.'.test.php')) {
@@ -297,11 +292,7 @@ class TestSuiteShell extends Shell {
return $result;
}
- if (file_exists(CORE_TEST_CASES . DS . $this->file . '.test.php')) {
- $case = $this->file . '.test.php';
- } else {
- $case = 'libs' . DS . $this->file . '.test.php';
- }
+ $case = 'libs'.DS.$this->file.'.test.php';
if ($this->category == 'app') {
$case = $this->file.'.test.php';
} elseif ($this->isPluginTest) {