Merge branch '1.3' into merger

Conflicts:
	cake/VERSION.txt
	cake/config/config.php
	cake/console/shells/tasks/template.php
	cake/dispatcher.php
	cake/libs/controller/component.php
	cake/libs/controller/components/email.php
	cake/libs/controller/scaffold.php
	cake/libs/model/datasources/dbo/dbo_mysqli.php
	cake/libs/view/helpers/cache.php
	cake/libs/view/pages/home.ctp
	cake/tests/cases/dispatcher.test.php
	cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php
	cake/tests/fixtures/datatype_fixture.php
This commit is contained in:
mark_story 2011-02-05 12:20:09 -05:00
commit e149c411fb
17 changed files with 174 additions and 75 deletions

View file

@ -145,9 +145,14 @@ class SchemaShell extends Shell {
} }
} }
$cacheDisable = Configure::read('Cache.disable');
Configure::write('Cache.disable', true);
$content = $this->Schema->read($options); $content = $this->Schema->read($options);
$content['file'] = $this->params['file']; $content['file'] = $this->params['file'];
Configure::write('Cache.disable', $cacheDisable);
if ($snapshot === true) { if ($snapshot === true) {
$Folder = new Folder($this->Schema->path); $Folder = new Folder($this->Schema->path);
$result = $Folder->read(); $result = $Folder->read();

View file

@ -57,8 +57,9 @@ class TemplateTask extends Shell {
$core = array_pop($paths); $core = array_pop($paths);
$separator = DS === '/' ? '/' : '\\\\'; $separator = DS === '/' ? '/' : '\\\\';
$core = preg_replace('#shells' . $separator . '$#', '', $core); $core = preg_replace('#shells' . $separator . '$#', '', $core);
$paths[] = $core;
$Folder = new Folder($core . 'templates' . DS . 'default'); $Folder = new Folder($core . 'templates' . DS . 'default');
$contents = $Folder->read(); $contents = $Folder->read();
$themeFolders = $contents[0]; $themeFolders = $contents[0];
@ -67,6 +68,7 @@ class TemplateTask extends Shell {
$paths[] = $this->_pluginPath($plugin) . 'console' . DS . 'shells' . DS; $paths[] = $this->_pluginPath($plugin) . 'console' . DS . 'shells' . DS;
$paths[] = $this->_pluginPath($plugin) . 'vendors' . DS . 'shells' . DS; $paths[] = $this->_pluginPath($plugin) . 'vendors' . DS . 'shells' . DS;
} }
$paths[] = $core;
// TEMPORARY TODO remove when all paths are DS terminated // TEMPORARY TODO remove when all paths are DS terminated
foreach ($paths as $i => $path) { foreach ($paths as $i => $path) {

View file

@ -274,10 +274,9 @@ class CakeRequest implements ArrayAccess {
if (!$base) { if (!$base) {
$base = $this->base; $base = $this->base;
} }
if ($base !== false) { if ($base !== false) {
$this->webroot = $base . '/'; $this->webroot = $base . '/';
return $base; return $this->base = $base;
} }
if (!$baseUrl) { if (!$baseUrl) {
$replace = array('<', '>', '*', '\'', '"'); $replace = array('<', '>', '*', '\'', '"');
@ -306,7 +305,11 @@ class CakeRequest implements ArrayAccess {
} }
$this->webroot = $base . '/'; $this->webroot = $base . '/';
if (!empty($base)) { $docRoot = env('DOCUMENT_ROOT');
$script = realpath(env('SCRIPT_FILENAME'));
$docRootContainsWebroot = strpos($docRoot, $dir . '/' . $webroot);
if (!empty($base) || !$docRootContainsWebroot) {
if (strpos($this->webroot, $dir) === false) { if (strpos($this->webroot, $dir) === false) {
$this->webroot .= $dir . '/' ; $this->webroot .= $dir . '/' ;
} }

View file

@ -157,7 +157,7 @@ class EmailComponent extends Component {
/** /**
* Line feed character(s) to be used when sending using mail() function * Line feed character(s) to be used when sending using mail() function
* If null PHP_EOL is used. * By default PHP_EOL is used.
* RFC2822 requires it to be CRLF but some Unix * RFC2822 requires it to be CRLF but some Unix
* mail transfer agents replace LF by CRLF automatically * mail transfer agents replace LF by CRLF automatically
* (which leads to doubling CR if CRLF is used). * (which leads to doubling CR if CRLF is used).
@ -165,7 +165,7 @@ class EmailComponent extends Component {
* @var string * @var string
* @access public * @access public
*/ */
var $lineFeed = null; var $lineFeed = PHP_EOL;
/** /**
* @deprecated see lineLength * @deprecated see lineLength
@ -822,13 +822,8 @@ class EmailComponent extends Component {
* @access private * @access private
*/ */
function _mail() { function _mail() {
if ($this->lineFeed === null) { $header = implode($this->lineFeed, $this->_header);
$lineFeed = PHP_EOL; $message = implode($this->lineFeed, $this->_message);
} else {
$lineFeed = $this->lineFeed;
}
$header = implode($lineFeed, $this->_header);
$message = implode($lineFeed, $this->_message);
if (is_array($this->to)) { if (is_array($this->to)) {
$to = implode(', ', array_map(array($this, '_formatAddress'), $this->to)); $to = implode(', ', array_map(array($this, '_formatAddress'), $this->to));
} else { } else {

View file

@ -263,11 +263,16 @@ class CakeSchema extends Object {
} }
if (is_object($Object->$class)) { if (is_object($Object->$class)) {
$withTable = $db->fullTableName($Object->$class, false); $withTable = $db->fullTableName($Object->$class, false);
if ($prefix && strpos($withTable, $prefix) !== 0) {
continue;
}
if (in_array($withTable, $currentTables)) { if (in_array($withTable, $currentTables)) {
$key = array_search($withTable, $currentTables); $key = array_search($withTable, $currentTables);
$tables[$withTable] = $this->__columns($Object->$class); $noPrefixWith = str_replace($prefix, '', $withTable);
$tables[$withTable]['indexes'] = $db->index($Object->$class);
$tables[$withTable]['tableParameters'] = $db->readTableParameters($withTable); $tables[$noPrefixWith] = $this->__columns($Object->$class);
$tables[$noPrefixWith]['indexes'] = $db->index($Object->$class);
$tables[$noPrefixWith]['tableParameters'] = $db->readTableParameters($withTable);
unset($currentTables[$key]); unset($currentTables[$key]);
} }
} }

View file

@ -240,6 +240,9 @@ class DboPostgres extends DboSource {
$this->_sequenceMap[$table][$c->default] = $seq[1]; $this->_sequenceMap[$table][$c->default] = $seq[1];
} }
} }
if ($fields[$c->name]['type'] == 'boolean' && !empty($fields[$c->name]['default'])) {
$fields[$c->name]['default'] = constant($fields[$c->name]['default']);
}
} }
$this->__cacheDescription($table, $fields); $this->__cacheDescription($table, $fields);
} }

View file

@ -702,7 +702,7 @@ class DboSource extends DataSource {
); );
} }
if ( if (
preg_match('/^([\w-]+(\.[\w-]+|\(.*\))*)\s+' . preg_quote($this->alias) . '\s*([\w-]+)$/', $data, $matches preg_match('/^([\w-]+(\.[\w-]+|\(.*\))*)\s+' . preg_quote($this->alias) . '\s*([\w-]+)$/i', $data, $matches
)) { )) {
return $this->cacheMethod( return $this->cacheMethod(
__FUNCTION__, $cacheKey, __FUNCTION__, $cacheKey,

View file

@ -1146,11 +1146,11 @@ class Model extends Object {
if ($data !== null && $data !== false) { if ($data !== null && $data !== false) {
foreach ($this->schema() as $field => $properties) { foreach ($this->schema() as $field => $properties) {
if ($this->primaryKey !== $field && isset($properties['default'])) { if ($this->primaryKey !== $field && isset($properties['default']) && $properties['default'] !== '') {
$defaults[$field] = $properties['default']; $defaults[$field] = $properties['default'];
} }
} }
$this->set(Set::filter($defaults)); $this->set($defaults);
$this->set($data); $this->set($data);
} }
if ($filterKey) { if ($filterKey) {

View file

@ -241,9 +241,10 @@ class CacheHelper extends AppHelper {
$controller->layout = $this->layout = \'' . $this->_View->layout. '\'; $controller->layout = $this->layout = \'' . $this->_View->layout. '\';
$controller->request = $this->request = unserialize(\'' . str_replace("'", "\\'", serialize($this->request)) . '\'); $controller->request = $this->request = unserialize(\'' . str_replace("'", "\\'", serialize($this->request)) . '\');
$controller->theme = $this->theme = \'' . $this->_View->theme . '\'; $controller->theme = $this->theme = \'' . $this->_View->theme . '\';
$controller->viewVars = $this->viewVars = ' . var_export($this->_View->viewVars, true) . '; $controller->viewVars = unserialize(base64_decode(\'' . base64_encode(serialize($this->_View->viewVars)) . '\'));
Router::setRequestInfo($controller->request);'; Router::setRequestInfo($controller->request);';
if ($useCallbacks == true) { if ($useCallbacks == true) {
$file .= ' $file .= '
$controller->constructClasses(); $controller->constructClasses();

View file

@ -1848,11 +1848,14 @@ class FormHelper extends AppHelper {
if ($time[0] == 0 && $timeFormat == '12') { if ($time[0] == 0 && $timeFormat == '12') {
$time[0] = 12; $time[0] = 12;
} }
$hour = $min = null;
if (isset($time[1])) {
$hour = $time[0]; $hour = $time[0];
$min = $time[1]; $min = $time[1];
} }
} }
} }
}
$elements = array('Day', 'Month', 'Year', 'Hour', 'Minute', 'Meridian'); $elements = array('Day', 'Month', 'Year', 'Hour', 'Minute', 'Meridian');
$defaults = array( $defaults = array(
@ -2197,10 +2200,19 @@ class FormHelper extends AppHelper {
} else { } else {
$secure = (isset($this->request['_Token']) && !empty($this->request['_Token'])); $secure = (isset($this->request['_Token']) && !empty($this->request['_Token']));
} }
$fieldName = null;
if ($secure && !empty($options['name'])) {
preg_match_all('/\[(.*?)\]/', $options['name'], $matches);
if (isset($matches[1])) {
$fieldName = $matches[1];
}
}
$result = parent::_initInputField($field, $options); $result = parent::_initInputField($field, $options);
if ($secure) { if ($secure) {
$this->__secure(); $this->__secure($fieldName);
} }
return $result; return $result;
} }

View file

@ -926,12 +926,6 @@ class CakeRequestTestCase extends CakeTestCase {
$this->assertEqual($request->base, '/app/index.php'); $this->assertEqual($request->base, '/app/index.php');
$this->assertEqual($request->webroot, '/app/webroot/'); $this->assertEqual($request->webroot, '/app/webroot/');
Configure::write('App.baseUrl', '/index.php');
$request = new CakeRequest();
$this->assertEqual($request->base, '/index.php');
$this->assertEqual($request->webroot, '/');
Configure::write('App.baseUrl', '/CakeBB/app/webroot/index.php'); Configure::write('App.baseUrl', '/CakeBB/app/webroot/index.php');
$request = new CakeRequest(); $request = new CakeRequest();
$this->assertEqual($request->base, '/CakeBB/app/webroot/index.php'); $this->assertEqual($request->base, '/CakeBB/app/webroot/index.php');
@ -958,6 +952,36 @@ class CakeRequestTestCase extends CakeTestCase {
$this->assertEqual($request->webroot, '/dbhauser/app/webroot/'); $this->assertEqual($request->webroot, '/dbhauser/app/webroot/');
} }
/**
* test baseUrl with no rewrite and using the top level index.php.
*
* @return void
*/
function testBaseUrlNoRewriteTopLevelIndex() {
Configure::write('App.baseUrl', '/index.php');
$_SERVER['DOCUMENT_ROOT'] = '/Users/markstory/Sites/cake_dev';
$_SERVER['SCRIPT_FILENAME'] = '/Users/markstory/Sites/cake_dev/index.php';
$request = new CakeRequest();
$this->assertEqual('/index.php', $request->base);
$this->assertEqual('/app/webroot/', $request->webroot);
}
/**
* test baseUrl with no rewrite, and using the app/webroot/index.php file as is normal with virtual hosts.
*
* @return void
*/
function testBaseUrlNoRewriteWebrootIndex() {
Configure::write('App.baseUrl', '/index.php');
$_SERVER['DOCUMENT_ROOT'] = '/Users/markstory/Sites/cake_dev/app/webroot';
$_SERVER['SCRIPT_FILENAME'] = '/Users/markstory/Sites/cake_dev/app/webroot/index.php';
$request = new CakeRequest();
$this->assertEqual('/index.php', $request->base);
$this->assertEqual('/', $request->webroot);
}
/** /**
* testEnvironmentDetection method * testEnvironmentDetection method
* *

View file

@ -439,6 +439,9 @@ TEMPDOC;
* @return void * @return void
*/ */
function testSmtpSendMultipleTo() { function testSmtpSendMultipleTo() {
if ($this->skipIf(!@fsockopen('localhost', 25), '%s No SMTP server running on localhost')) {
return;
}
$this->Controller->EmailTest->reset(); $this->Controller->EmailTest->reset();
$this->Controller->EmailTest->to = array('postmaster@localhost', 'root@localhost'); $this->Controller->EmailTest->to = array('postmaster@localhost', 'root@localhost');
$this->Controller->EmailTest->from = 'noreply@example.com'; $this->Controller->EmailTest->from = 'noreply@example.com';

View file

@ -215,6 +215,7 @@ class DboPostgresTest extends CakeTestCase {
*/ */
public $fixtures = array('core.user', 'core.binary_test', 'core.comment', 'core.article', public $fixtures = array('core.user', 'core.binary_test', 'core.comment', 'core.article',
'core.tag', 'core.articles_tag', 'core.attachment', 'core.person', 'core.post', 'core.author', 'core.tag', 'core.articles_tag', 'core.attachment', 'core.person', 'core.post', 'core.author',
'core.datatype',
); );
/** /**
* Actual DB connection used in testing * Actual DB connection used in testing
@ -396,19 +397,32 @@ class DboPostgresTest extends CakeTestCase {
* @return void * @return void
*/ */
function testBooleanNormalization() { function testBooleanNormalization() {
$this->assertEquals(1, $this->Dbo2->boolean('t', false)); $this->assertEquals(true, $this->Dbo2->boolean('t', false));
$this->assertEquals(1, $this->Dbo2->boolean('true', false)); $this->assertEquals(true, $this->Dbo2->boolean('true', false));
$this->assertEquals(1, $this->Dbo2->boolean('TRUE', false)); $this->assertEquals(true, $this->Dbo2->boolean('TRUE', false));
$this->assertEquals(1, $this->Dbo2->boolean(true, false)); $this->assertEquals(true, $this->Dbo2->boolean(true, false));
$this->assertEquals(1, $this->Dbo2->boolean(1, false)); $this->assertEquals(true, $this->Dbo2->boolean(1, false));
$this->assertEquals(1, $this->Dbo2->boolean(" ", false)); $this->assertEquals(true, $this->Dbo2->boolean(" ", false));
$this->assertEquals(0, $this->Dbo2->boolean('f', false)); $this->assertEquals(false, $this->Dbo2->boolean('f', false));
$this->assertEquals(0, $this->Dbo2->boolean('false', false)); $this->assertEquals(false, $this->Dbo2->boolean('false', false));
$this->assertEquals(0, $this->Dbo2->boolean('FALSE', false)); $this->assertEquals(false, $this->Dbo2->boolean('FALSE', false));
$this->assertEquals(0, $this->Dbo2->boolean(false, false)); $this->assertEquals(false, $this->Dbo2->boolean(false, false));
$this->assertEquals(0, $this->Dbo2->boolean(0, false)); $this->assertEquals(false, $this->Dbo2->boolean(0, false));
$this->assertEquals(0, $this->Dbo2->boolean('', false)); $this->assertEquals(false, $this->Dbo2->boolean('', false));
}
/**
* test that default -> false in schemas works correctly.
*
* @return void
*/
function testBooleanDefaultFalseInSchema() {
$this->loadFixtures('Datatype');
$model = new Model(array('name' => 'Datatype', 'table' => 'datatypes', 'ds' => 'test'));
$model->create();
$this->assertIdentical(false, $model->data['Datatype']['bool']);
} }
/** /**
@ -421,18 +435,16 @@ class DboPostgresTest extends CakeTestCase {
$this->loadFixtures('User'); $this->loadFixtures('User');
$db1 = ConnectionManager::getDataSource('test'); $db1 = ConnectionManager::getDataSource('test');
$db2 = clone $db1;
$db2->connect();
$this->assertNotSame($db1->getConnection(), $db2->getConnection());
$table = $db1->fullTableName('users', false); $table = $db1->fullTableName('users', false);
$password = '5f4dcc3b5aa765d61d8327deb882cf99'; $password = '5f4dcc3b5aa765d61d8327deb882cf99';
$db1->execute( $db1->execute(
"INSERT INTO {$table} (\"user\", password) VALUES ('mariano', '{$password}')" "INSERT INTO {$table} (\"user\", password) VALUES ('mariano', '{$password}')"
); );
$db2->execute("INSERT INTO {$table} (\"user\", password) VALUES ('hoge', '{$password}')");
$this->assertEqual($db1->lastInsertId($table), 5); $this->assertEqual($db1->lastInsertId($table), 5);
$this->assertEqual($db2->lastInsertId($table), 6);
$db1->execute("INSERT INTO {$table} (\"user\", password) VALUES ('hoge', '{$password}')");
$this->assertEqual($db1->lastInsertId($table), 6);
} }
/** /**
@ -552,7 +564,8 @@ class DboPostgresTest extends CakeTestCase {
$db1 = ConnectionManager::getDataSource('test'); $db1 = ConnectionManager::getDataSource('test');
$db1->cacheSources = false; $db1->cacheSources = false;
$db1->reconnect(array('persistent' => false)); $db1->reconnect(array('persistent' => false));
$db1->rawQuery('CREATE TABLE ' . $db1->fullTableName('datatypes') . ' (
$db1->rawQuery('CREATE TABLE ' . $db1->fullTableName('datatype_tests') . ' (
id serial NOT NULL, id serial NOT NULL,
"varchar" character varying(40) NOT NULL, "varchar" character varying(40) NOT NULL,
"full_length" character varying NOT NULL, "full_length" character varying NOT NULL,
@ -560,31 +573,34 @@ class DboPostgresTest extends CakeTestCase {
"date" date, "date" date,
CONSTRAINT test_data_types_pkey PRIMARY KEY (id) CONSTRAINT test_data_types_pkey PRIMARY KEY (id)
)'); )');
$model = new Model(array('name' => 'Datatype', 'ds' => 'test'));
$model = new Model(array('name' => 'DatatypeTest', 'ds' => 'test'));
$schema = new CakeSchema(array('connection' => 'test')); $schema = new CakeSchema(array('connection' => 'test'));
$result = $schema->read(array( $result = $schema->read(array(
'connection' => 'test', 'connection' => 'test',
'models' => array('Datatype') 'models' => array('DatatypeTest')
)); ));
$schema->tables = array('datatype_tests' => $result['tables']['missing']['datatype_tests']);
$result = $db1->createSchema($schema, 'datatype_tests');
$schema->tables = array('datatypes' => $result['tables']['missing']['datatypes']);
$result = $db1->createSchema($schema, 'datatypes');
$db1->rawQuery('DROP TABLE ' . $db1->fullTableName('datatypes'));
$this->assertNoPattern('/timestamp DEFAULT/', $result); $this->assertNoPattern('/timestamp DEFAULT/', $result);
$this->assertPattern('/\"full_length\"\s*text\s.*,/', $result); $this->assertPattern('/\"full_length\"\s*text\s.*,/', $result);
$this->assertPattern('/timestamp\s*,/', $result); $this->assertPattern('/timestamp\s*,/', $result);
$db1->query('DROP TABLE ' . $db1->fullTableName('datatype_tests'));
$db1->query($result); $db1->query($result);
$result2 = $schema->read(array( $result2 = $schema->read(array(
'connection' => 'test', 'connection' => 'test',
'models' => array('Datatype') 'models' => array('DatatypeTest')
)); ));
$schema->tables = array('datatypes' => $result2['tables']['missing']['datatypes']); $schema->tables = array('datatype_tests' => $result2['tables']['missing']['datatype_tests']);
$result2 = $db1->createSchema($schema, 'datatypes'); $result2 = $db1->createSchema($schema, 'datatype_tests');
$this->assertEqual($result, $result2); $this->assertEqual($result, $result2);
$db1->query('DROP TABLE ' . $db1->fullTableName('datatypes')); $db1->query('DROP TABLE ' . $db1->fullTableName('datatype_tests'));
} }
/** /**
@ -598,9 +614,9 @@ class DboPostgresTest extends CakeTestCase {
$this->Dbo->query('CREATE INDEX pointless_bool ON ' . $name . '("bool")'); $this->Dbo->query('CREATE INDEX pointless_bool ON ' . $name . '("bool")');
$this->Dbo->query('CREATE UNIQUE INDEX char_index ON ' . $name . '("small_char")'); $this->Dbo->query('CREATE UNIQUE INDEX char_index ON ' . $name . '("small_char")');
$expected = array( $expected = array(
'PRIMARY' => array('column' => 'id', 'unique' => 1), 'PRIMARY' => array('unique' => true, 'column' => 'id'),
'pointless_bool' => array('column' => 'bool', 'unique' => 0), 'pointless_bool' => array('unique' => false, 'column' => 'bool'),
'char_index' => array('column' => 'small_char', 'unique' => 1), 'char_index' => array('unique' => true, 'column' => 'small_char'),
); );
$result = $this->Dbo->index($name); $result = $this->Dbo->index($name);
@ -611,8 +627,8 @@ class DboPostgresTest extends CakeTestCase {
$this->Dbo->query('CREATE TABLE ' . $name . ' ("id" serial NOT NULL PRIMARY KEY, "bool" integer, "small_char" varchar(50), "description" varchar(40) )'); $this->Dbo->query('CREATE TABLE ' . $name . ' ("id" serial NOT NULL PRIMARY KEY, "bool" integer, "small_char" varchar(50), "description" varchar(40) )');
$this->Dbo->query('CREATE UNIQUE INDEX multi_col ON ' . $name . '("small_char", "bool")'); $this->Dbo->query('CREATE UNIQUE INDEX multi_col ON ' . $name . '("small_char", "bool")');
$expected = array( $expected = array(
'PRIMARY' => array('column' => 'id', 'unique' => 1), 'PRIMARY' => array('unique' => true, 'column' => 'id'),
'multi_col' => array('column' => array('small_char', 'bool'), 'unique' => 1), 'multi_col' => array('unique' => true, 'column' => array('small_char', 'bool')),
); );
$result = $this->Dbo->index($name); $result = $this->Dbo->index($name);
$this->Dbo->query('DROP TABLE ' . $name); $this->Dbo->query('DROP TABLE ' . $name);
@ -687,6 +703,7 @@ class DboPostgresTest extends CakeTestCase {
'group2' => array('type' => 'integer', 'null' => true) 'group2' => array('type' => 'integer', 'null' => true)
) )
)); ));
$this->Dbo->rawQuery($this->Dbo->dropSchema($schema1));
$this->Dbo->rawQuery($this->Dbo->createSchema($schema1)); $this->Dbo->rawQuery($this->Dbo->createSchema($schema1));
$schema2 = new CakeSchema(array( $schema2 = new CakeSchema(array(
@ -698,10 +715,10 @@ class DboPostgresTest extends CakeTestCase {
'group1' => array('type' => 'integer', 'null' => 1), 'group1' => array('type' => 'integer', 'null' => 1),
'group2' => array('type' => 'integer', 'null' => 1), 'group2' => array('type' => 'integer', 'null' => 1),
'indexes' => array( 'indexes' => array(
'name_idx' => array('column' => 'name', 'unique' => 0), 'name_idx' => array('unique' => false, 'column' => 'name'),
'group_idx' => array('column' => 'group1', 'unique' => 0), 'group_idx' => array('unique' => false, 'column' => 'group1'),
'compound_idx' => array('column' => array('group1', 'group2'), 'unique' => 0), 'compound_idx' => array('unique' => false, 'column' => array('group1', 'group2')),
'PRIMARY' => array('column' => 'id', 'unique' => 1) 'PRIMARY' => array('unique' => true, 'column' => 'id')
) )
) )
)); ));
@ -720,10 +737,10 @@ class DboPostgresTest extends CakeTestCase {
'group1' => array('type' => 'integer', 'null' => 1), 'group1' => array('type' => 'integer', 'null' => 1),
'group2' => array('type' => 'integer', 'null' => 1), 'group2' => array('type' => 'integer', 'null' => 1),
'indexes' => array( 'indexes' => array(
'name_idx' => array('column' => 'name', 'unique' => 1), 'name_idx' => array('unique' => true, 'column' => 'name'),
'group_idx' => array('column' => 'group2', 'unique' => 0), 'group_idx' => array('unique' => false, 'column' => 'group2'),
'compound_idx' => array('column' => array('group2', 'group1'), 'unique' => 0), 'compound_idx' => array('unique' => false, 'column' => array('group2', 'group1')),
'another_idx' => array('column' => array('group1', 'name'), 'unique' => 0)) 'another_idx' => array('unique' => false, 'column' => array('group1', 'name')))
))); )));
$this->Dbo->query($this->Dbo->alterSchema($schema3->compare($schema2))); $this->Dbo->query($this->Dbo->alterSchema($schema3->compare($schema2)));

View file

@ -580,6 +580,10 @@ class DboSourceTest extends CakeTestCase {
$result = $this->testDb->name(array('Team.P%', 'Team.G/G')); $result = $this->testDb->name(array('Team.P%', 'Team.G/G'));
$expected = array('`Team`.`P%`', '`Team`.`G/G`'); $expected = array('`Team`.`P%`', '`Team`.`G/G`');
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
$result = $this->testDb->name('Model.name as y');
$expected = '`Model`.`name` AS `y`';
$this->assertEqual($result, $expected);
} }
/** /**

View file

@ -318,7 +318,6 @@ class CacheHelperTest extends CakeTestCase {
$this->assertPattern('/\$this\-\>viewVars/', $contents); $this->assertPattern('/\$this\-\>viewVars/', $contents);
$this->assertPattern('/extract\(\$this\-\>viewVars, EXTR_SKIP\);/', $contents); $this->assertPattern('/extract\(\$this\-\>viewVars, EXTR_SKIP\);/', $contents);
$this->assertPattern('/php echo \$variable/', $contents); $this->assertPattern('/php echo \$variable/', $contents);
$this->assertPattern('/variableValue/', $contents);
@unlink($filename); @unlink($filename);
} }

View file

@ -1073,6 +1073,21 @@ class FormHelperTest extends CakeTestCase {
$this->assertTags($result, $expected); $this->assertTags($result, $expected);
} }
/**
* test securing inputs with custom name attributes.
*
* @return void
*/
function testFormSecureWithCustomNameAttribute() {
$this->Form->params['_Token']['key'] = 'testKey';
$this->Form->text('UserForm.published', array('name' => 'data[User][custom]'));
$this->assertEqual('User.custom', $this->Form->fields[0]);
$this->Form->text('UserForm.published', array('name' => 'data[User][custom][another][value]'));
$this->assertEqual('User.custom.another.value', $this->Form->fields[1]);
}
/** /**
* testFormSecuredInput method * testFormSecuredInput method
* *
@ -4466,6 +4481,16 @@ class FormHelperTest extends CakeTestCase {
$this->assertPattern('/<option[^<>]+value="06"[^<>]+selected="selected"[^>]*>June<\/option>/', $result); $this->assertPattern('/<option[^<>]+value="06"[^<>]+selected="selected"[^>]*>June<\/option>/', $result);
} }
/**
* test that bogus non-date time data doesn't cause errors.
*
* @return void
*/
function testDateTimeWithBogusData() {
$result = $this->Form->dateTime('Contact.updated', 'DMY', '12', 'CURRENT_TIMESTAMP');
$this->assertNoPattern('/selected="selected">\d/', $result);
}
/** /**
* testFormDateTimeMulti method * testFormDateTimeMulti method
* *

View file

@ -41,6 +41,7 @@ class DatatypeFixture extends CakeTestFixture {
public $fields = array( public $fields = array(
'id' => array('type' => 'integer', 'null'=> false, 'default'=> 0, 'key' => 'primary'), 'id' => array('type' => 'integer', 'null'=> false, 'default'=> 0, 'key' => 'primary'),
'float_field' => array('type' => 'float', 'length' => '5,2', 'null' => false, 'default' => null), 'float_field' => array('type' => 'float', 'length' => '5,2', 'null' => false, 'default' => null),
'bool' => array('type' => 'boolean', 'null' => false, 'default' => false),
); );
/** /**
@ -49,7 +50,7 @@ class DatatypeFixture extends CakeTestFixture {
* @var array * @var array
* @access public * @access public
*/ */
public $records = array( var $records = array(
array('id' => 1, 'float_field' => 42.23), array('id' => 1, 'float_field' => 42.23, 'bool' => false),
); );
} }