diff --git a/app/config/core.php b/app/config/core.php
index 4f56244f9..4a86273cd 100644
--- a/app/config/core.php
+++ b/app/config/core.php
@@ -225,6 +225,11 @@
*/
//date_default_timezone_set('UTC');
+/**
+ * If you are on PHP 5.3 uncomment this line and correct your server timezone
+ * to fix the date & time related errors.
+ */
+ //date_default_timezone_set('UTC');
/**
*
* Cache Engine Configuration
diff --git a/app/webroot/test.php b/app/webroot/test.php
index 4cdbd8c28..40c42decf 100644
--- a/app/webroot/test.php
+++ b/app/webroot/test.php
@@ -24,14 +24,6 @@
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
*/
-/**
- * PHP 5.3 raises many notices in bootstrap.
- */
-if (!defined('E_DEPRECATED')) {
- define('E_DEPRECATED', 8192);
-}
-error_reporting(E_ALL & ~E_DEPRECATED);
-
set_time_limit(0);
ini_set('memory_limit','128M');
ini_set('display_errors', 1);
diff --git a/cake/basics.php b/cake/basics.php
index 01133de7e..f916576e7 100644
--- a/cake/basics.php
+++ b/cake/basics.php
@@ -54,9 +54,8 @@ if (!function_exists('clone')) {
* Loads configuration files. Receives a set of configuration files
* to load.
* Example:
- *
- * config('config1', 'config2');
- *
+ *
+ * `config('config1', 'config2');`
*
* @return boolean Success
*/
@@ -84,9 +83,8 @@ if (!function_exists('clone')) {
* Loads component/components from LIBS. Takes optional number of parameters.
*
* Example:
- *
- * uses('flay', 'time');
- *
+ *
+ * `uses('flay', 'time');`
*
* @param string $name Filename without the .php part
* @deprecated
@@ -224,14 +222,12 @@ if (!function_exists('array_combine')) {
* Returns an array of all the given parameters.
*
* Example:
- *
- * a('a', 'b')
- *
+ *
+ * `a('a', 'b')`
*
* Would return:
- *
- * array('a', 'b')
- *
+ *
+ * `array('a', 'b')`
*
* @return array Array of given parameters
* @link http://book.cakephp.org/view/694/a
@@ -245,14 +241,12 @@ if (!function_exists('array_combine')) {
* Constructs associative array from pairs of arguments.
*
* Example:
- *
- * aa('a','b')
- *
+ *
+ * `aa('a','b')`
*
* Would return:
- *
- * array('a'=>'b')
- *
+ *
+ * `array('a'=>'b')`
*
* @return array Associative array
* @link http://book.cakephp.org/view/695/aa
@@ -531,10 +525,9 @@ if (!function_exists('file_put_contents')) {
/**
* Used to delete files in the cache directories, or clear contents of cache directories
*
- * @param mixed $params As String name to be searched for deletion, if name is a directory all files in directory will be deleted.
- * If array, names to be searched for deletion.
- * If clearCache() without params, all files in app/tmp/cache/views will be deleted
- *
+ * @param mixed $params As String name to be searched for deletion, if name is a directory all files in
+ * directory will be deleted. If array, names to be searched for deletion. If clearCache() without params,
+ * all files in app/tmp/cache/views will be deleted
* @param string $type Directory in tmp/cache defaults to view directory
* @param string $ext The file extension you are deleting
* @return true if files found and deleted false otherwise
@@ -715,13 +708,14 @@ if (!function_exists('file_put_contents')) {
* Valid categories are: LC_CTYPE, LC_NUMERIC, LC_TIME, LC_COLLATE, LC_MONETARY, LC_MESSAGES and LC_ALL.
*
* Note that the category must be specified with a numeric value, instead of the constant name. The values are:
- * LC_CTYPE 0
- * LC_NUMERIC 1
- * LC_TIME 2
- * LC_COLLATE 3
- * LC_MONETARY 4
- * LC_MESSAGES 5
- * LC_ALL 6
+ *
+ * - LC_ALL 0
+ * - LC_COLLATE 1
+ * - LC_CTYPE 2
+ * - LC_MONETARY 3
+ * - LC_NUMERIC 4
+ * - LC_TIME 5
+ * - LC_MESSAGES 6
*
* @param string $domain Domain
* @param string $msg Message to translate
@@ -754,13 +748,14 @@ if (!function_exists('file_put_contents')) {
* Valid categories are: LC_CTYPE, LC_NUMERIC, LC_TIME, LC_COLLATE, LC_MONETARY, LC_MESSAGES and LC_ALL.
*
* Note that the category must be specified with a numeric value, instead of the constant name. The values are:
- * LC_ALL 0
- * LC_COLLATE 1
- * LC_CTYPE 2
- * LC_MONETARY 3
- * LC_NUMERIC 4
- * LC_TIME 5
- * LC_MESSAGES 6
+ *
+ * - LC_ALL 0
+ * - LC_COLLATE 1
+ * - LC_CTYPE 2
+ * - LC_MONETARY 3
+ * - LC_NUMERIC 4
+ * - LC_TIME 5
+ * - LC_MESSAGES 6
*
* @param string $domain Domain
* @param string $singular Singular string to translate
@@ -790,13 +785,14 @@ if (!function_exists('file_put_contents')) {
* Valid categories are: LC_CTYPE, LC_NUMERIC, LC_TIME, LC_COLLATE, LC_MONETARY, LC_MESSAGES and LC_ALL.
*
* Note that the category must be specified with a numeric value, instead of the constant name. The values are:
- * LC_CTYPE 0
- * LC_NUMERIC 1
- * LC_TIME 2
- * LC_COLLATE 3
- * LC_MONETARY 4
- * LC_MESSAGES 5
- * LC_ALL 6
+ *
+ * - LC_ALL 0
+ * - LC_COLLATE 1
+ * - LC_CTYPE 2
+ * - LC_MONETARY 3
+ * - LC_NUMERIC 4
+ * - LC_TIME 5
+ * - LC_MESSAGES 6
*
* @param string $msg String to translate
* @param integer $category Category
@@ -965,9 +961,8 @@ if (!function_exists('file_put_contents')) {
* Wraps ternary operations. If $condition is a non-empty value, $val1 is returned, otherwise $val2.
* Don't use for isset() conditions, or wrap your variable with @ operator:
* Example:
- *
- * ife(isset($variable), @$variable, 'default');
- *
+ *
+ * `ife(isset($variable), @$variable, 'default');`
*
* @param mixed $condition Conditional expression
* @param mixed $val1 Value to return in case condition matches
diff --git a/cake/config/config.php b/cake/config/config.php
index 0ea8edad5..8671c403c 100644
--- a/cake/config/config.php
+++ b/cake/config/config.php
@@ -19,5 +19,5 @@
* @since CakePHP(tm) v 1.1.11.4062
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-return $config['Cake.version'] = '1.3.0.0';
-?>
\ No newline at end of file
+return $config['Cake.version'] = '1.3.0';
+?>
diff --git a/cake/console/cake.php b/cake/console/cake.php
index e3e1c85ba..5b08b43c9 100644
--- a/cake/console/cake.php
+++ b/cake/console/cake.php
@@ -27,7 +27,6 @@
if (!defined('E_DEPRECATED')) {
define('E_DEPRECATED', 8192);
}
-
/**
* Shell dispatcher
*
@@ -161,7 +160,7 @@ class ShellDispatcher {
function __initConstants() {
if (function_exists('ini_set')) {
ini_set('display_errors', '1');
- ini_set('error_reporting', E_ALL);
+ ini_set('error_reporting', E_ALL & ~E_DEPRECATED);
ini_set('html_errors', false);
ini_set('implicit_flush', true);
ini_set('max_execution_time', 0);
@@ -228,7 +227,7 @@ class ShellDispatcher {
require LIBS . 'folder.php';
}
foreach ($pluginPaths as $pluginPath) {
- $Folder =& new Folder($pluginPath);
+ $Folder = new Folder($pluginPath);
list($plugins,) = $Folder->read(false, true);
foreach ((array)$plugins as $plugin) {
$path = $pluginPath . Inflector::underscore($plugin) . DS . 'vendors' . DS . 'shells' . DS;
diff --git a/cake/console/libs/schema.php b/cake/console/libs/schema.php
index 699496fc4..6cdf126a3 100644
--- a/cake/console/libs/schema.php
+++ b/cake/console/libs/schema.php
@@ -8,20 +8,17 @@
* PHP versions 4 and 5
*
* CakePHP(tm) : Rapid Development Framework (http://www.cakephp.org)
- * Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
+ * Copyright 2005-2009, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @filesource
- * @copyright Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
+ * @copyright Copyright 2005-2009, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
* @package cake
* @subpackage cake.cake.console.libs
* @since CakePHP(tm) v 1.2.0.5550
- * @version $Revision$
- * @modifiedby $LastChangedBy$
- * @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
App::import('Core', 'File', false);
@@ -208,6 +205,7 @@ class SchemaShell extends Shell {
$db =& ConnectionManager::getDataSource($this->Schema->connection);
$contents = "#" . $Schema->name . " sql generated on: " . date('Y-m-d H:i:s') . " : " . time() . "\n\n";
$contents .= $db->dropSchema($Schema) . "\n\n". $db->createSchema($Schema);
+
if ($write) {
if (strpos($write, '.sql') === false) {
$write .= '.sql';
@@ -290,7 +288,7 @@ class SchemaShell extends Shell {
*
* @access private
*/
- function __create($Schema, $table = null) {
+ function __create(&$Schema, $table = null) {
$db =& ConnectionManager::getDataSource($this->Schema->connection);
$drop = $create = array();
@@ -334,11 +332,15 @@ class SchemaShell extends Shell {
*
* @access private
*/
- function __update($Schema, $table = null) {
+ function __update(&$Schema, $table = null) {
$db =& ConnectionManager::getDataSource($this->Schema->connection);
$this->out(__('Comparing Database to Schema...', true));
- $Old = $this->Schema->read();
+ $options = array();
+ if (isset($this->params['f'])) {
+ $options['models'] = false;
+ }
+ $Old = $this->Schema->read($options);
$compare = $this->Schema->compare($Old, $Schema);
$contents = array();
@@ -372,7 +374,7 @@ class SchemaShell extends Shell {
*
* @access private
*/
- function __run($contents, $event, $Schema) {
+ function __run($contents, $event, &$Schema) {
if (empty($contents)) {
$this->err(__('Sql could not be run', true));
return;
@@ -380,7 +382,7 @@ class SchemaShell extends Shell {
Configure::write('debug', 2);
$db =& ConnectionManager::getDataSource($this->Schema->connection);
$db->fullDebug = true;
-
+
foreach ($contents as $table => $sql) {
if (empty($sql)) {
$this->out(sprintf(__('%s is up to date.', true), $table));
diff --git a/cake/console/templates/skel/config/core.php b/cake/console/templates/skel/config/core.php
index 22ca951c4..3d4073949 100644
--- a/cake/console/templates/skel/config/core.php
+++ b/cake/console/templates/skel/config/core.php
@@ -225,6 +225,11 @@
*/
//date_default_timezone_set('UTC');
+/**
+ * If you are on PHP 5.3 uncomment this line and correct your server timezone
+ * to fix the date & time related errors.
+ */
+ //date_default_timezone_set('UTC');
/**
*
* Cache Engine Configuration
diff --git a/cake/console/templates/skel/webroot/test.php b/cake/console/templates/skel/webroot/test.php
index c64220950..cd1fffb27 100644
--- a/cake/console/templates/skel/webroot/test.php
+++ b/cake/console/templates/skel/webroot/test.php
@@ -25,25 +25,15 @@
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
*/
-/**
- * PHP 5.3 raises many notices in bootstrap.
- */
-if (!defined('E_DEPRECATED')) {
- define('E_DEPRECATED', 8192);
-}
-error_reporting(E_ALL & ~E_DEPRECATED);
-
set_time_limit(0);
ini_set('memory_limit','128M');
ini_set('display_errors', 1);
-
/**
* Use the DS to separate the directories in other defines
*/
if (!defined('DS')) {
define('DS', DIRECTORY_SEPARATOR);
}
-
/**
* These defines should only be edited if you have cake installed in
* a directory layout other than the way it is distributed.
diff --git a/cake/libs/controller/components/email.php b/cake/libs/controller/components/email.php
index 3801e7401..46fd47209 100644
--- a/cake/libs/controller/components/email.php
+++ b/cake/libs/controller/components/email.php
@@ -725,10 +725,14 @@ class EmailComponent extends Object{
return false;
}
+ $httpHost = env('HTTP_HOST');
+
if (isset($this->smtpOptions['client'])) {
$host = $this->smtpOptions['client'];
+ } elseif (!empty($httpHost)) {
+ $host = $httpHost;
} else {
- $host = env('HTTP_HOST');
+ $host = 'localhost';
}
if (!$this->__smtpSend("HELO {$host}", '250')) {
diff --git a/cake/libs/model/cake_schema.php b/cake/libs/model/cake_schema.php
index 865dcc517..c2e06a7db 100644
--- a/cake/libs/model/cake_schema.php
+++ b/cake/libs/model/cake_schema.php
@@ -186,6 +186,7 @@ class CakeSchema extends Object {
* - 'connection' - the db connection to use
* - 'name' - name of the schema
* - 'models' - a list of models to use, or false to ignore models
+ *
* @param array $options schema object properties
* @return array Array indexed by name and tables
* @access public
diff --git a/cake/libs/model/datasources/dbo/dbo_mssql.php b/cake/libs/model/datasources/dbo/dbo_mssql.php
index 56911273b..de8db0a60 100644
--- a/cake/libs/model/datasources/dbo/dbo_mssql.php
+++ b/cake/libs/model/datasources/dbo/dbo_mssql.php
@@ -275,6 +275,9 @@ class DboMssql extends DboSource {
if ($data === null) {
return 'NULL';
}
+ if (in_array($column, array('integer', 'float', 'binary')) && $data === '') {
+ return 'NULL';
+ }
if ($data === '') {
return "''";
}
@@ -737,8 +740,8 @@ class DboMssql extends DboSource {
foreach ($indexes as $name => $value) {
if ($name == 'PRIMARY') {
- $out = 'PRIMARY KEY (' . $this->name($value['column']) . ')';
- } else {
+ $join[] = 'PRIMARY KEY (' . $this->name($value['column']) . ')';
+ } else if (isset($value['unique']) && $value['unique']) {
$out = "ALTER TABLE {$table} ADD CONSTRAINT {$name} UNIQUE";
if (is_array($value['column'])) {
@@ -747,8 +750,8 @@ class DboMssql extends DboSource {
$value['column'] = $this->name($value['column']);
}
$out .= "({$value['column']});";
+ $join[] = $out;
}
- $join[] = $out;
}
return $join;
}
diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php
index 276bab7b9..c2ccd0212 100644
--- a/cake/libs/model/datasources/dbo_source.php
+++ b/cake/libs/model/datasources/dbo_source.php
@@ -1563,7 +1563,7 @@ class DboSource extends DataSource {
'alias' => $assoc,
'type' => isset($assocData['type']) ? $assocData['type'] : 'LEFT',
'conditions' => trim($this->conditions(
- $this->getConstraint($assocData['association'], $model, $model->{$assoc}, $assoc, $assocData),
+ $this->__mergeConditions($assocData['conditions'], $this->getConstraint($assocData['association'], $model, $model->{$assoc}, $assoc, $assocData)),
true, false, $model
))
));
diff --git a/cake/libs/model/model.php b/cake/libs/model/model.php
index fdc877700..060e3bc01 100644
--- a/cake/libs/model/model.php
+++ b/cake/libs/model/model.php
@@ -1855,8 +1855,6 @@ class Model extends Overloadable {
* @access protected
*/
function _deleteLinks($id) {
- $db =& ConnectionManager::getDataSource($this->useDbConfig);
-
foreach ($this->hasAndBelongsToMany as $assoc => $data) {
$with = $data['with'];
$records = $this->{$data['with']}->find('all', array(
diff --git a/cake/libs/router.php b/cake/libs/router.php
index 9f0ae7b63..87c5b0df0 100644
--- a/cake/libs/router.php
+++ b/cake/libs/router.php
@@ -799,6 +799,9 @@ class Router extends Object {
} else {
$params = end($_this->__params);
}
+ if (isset($params['prefix']) && strpos($params['action'], $params['prefix']) === 0) {
+ $params['action'] = substr($params['action'], strlen($params['prefix']) + 1);
+ }
}
$path = array('base' => null);
diff --git a/cake/libs/set.php b/cake/libs/set.php
index c08b70fa7..e50895da1 100644
--- a/cake/libs/set.php
+++ b/cake/libs/set.php
@@ -398,7 +398,7 @@ class Set extends Object {
$options = array_merge(array('flatten' => true), $options);
if (!isset($contexts[0])) {
$current = current($data);
- if ((is_array($current) && count($data) <= 1) || !is_array($current)) {
+ if ((is_array($current) && count($data) <= 1) || !is_array($current) || !Set::numeric(array_keys($data))) {
$contexts = array($data);
}
}
@@ -1098,7 +1098,7 @@ class Set extends Object {
if (!is_null($key)) {
$id = $key;
}
- if (is_array($r)) {
+ if (is_array($r) && count($r)) {
$stack = array_merge($stack, Set::__flatten($r, $id));
} else {
$stack[] = array('id' => $id, 'value' => $r);
diff --git a/cake/libs/view/helpers/form.php b/cake/libs/view/helpers/form.php
index e963154d2..899455aa7 100644
--- a/cake/libs/view/helpers/form.php
+++ b/cake/libs/view/helpers/form.php
@@ -421,11 +421,10 @@ class FormHelper extends AppHelper {
if (is_array($text) && is_numeric($error) && $error > 0) {
$error--;
}
- if (is_array($text) && isset($text[$error])) {
- $text = $text[$error];
- } elseif (is_array($text)) {
+ if (is_array($text)) {
$options = array_merge($options, $text);
- $text = null;
+ $text = isset($text[$error]) ? $text[$error] : null;
+ unset($options[$error]);
}
if ($text != null) {
@@ -1647,15 +1646,16 @@ class FormHelper extends AppHelper {
}
$opt = implode($separator, $selects);
}
-
+ if (!empty($interval) && $interval > 1 && !empty($min)) {
+ $min = round($min * (1 / $interval)) * $interval;
+ }
+ $selectMinuteAttr['interval'] = $interval;
switch ($timeFormat) {
case '24':
- $selectMinuteAttr['interval'] = $interval;
$opt .= $this->hour($fieldName, true, $hour, $selectHourAttr, $showEmpty) . ':' .
$this->minute($fieldName, $min, $selectMinuteAttr, $showEmpty);
break;
case '12':
- $selectMinuteAttr['interval'] = $interval;
$opt .= $this->hour($fieldName, false, $hour, $selectHourAttr, $showEmpty) . ':' .
$this->minute($fieldName, $min, $selectMinuteAttr, $showEmpty) . ' ' .
$this->meridian($fieldName, $meridian, $selectMeridianAttr, $showEmpty);
diff --git a/cake/tests/cases/console/libs/schema.test.php b/cake/tests/cases/console/libs/schema.test.php
index 5b7ae176d..e45d313bd 100644
--- a/cake/tests/cases/console/libs/schema.test.php
+++ b/cake/tests/cases/console/libs/schema.test.php
@@ -47,6 +47,67 @@ Mock::generatePartial(
Mock::generate('CakeSchema', 'MockSchemaCakeSchema');
+/**
+ * Test for Schema database management
+ *
+ * @package cake
+ * @subpackage cake.tests.cases.libs
+ */
+class SchemaShellTestSchema extends CakeSchema {
+
+/**
+ * name property
+ *
+ * @var string 'MyApp'
+ * @access public
+ */
+ var $name = 'SchemaShellTest';
+
+/**
+ * connection property
+ *
+ * @var string 'test_suite'
+ * @access public
+ */
+ var $connection = 'test_suite';
+
+/**
+ * comments property
+ *
+ * @var array
+ * @access public
+ */
+ var $comments = array(
+ 'id' => array('type' => 'integer', 'null' => false, 'default' => 0, 'key' => 'primary'),
+ 'post_id' => array('type' => 'integer', 'null' => false, 'default' => 0),
+ 'user_id' => array('type' => 'integer', 'null' => false),
+ 'title' => array('type' => 'string', 'null' => false, 'length' => 100),
+ 'comment' => array('type' => 'text', 'null' => false, 'default' => null),
+ 'published' => array('type' => 'string', 'null' => true, 'default' => 'N', 'length' => 1),
+ 'created' => array('type' => 'datetime', 'null' => true, 'default' => null),
+ 'updated' => array('type' => 'datetime', 'null' => true, 'default' => null),
+ 'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => true)),
+ );
+
+/**
+ * posts property
+ *
+ * @var array
+ * @access public
+ */
+ var $articles = array(
+ 'id' => array('type' => 'integer', 'null' => false, 'default' => 0, 'key' => 'primary'),
+ 'user_id' => array('type' => 'integer', 'null' => true, 'default' => ''),
+ 'title' => array('type' => 'string', 'null' => false, 'default' => 'Title'),
+ 'body' => array('type' => 'text', 'null' => true, 'default' => null),
+ 'summary' => array('type' => 'text', 'null' => true),
+ 'published' => array('type' => 'string', 'null' => true, 'default' => 'Y', 'length' => 1),
+ 'created' => array('type' => 'datetime', 'null' => true, 'default' => null),
+ 'updated' => array('type' => 'datetime', 'null' => true, 'default' => null),
+ 'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => true)),
+ );
+}
+
/**
* SchemaShellTest class
*
@@ -87,7 +148,7 @@ class SchemaShellTest extends CakeTestCase {
$this->Shell->startup();
$this->assertTrue(isset($this->Shell->Schema));
$this->assertTrue(is_a($this->Shell->Schema, 'CakeSchema'));
- $this->assertEqual($this->Shell->Schema->name, 'App');
+ $this->assertEqual(strtolower($this->Shell->Schema->name), APP_DIR);
$this->assertEqual($this->Shell->Schema->file, 'schema.php');
unset($this->Shell->Schema);
@@ -99,7 +160,7 @@ class SchemaShellTest extends CakeTestCase {
$this->assertEqual($this->Shell->Schema->file, 'test_schema.php');
$this->assertEqual($this->Shell->Schema->connection, 'default');
$this->assertEqual($this->Shell->Schema->path, APP . 'config' . DS . 'schema');
-
+
unset($this->Shell->Schema);
$this->Shell->params = array(
'file' => 'other_file.php',
@@ -107,7 +168,7 @@ class SchemaShellTest extends CakeTestCase {
'path' => '/test/path'
);
$this->Shell->startup();
- $this->assertEqual($this->Shell->Schema->name, 'App');
+ $this->assertEqual(strtolower($this->Shell->Schema->name), APP_DIR);
$this->assertEqual($this->Shell->Schema->file, 'other_file.php');
$this->assertEqual($this->Shell->Schema->connection, 'test_suite');
$this->assertEqual($this->Shell->Schema->path, '/test/path');
@@ -123,24 +184,9 @@ class SchemaShellTest extends CakeTestCase {
$this->Shell->Schema->path = APP . 'config' . DS . 'schema';
$this->Shell->params['file'] = 'i18n.php';
$this->Shell->expectOnce('_stop');
- $this->Shell->expectOnce('out');
- $this->Shell->expectAt(0, 'out', array(new PatternExpectation('/class i18nSchema extends CakeSchema/')));
$this->Shell->view();
}
-/**
- * test dumping a schema file.
- *
- * @return void
- **/
- function testDump() {
- $this->Shell->params = array('name' => 'i18n');
- $this->Shell->startup();
- $this->Shell->Schema->path = APP . 'config' . DS . 'schema';
- $this->Shell->expectAt(0, 'out', array(new PatternExpectation('/create table `i18n`/i')));
- $this->Shell->dump();
- }
-
/**
* test dump() with sql file generation
*
@@ -244,16 +290,16 @@ class SchemaShellTest extends CakeTestCase {
$this->Shell->params = array(
'connection' => 'test_suite',
'name' => 'i18n',
- 'path' => APP . 'config' . DS . 'schema'
+ 'path' => APP . 'config' . DS . 'sql'
);
$this->Shell->args = array('create');
$this->Shell->startup();
$this->Shell->setReturnValue('in', 'y');
$this->Shell->run();
-
+
$db =& ConnectionManager::getDataSource('test_suite');
$sources = $db->listSources();
- $this->assertTrue(in_array('i18n', $sources));
+ $this->assertTrue(in_array($db->config['prefix'] . 'i18n', $sources));
}
/**
@@ -265,7 +311,7 @@ class SchemaShellTest extends CakeTestCase {
$this->Shell->params = array(
'connection' => 'test_suite',
'name' => 'DbAcl',
- 'path' => APP . 'config' . DS . 'schema'
+ 'path' => APP . 'config' . DS . 'sql'
);
$this->Shell->args = array('create', 'acos');
$this->Shell->startup();
@@ -274,10 +320,34 @@ class SchemaShellTest extends CakeTestCase {
$db =& ConnectionManager::getDataSource('test_suite');
$sources = $db->listSources();
- $this->assertTrue(in_array('acos', $sources));
- $this->assertFalse(in_array('aros', $sources));
+ $this->assertTrue(in_array($db->config['prefix'] . 'acos', $sources));
+ $this->assertFalse(in_array($db->config['prefix'] . 'aros', $sources));
$this->assertFalse(in_array('aros_acos', $sources));
}
+/**
+ * test run update with a table arg.
+ *
+ * @return void
+ **/
+ function testRunUpdateWithTable() {
+ $this->Shell->params = array(
+ 'name' => 'SchemaShellTest',
+ 'connection' => 'test_suite',
+ 'f' => true
+ );
+ $this->Shell->args = array('update', 'articles');
+ $this->Shell->startup();
+ $this->Shell->setReturnValue('in', 'y');
+ $this->Shell->run();
+
+ $article =& new Model(array('name' => 'Article', 'ds' => 'test_suite'));
+ $fields = $article->schema();
+ $this->assertTrue(isset($fields['summary']));
+
+ $this->_fixtures['core.article']->drop($this->db);
+ $this->_fixtures['core.article']->create($this->db);
+ }
+
}
?>
\ No newline at end of file
diff --git a/cake/tests/cases/libs/controller/components/email.test.php b/cake/tests/cases/libs/controller/components/email.test.php
index bd8fc6421..986aa78fc 100644
--- a/cake/tests/cases/libs/controller/components/email.test.php
+++ b/cake/tests/cases/libs/controller/components/email.test.php
@@ -505,10 +505,9 @@ TEXTBLOC;
$response = $this->Controller->EmailTest->smtpSend('HELO', '250');
$this->assertPattern('/501 Syntax: HELO hostname/', $this->Controller->EmailTest->smtpError);
- $this->Controller->EmailTest->smtpError = null;
+ $this->Controller->EmailTest->reset();
$response = $this->Controller->EmailTest->smtpSend('HELO somehostname', '250');
$this->assertNoPattern('/501 Syntax: HELO hostname/', $this->Controller->EmailTest->smtpError);
-
}
/**
diff --git a/cake/tests/cases/libs/model/behaviors/tree.test.php b/cake/tests/cases/libs/model/behaviors/tree.test.php
index 71b6f227b..6376e27a4 100644
--- a/cake/tests/cases/libs/model/behaviors/tree.test.php
+++ b/cake/tests/cases/libs/model/behaviors/tree.test.php
@@ -1174,12 +1174,12 @@ class NumberTreeTest extends CakeTestCase {
$data = $this->Tree->find(array($modelClass . '.name' => '1. Root'));
$this->Tree->id= $data[$modelClass]['id'];
- $direct = $this->Tree->children(null, true, array('id', 'name', $parentField, $leftField, $rightField), null, null, null, 1);
+ $direct = $this->Tree->children(null, true, array('id', 'name', $parentField, $leftField, $rightField));
$expects = array(array($modelClass => array('id' => 2, 'name' => '1.1', $parentField => 1, $leftField => 2, $rightField => 7)),
array($modelClass => array('id' => 5, 'name' => '1.2', $parentField => 1, $leftField => 8, $rightField => 13)));
$this->assertEqual($direct, $expects);
- $total = $this->Tree->children(null, null, array('id', 'name', $parentField, $leftField, $rightField), null, null, null, 1);
+ $total = $this->Tree->children(null, null, array('id', 'name', $parentField, $leftField, $rightField));
$expects = array(
array($modelClass => array('id' => 2, 'name' => '1.1', $parentField => 1, $leftField => 2, $rightField => 7)),
array($modelClass => array('id' => 3, 'name' => '1.1.1', $parentField => 2, $leftField => 3, $rightField => 4)),
@@ -1790,7 +1790,7 @@ class UuidTreeTest extends NumberTreeTest {
$this->Tree->initialize(2, 2);
$data = $this->Tree->find(array($modelClass . '.name' => '1. Root'));
- $this->Tree->id= $data[$modelClass]['id'];
+ $this->Tree->id = $data[$modelClass]['id'];
$direct = $this->Tree->children(null, true, array('name', $leftField, $rightField));
$expects = array(array($modelClass => array('name' => '1.1', $leftField => 2, $rightField => 7)),
@@ -1816,19 +1816,20 @@ class UuidTreeTest extends NumberTreeTest {
function testNoAmbiguousColumn() {
extract($this->settings);
$this->Tree =& new $modelClass();
- $this->Tree->bindModel(array('belongsTo' => array('Dummy' =>
- array('className' => $modelClass, 'foreignKey' => $parentField, 'conditions' => array('Dummy.id' => null)))), false);
$this->Tree->initialize(2, 2);
- $data = $this->Tree->find(array($modelClass . '.name' => '1. Root'));
- $this->Tree->id= $data[$modelClass]['id'];
+ $this->Tree->bindModel(array('belongsTo' => array('Dummy' =>
+ array('className' => $modelClass, 'foreignKey' => $parentField, 'conditions' => array('Dummy.id' => null)))), false);
- $direct = $this->Tree->children(null, true, array('name', $leftField, $rightField), null, null, null, 1);
+ $data = $this->Tree->find(array($modelClass . '.name' => '1. Root'));
+ $this->Tree->id = $data[$modelClass]['id'];
+
+ $direct = $this->Tree->children(null, true, array('name', $leftField, $rightField));
$expects = array(array($modelClass => array('name' => '1.1', $leftField => 2, $rightField => 7)),
array($modelClass => array('name' => '1.2', $leftField => 8, $rightField => 13)));
$this->assertEqual($direct, $expects);
- $total = $this->Tree->children(null, null, array('name', $leftField, $rightField), null, null, null, 1);
+ $total = $this->Tree->children(null, null, array('name', $leftField, $rightField));
$expects = array(
array($modelClass => array('name' => '1.1', $leftField => 2, $rightField => 7)),
array($modelClass => array('name' => '1.1.1', $leftField => 3, $rightField => 4)),
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 7cc0ca996..412c5137c 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
@@ -367,6 +367,18 @@ class DboMssqlTest extends CakeTestCase {
$expected = "'1,2'";
$result = $this->db->value('1,2', 'float');
$this->assertIdentical($expected, $result);
+
+ $expected = 'NULL';
+ $result = $this->db->value('', 'integer');
+ $this->assertIdentical($expected, $result);
+
+ $expected = 'NULL';
+ $result = $this->db->value('', 'float');
+ $this->assertIdentical($expected, $result);
+
+ $expected = 'NULL';
+ $result = $this->db->value('', 'binary');
+ $this->assertIdentical($expected, $result);
}
/**
* testFields method
@@ -544,6 +556,33 @@ class DboMssqlTest extends CakeTestCase {
$expected = '[name] varchar(255) DEFAULT \'\'';
$this->assertEqual($result, $expected);
}
+/**
+ * testBuildIndex method
+ *
+ * @return void
+ * @access public
+ */
+ function testBuildIndex() {
+ $indexes = array(
+ 'PRIMARY' => array('column' => 'id', 'unique' => 1),
+ 'client_id' => array('column' => 'client_id', 'unique' => 1)
+ );
+ $result = $this->db->buildIndex($indexes, 'items');
+ $expected = array(
+ 'PRIMARY KEY ([id])',
+ 'ALTER TABLE items ADD CONSTRAINT client_id UNIQUE([client_id]);'
+ );
+ $this->assertEqual($result, $expected);
+
+ $indexes = array('client_id' => array('column' => 'client_id'));
+ $result = $this->db->buildIndex($indexes, 'items');
+ $this->assertEqual($result, array());
+
+ $indexes = array('client_id' => array('column' => array('client_id', 'period_id'), 'unique' => 1));
+ $result = $this->db->buildIndex($indexes, 'items');
+ $expected = array('ALTER TABLE items ADD CONSTRAINT client_id UNIQUE([client_id], [period_id]);');
+ $this->assertEqual($result, $expected);
+ }
/**
* testUpdateAllSyntax method
*
diff --git a/cake/tests/cases/libs/model/model.test.php b/cake/tests/cases/libs/model/model.test.php
index 11e6f7262..cd6aa0bb8 100644
--- a/cake/tests/cases/libs/model/model.test.php
+++ b/cake/tests/cases/libs/model/model.test.php
@@ -73,7 +73,7 @@ class BaseModelTest extends CakeTestCase {
'core.counter_cache_user_nonstandard_primary_key',
'core.counter_cache_post_nonstandard_primary_key', 'core.uuidportfolio',
'core.uuiditems_uuidportfolio', 'core.uuiditems_uuidportfolio_numericid', 'core.fruit',
- 'core.fruits_uuid_tag', 'core.uuid_tag'
+ 'core.fruits_uuid_tag', 'core.uuid_tag', 'core.product_update_all', 'core.group_update_all'
);
/**
diff --git a/cake/tests/cases/libs/model/model_write.test.php b/cake/tests/cases/libs/model/model_write.test.php
index a8e86edc1..036a20bfb 100644
--- a/cake/tests/cases/libs/model/model_write.test.php
+++ b/cake/tests/cases/libs/model/model_write.test.php
@@ -26,8 +26,6 @@
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
*/
require_once dirname(__FILE__) . DS . 'model.test.php';
-require_once dirname(__FILE__) . DS . 'model_write.test.php';
-
/**
* ModelWriteTest
*
@@ -3938,6 +3936,167 @@ class ModelWriteTest extends BaseModelTest {
);
$this->assertEqual($TestModel->Comment->validationErrors, $expected);
}
+/**
+ * TestFindAllWithoutForeignKey
+ *
+ * @link http://code.cakephp.org/tickets/view/69
+ * @access public
+ * @return void
+ */
+ function testFindAllForeignKey() {
+ $this->loadFixtures('ProductUpdateAll', 'GroupUpdateAll');
+ $ProductUpdateAll =& new ProductUpdateAll();
+
+ $conditions = array('Group.name' => 'group one');
+
+ $ProductUpdateAll->bindModel(array(
+ 'belongsTo' => array(
+ 'Group' => array('className' => 'GroupUpdateAll')
+ )
+ ));
+
+ $ProductUpdateAll->belongsTo = array(
+ 'Group' => array('className' => 'GroupUpdateAll', 'foreignKey' => 'group_id')
+ );
+
+ $results = $ProductUpdateAll->find('all', compact('conditions'));
+ $this->assertTrue(!empty($results));
+
+ $ProductUpdateAll->bindModel(array('belongsTo'=>array('Group')));
+ $ProductUpdateAll->belongsTo = array(
+ 'Group' => array(
+ 'className' => 'GroupUpdateAll',
+ 'foreignKey' => false,
+ 'conditions' => 'ProductUpdateAll.groupcode = Group.code'
+ ));
+
+ $resultsFkFalse = $ProductUpdateAll->find('all', compact('conditions'));
+ $this->assertTrue(!empty($resultsFkFalse));
+ $expected = array(
+ '0' => array(
+ 'ProductUpdateAll' => array(
+ 'id' => 1,
+ 'name' => 'product one',
+ 'groupcode' => 120,
+ 'group_id' => 1),
+ 'Group' => array(
+ 'id' => 1,
+ 'name' => 'group one',
+ 'code' => 120)
+ ),
+ '1' => array(
+ 'ProductUpdateAll' => array(
+ 'id' => 2,
+ 'name' => 'product two',
+ 'groupcode' => 120,
+ 'group_id' => 1),
+ 'Group' => array(
+ 'id' => 1,
+ 'name' => 'group one',
+ 'code' => 120)
+ )
+
+ );
+ $this->assertEqual($results, $expected);
+ $this->assertEqual($resultsFkFalse, $expected);
+ }
+/**
+ * testProductUpdateAllWithForeignKey
+ *
+ * @link http://code.cakephp.org/tickets/view/69
+ * @access public
+ * @return void
+ */
+ function testProductUpdateAll() {
+ $this->loadFixtures('ProductUpdateAll', 'GroupUpdateAll');
+ $ProductUpdateAll =& new ProductUpdateAll();
+
+ $conditions = array('Group.name' => 'group one');
+
+ $ProductUpdateAll->bindModel(array('belongsTo' => array(
+ 'Group' => array('className' => 'GroupUpdateAll')))
+ );
+
+ $ProductUpdateAll->updateAll(array('name' => "'new product'"), $conditions);
+ $results = $ProductUpdateAll->find('all', array(
+ 'conditions' => array('ProductUpdateAll.name' => 'new product')
+ ));
+ $expected = array(
+ '0' => array(
+ 'ProductUpdateAll' => array(
+ 'id' => 1,
+ 'name' => 'new product',
+ 'groupcode' => 120,
+ 'group_id' => 1),
+ 'Group' => array(
+ 'id' => 1,
+ 'name' => 'group one',
+ 'code' => 120)
+ ),
+ '1' => array(
+ 'ProductUpdateAll' => array(
+ 'id' => 2,
+ 'name' => 'new product',
+ 'groupcode' => 120,
+ 'group_id' => 1),
+ 'Group' => array(
+ 'id' => 1,
+ 'name' => 'group one',
+ 'code' => 120)));
+
+ $this->assertEqual($results, $expected);
+ }
+/**
+ * testProductUpdateAllWithoutForeignKey
+ *
+ * @link http://code.cakephp.org/tickets/view/69
+ * @access public
+ * @return void
+ */
+ function testProductUpdateAllWithoutForeignKey() {
+ $this->loadFixtures('ProductUpdateAll', 'GroupUpdateAll');
+ $ProductUpdateAll =& new ProductUpdateAll();
+
+ $conditions = array('Group.name' => 'group one');
+
+ $ProductUpdateAll->bindModel(array('belongsTo' => array(
+ 'Group' => array('className' => 'GroupUpdateAll')
+ )));
+
+ $ProductUpdateAll->belongsTo = array(
+ 'Group' => array(
+ 'className' => 'GroupUpdateAll',
+ 'foreignKey' => false,
+ 'conditions' => 'ProductUpdateAll.groupcode = Group.code'
+ )
+ );
+
+ $ProductUpdateAll->updateAll(array('name' => "'new product'"), $conditions);
+ $resultsFkFalse = $ProductUpdateAll->find('all', array('conditions' => array('ProductUpdateAll.name'=>'new product')));
+ $expected = array(
+ '0' => array(
+ 'ProductUpdateAll' => array(
+ 'id' => 1,
+ 'name' => 'new product',
+ 'groupcode' => 120,
+ 'group_id' => 1),
+ 'Group' => array(
+ 'id' => 1,
+ 'name' => 'group one',
+ 'code' => 120)
+ ),
+ '1' => array(
+ 'ProductUpdateAll' => array(
+ 'id' => 2,
+ 'name' => 'new product',
+ 'groupcode' => 120,
+ 'group_id' => 1),
+ 'Group' => array(
+ 'id' => 1,
+ 'name' => 'group one',
+ 'code' => 120)));
+ $this->assertEqual($resultsFkFalse, $expected);
+ }
}
diff --git a/cake/tests/cases/libs/model/models.php b/cake/tests/cases/libs/model/models.php
index 47dc386bb..20262d74b 100644
--- a/cake/tests/cases/libs/model/models.php
+++ b/cake/tests/cases/libs/model/models.php
@@ -3389,4 +3389,16 @@ class UuidTagNoWith extends CakeTestModel {
);
}
+class ProductUpdateAll extends CakeTestModel {
+ var $name = 'ProductUpdateAll';
+ var $useTable = 'product_update_all';
+
+}
+
+class GroupUpdateAll extends CakeTestModel {
+ var $name = 'GroupUpdateAll';
+ var $useTable = 'group_update_all';
+
+}
+
?>
\ No newline at end of file
diff --git a/cake/tests/cases/libs/router.test.php b/cake/tests/cases/libs/router.test.php
index 7780a4448..528a06b2c 100644
--- a/cake/tests/cases/libs/router.test.php
+++ b/cake/tests/cases/libs/router.test.php
@@ -706,6 +706,20 @@ class RouterTest extends CakeTestCase {
));
$expected = '/admin/shows/show_tickets/edit/6';
$this->assertEqual($result, $expected);
+
+ Router::reload();
+
+ Router::setRequestInfo(array(
+ array('pass' => array(), 'action' => 'admin_index', 'plugin' => null, 'controller' => 'posts', 'prefix' => 'admin', 'admin' => true, 'url' => array('url' => 'admin/posts')),
+ array('base' => '', 'here' => '/admin/posts', 'webroot' => '/')
+ ));
+
+ Router::connect('/admin/posts/*', array('controller' => 'posts', 'action' => 'index', 'admin' => true));
+ Router::parse('/');
+
+ $result = Router::url(array('all'));
+ $expected = '/admin/posts/all';
+ $this->assertEqual($result, $expected);
}
/**
diff --git a/cake/tests/cases/libs/set.test.php b/cake/tests/cases/libs/set.test.php
index f57e9b482..1b7da9a22 100644
--- a/cake/tests/cases/libs/set.test.php
+++ b/cake/tests/cases/libs/set.test.php
@@ -345,6 +345,21 @@ class SetTest extends CakeTestCase {
);
$a = Set::sort($a, '{n}.Person.name', 'ASC');
$this->assertIdentical($a, $b);
+
+ $names = array(
+ array('employees' => array(array('name' => array('first' => 'John', 'last' => 'Doe')))),
+ array('employees' => array(array('name' => array('first' => 'Jane', 'last' => 'Doe')))),
+ array('employees' => array(array('name' => array()))),
+ array('employees' => array(array('name' => array())))
+ );
+ $result = Set::sort($names, '{n}.employees.0.name', 'asc', 1);
+ $expected = array(
+ array('employees' => array(array('name' => array('first' => 'John', 'last' => 'Doe')))),
+ array('employees' => array(array('name' => array('first' => 'Jane', 'last' => 'Doe')))),
+ array('employees' => array(array('name' => array()))),
+ array('employees' => array(array('name' => array())))
+ );
+ $this->assertEqual($result, $expected);
}
/**
@@ -1003,6 +1018,24 @@ class SetTest extends CakeTestCase {
$expected = array(array('name' => 'zipfile.zip','type' => 'application/zip','tmp_name' => '/tmp/php178.tmp','error' => 0,'size' => '564647'));
$r = Set::extract('/file/.[type=application/zip]', $f);
$this->assertEqual($r, $expected);
+
+ $hasMany = array(
+ 'Node' => array(
+ 'id' => 1,
+ 'name' => 'First',
+ 'state' => 50
+ ),
+ 'ParentNode' => array(
+ 0 => array(
+ 'id' => 2,
+ 'name' => 'Second',
+ 'state' => 60,
+ )
+ )
+ );
+ $result = Set::extract('/ParentNode/name', $hasMany);
+ $expected = array('Second');
+ $this->assertEqual($result, $expected);
}
/**
diff --git a/cake/tests/cases/libs/view/helpers/form.test.php b/cake/tests/cases/libs/view/helpers/form.test.php
index f0d010fdf..e8e7a7243 100644
--- a/cake/tests/cases/libs/view/helpers/form.test.php
+++ b/cake/tests/cases/libs/view/helpers/form.test.php
@@ -2331,14 +2331,14 @@ class FormHelperTest extends CakeTestCase {
}
/**
- * testFieldError method
+ * testError method
*
* Test field error generation
*
* @access public
* @return void
*/
- function testFieldError() {
+ function testError() {
$this->Form->validationErrors['Model']['field'] = 1;
$result = $this->Form->error('Model.field');
$this->assertTags($result, array('div' => array('class' => 'error-message'), 'Error in field Field', '/div'));
@@ -2365,6 +2365,15 @@ class FormHelperTest extends CakeTestCase {
$result = $this->Form->error('Model.field', "Badness!", array('wrap' => false, 'escape' => false));
$this->assertEqual($result, 'Badness!');
+
+ $this->Form->validationErrors['Model']['field'] = "email";
+ $result = $this->Form->error('Model.field', array('class' => 'field-error', 'email' => 'No good!'));
+ $expected = array(
+ 'div' => array('class' => 'field-error'),
+ 'No good!',
+ '/div'
+ );
+ $this->assertTags($result, $expected);
}
/**
@@ -3782,6 +3791,18 @@ class FormHelperTest extends CakeTestCase {
':',
);
$this->assertTags($result, $expected);
+
+ $result = $this->Form->input('published', array(
+ 'timeFormat' => 24,
+ 'interval' => 5,
+ 'selected' => strtotime('2009-09-03 13:37:00'),
+ 'type' => 'datetime'
+ ));
+ $this->assertPattern('/