diff --git a/cake/console/shells/schema.php b/cake/console/shells/schema.php index c0fe44751..3c16edd81 100644 --- a/cake/console/shells/schema.php +++ b/cake/console/shells/schema.php @@ -145,8 +145,13 @@ class SchemaShell extends Shell { } } + $cacheDisable = Configure::read('Cache.disable'); + Configure::write('Cache.disable', true); + $content = $this->Schema->read($options); $content['file'] = $this->params['file']; + + Configure::write('Cache.disable', $cacheDisable); if ($snapshot === true) { $Folder = new Folder($this->Schema->path); diff --git a/cake/console/shells/tasks/template.php b/cake/console/shells/tasks/template.php index 108ffa8a4..d23fc21d1 100644 --- a/cake/console/shells/tasks/template.php +++ b/cake/console/shells/tasks/template.php @@ -57,8 +57,9 @@ class TemplateTask extends Shell { $core = array_pop($paths); $separator = DS === '/' ? '/' : '\\\\'; $core = preg_replace('#shells' . $separator . '$#', '', $core); - $paths[] = $core; + $Folder = new Folder($core . 'templates' . DS . 'default'); + $contents = $Folder->read(); $themeFolders = $contents[0]; @@ -67,6 +68,7 @@ class TemplateTask extends Shell { $paths[] = $this->_pluginPath($plugin) . 'console' . DS . 'shells' . DS; $paths[] = $this->_pluginPath($plugin) . 'vendors' . DS . 'shells' . DS; } + $paths[] = $core; // TEMPORARY TODO remove when all paths are DS terminated foreach ($paths as $i => $path) { diff --git a/cake/libs/cake_request.php b/cake/libs/cake_request.php index 90ffa8cbf..1f2cfd037 100644 --- a/cake/libs/cake_request.php +++ b/cake/libs/cake_request.php @@ -274,10 +274,9 @@ class CakeRequest implements ArrayAccess { if (!$base) { $base = $this->base; } - if ($base !== false) { $this->webroot = $base . '/'; - return $base; + return $this->base = $base; } if (!$baseUrl) { $replace = array('<', '>', '*', '\'', '"'); @@ -304,9 +303,13 @@ class CakeRequest implements ArrayAccess { if ($base === DS || $base === '.') { $base = ''; } - $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) { $this->webroot .= $dir . '/' ; } diff --git a/cake/libs/controller/components/email.php b/cake/libs/controller/components/email.php index e9ee33a75..f575cee5c 100755 --- a/cake/libs/controller/components/email.php +++ b/cake/libs/controller/components/email.php @@ -157,7 +157,7 @@ class EmailComponent extends Component { /** * 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 * mail transfer agents replace LF by CRLF automatically * (which leads to doubling CR if CRLF is used). @@ -165,7 +165,7 @@ class EmailComponent extends Component { * @var string * @access public */ - var $lineFeed = null; + var $lineFeed = PHP_EOL; /** * @deprecated see lineLength @@ -822,13 +822,8 @@ class EmailComponent extends Component { * @access private */ function _mail() { - if ($this->lineFeed === null) { - $lineFeed = PHP_EOL; - } else { - $lineFeed = $this->lineFeed; - } - $header = implode($lineFeed, $this->_header); - $message = implode($lineFeed, $this->_message); + $header = implode($this->lineFeed, $this->_header); + $message = implode($this->lineFeed, $this->_message); if (is_array($this->to)) { $to = implode(', ', array_map(array($this, '_formatAddress'), $this->to)); } else { diff --git a/cake/libs/model/cake_schema.php b/cake/libs/model/cake_schema.php index c083c7356..ab8d01b67 100644 --- a/cake/libs/model/cake_schema.php +++ b/cake/libs/model/cake_schema.php @@ -263,11 +263,16 @@ class CakeSchema extends Object { } if (is_object($Object->$class)) { $withTable = $db->fullTableName($Object->$class, false); + if ($prefix && strpos($withTable, $prefix) !== 0) { + continue; + } if (in_array($withTable, $currentTables)) { $key = array_search($withTable, $currentTables); - $tables[$withTable] = $this->__columns($Object->$class); - $tables[$withTable]['indexes'] = $db->index($Object->$class); - $tables[$withTable]['tableParameters'] = $db->readTableParameters($withTable); + $noPrefixWith = str_replace($prefix, '', $withTable); + + $tables[$noPrefixWith] = $this->__columns($Object->$class); + $tables[$noPrefixWith]['indexes'] = $db->index($Object->$class); + $tables[$noPrefixWith]['tableParameters'] = $db->readTableParameters($withTable); unset($currentTables[$key]); } } diff --git a/cake/libs/model/datasources/dbo/dbo_postgres.php b/cake/libs/model/datasources/dbo/dbo_postgres.php index 9a397a0cc..2b53aa1e5 100644 --- a/cake/libs/model/datasources/dbo/dbo_postgres.php +++ b/cake/libs/model/datasources/dbo/dbo_postgres.php @@ -240,6 +240,9 @@ class DboPostgres extends DboSource { $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); } diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php index d9423399b..c57124a5a 100755 --- a/cake/libs/model/datasources/dbo_source.php +++ b/cake/libs/model/datasources/dbo_source.php @@ -702,7 +702,7 @@ class DboSource extends DataSource { ); } 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( __FUNCTION__, $cacheKey, diff --git a/cake/libs/model/model.php b/cake/libs/model/model.php index a375dc2eb..b7899582a 100644 --- a/cake/libs/model/model.php +++ b/cake/libs/model/model.php @@ -1146,11 +1146,11 @@ class Model extends Object { if ($data !== null && $data !== false) { 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']; } } - $this->set(Set::filter($defaults)); + $this->set($defaults); $this->set($data); } if ($filterKey) { diff --git a/cake/libs/view/helpers/cache.php b/cake/libs/view/helpers/cache.php index 017ca89f9..3ee75c3fd 100644 --- a/cake/libs/view/helpers/cache.php +++ b/cake/libs/view/helpers/cache.php @@ -241,9 +241,10 @@ class CacheHelper extends AppHelper { $controller->layout = $this->layout = \'' . $this->_View->layout. '\'; $controller->request = $this->request = unserialize(\'' . str_replace("'", "\\'", serialize($this->request)) . '\'); $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);'; + if ($useCallbacks == true) { $file .= ' $controller->constructClasses(); diff --git a/cake/libs/view/helpers/form.php b/cake/libs/view/helpers/form.php index 92e87fb3e..18af5b2b8 100644 --- a/cake/libs/view/helpers/form.php +++ b/cake/libs/view/helpers/form.php @@ -1848,8 +1848,11 @@ class FormHelper extends AppHelper { if ($time[0] == 0 && $timeFormat == '12') { $time[0] = 12; } - $hour = $time[0]; - $min = $time[1]; + $hour = $min = null; + if (isset($time[1])) { + $hour = $time[0]; + $min = $time[1]; + } } } } @@ -2197,10 +2200,19 @@ class FormHelper extends AppHelper { } else { $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); if ($secure) { - $this->__secure(); + $this->__secure($fieldName); } return $result; } diff --git a/cake/tests/cases/libs/cake_request.test.php b/cake/tests/cases/libs/cake_request.test.php index 58cc50631..0d276169d 100644 --- a/cake/tests/cases/libs/cake_request.test.php +++ b/cake/tests/cases/libs/cake_request.test.php @@ -926,12 +926,6 @@ class CakeRequestTestCase extends CakeTestCase { $this->assertEqual($request->base, '/app/index.php'); $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'); $request = new CakeRequest(); $this->assertEqual($request->base, '/CakeBB/app/webroot/index.php'); @@ -958,6 +952,36 @@ class CakeRequestTestCase extends CakeTestCase { $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 * diff --git a/cake/tests/cases/libs/controller/components/email.test.php b/cake/tests/cases/libs/controller/components/email.test.php index 878cc0da2..a089ec319 100755 --- a/cake/tests/cases/libs/controller/components/email.test.php +++ b/cake/tests/cases/libs/controller/components/email.test.php @@ -439,6 +439,9 @@ TEMPDOC; * @return void */ function testSmtpSendMultipleTo() { + if ($this->skipIf(!@fsockopen('localhost', 25), '%s No SMTP server running on localhost')) { + return; + } $this->Controller->EmailTest->reset(); $this->Controller->EmailTest->to = array('postmaster@localhost', 'root@localhost'); $this->Controller->EmailTest->from = 'noreply@example.com'; diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php index 35b465f63..7d18d0970 100644 --- a/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php @@ -215,6 +215,7 @@ class DboPostgresTest extends CakeTestCase { */ 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.datatype', ); /** * Actual DB connection used in testing @@ -396,19 +397,32 @@ class DboPostgresTest extends CakeTestCase { * @return void */ function testBooleanNormalization() { - $this->assertEquals(1, $this->Dbo2->boolean('t', false)); - $this->assertEquals(1, $this->Dbo2->boolean('true', false)); - $this->assertEquals(1, $this->Dbo2->boolean('TRUE', false)); - $this->assertEquals(1, $this->Dbo2->boolean(true, false)); - $this->assertEquals(1, $this->Dbo2->boolean(1, false)); - $this->assertEquals(1, $this->Dbo2->boolean(" ", false)); + $this->assertEquals(true, $this->Dbo2->boolean('t', false)); + $this->assertEquals(true, $this->Dbo2->boolean('true', false)); + $this->assertEquals(true, $this->Dbo2->boolean('TRUE', false)); + $this->assertEquals(true, $this->Dbo2->boolean(true, false)); + $this->assertEquals(true, $this->Dbo2->boolean(1, false)); + $this->assertEquals(true, $this->Dbo2->boolean(" ", false)); - $this->assertEquals(0, $this->Dbo2->boolean('f', false)); - $this->assertEquals(0, $this->Dbo2->boolean('false', false)); - $this->assertEquals(0, $this->Dbo2->boolean('FALSE', false)); - $this->assertEquals(0, $this->Dbo2->boolean(false, false)); - $this->assertEquals(0, $this->Dbo2->boolean(0, false)); - $this->assertEquals(0, $this->Dbo2->boolean('', false)); + $this->assertEquals(false, $this->Dbo2->boolean('f', false)); + $this->assertEquals(false, $this->Dbo2->boolean('false', false)); + $this->assertEquals(false, $this->Dbo2->boolean('FALSE', false)); + $this->assertEquals(false, $this->Dbo2->boolean(false, false)); + $this->assertEquals(false, $this->Dbo2->boolean(0, 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'); $db1 = ConnectionManager::getDataSource('test'); - $db2 = clone $db1; - $db2->connect(); - $this->assertNotSame($db1->getConnection(), $db2->getConnection()); - $table = $db1->fullTableName('users', false); $password = '5f4dcc3b5aa765d61d8327deb882cf99'; $db1->execute( "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($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->cacheSources = 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, "varchar" character varying(40) NOT NULL, "full_length" character varying NOT NULL, @@ -560,31 +573,34 @@ class DboPostgresTest extends CakeTestCase { "date" date, 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')); $result = $schema->read(array( '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->assertPattern('/\"full_length\"\s*text\s.*,/', $result); $this->assertPattern('/timestamp\s*,/', $result); + + $db1->query('DROP TABLE ' . $db1->fullTableName('datatype_tests')); + $db1->query($result); $result2 = $schema->read(array( 'connection' => 'test', - 'models' => array('Datatype') + 'models' => array('DatatypeTest') )); - $schema->tables = array('datatypes' => $result2['tables']['missing']['datatypes']); - $result2 = $db1->createSchema($schema, 'datatypes'); + $schema->tables = array('datatype_tests' => $result2['tables']['missing']['datatype_tests']); + $result2 = $db1->createSchema($schema, 'datatype_tests'); $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 UNIQUE INDEX char_index ON ' . $name . '("small_char")'); $expected = array( - 'PRIMARY' => array('column' => 'id', 'unique' => 1), - 'pointless_bool' => array('column' => 'bool', 'unique' => 0), - 'char_index' => array('column' => 'small_char', 'unique' => 1), + 'PRIMARY' => array('unique' => true, 'column' => 'id'), + 'pointless_bool' => array('unique' => false, 'column' => 'bool'), + 'char_index' => array('unique' => true, 'column' => 'small_char'), ); $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 UNIQUE INDEX multi_col ON ' . $name . '("small_char", "bool")'); $expected = array( - 'PRIMARY' => array('column' => 'id', 'unique' => 1), - 'multi_col' => array('column' => array('small_char', 'bool'), 'unique' => 1), + 'PRIMARY' => array('unique' => true, 'column' => 'id'), + 'multi_col' => array('unique' => true, 'column' => array('small_char', 'bool')), ); $result = $this->Dbo->index($name); $this->Dbo->query('DROP TABLE ' . $name); @@ -687,6 +703,7 @@ class DboPostgresTest extends CakeTestCase { 'group2' => array('type' => 'integer', 'null' => true) ) )); + $this->Dbo->rawQuery($this->Dbo->dropSchema($schema1)); $this->Dbo->rawQuery($this->Dbo->createSchema($schema1)); $schema2 = new CakeSchema(array( @@ -698,10 +715,10 @@ class DboPostgresTest extends CakeTestCase { 'group1' => array('type' => 'integer', 'null' => 1), 'group2' => array('type' => 'integer', 'null' => 1), 'indexes' => array( - 'name_idx' => array('column' => 'name', 'unique' => 0), - 'group_idx' => array('column' => 'group1', 'unique' => 0), - 'compound_idx' => array('column' => array('group1', 'group2'), 'unique' => 0), - 'PRIMARY' => array('column' => 'id', 'unique' => 1) + 'name_idx' => array('unique' => false, 'column' => 'name'), + 'group_idx' => array('unique' => false, 'column' => 'group1'), + 'compound_idx' => array('unique' => false, 'column' => array('group1', 'group2')), + 'PRIMARY' => array('unique' => true, 'column' => 'id') ) ) )); @@ -720,10 +737,10 @@ class DboPostgresTest extends CakeTestCase { 'group1' => array('type' => 'integer', 'null' => 1), 'group2' => array('type' => 'integer', 'null' => 1), 'indexes' => array( - 'name_idx' => array('column' => 'name', 'unique' => 1), - 'group_idx' => array('column' => 'group2', 'unique' => 0), - 'compound_idx' => array('column' => array('group2', 'group1'), 'unique' => 0), - 'another_idx' => array('column' => array('group1', 'name'), 'unique' => 0)) + 'name_idx' => array('unique' => true, 'column' => 'name'), + 'group_idx' => array('unique' => false, 'column' => 'group2'), + 'compound_idx' => array('unique' => false, 'column' => array('group2', 'group1')), + 'another_idx' => array('unique' => false, 'column' => array('group1', 'name'))) ))); $this->Dbo->query($this->Dbo->alterSchema($schema3->compare($schema2))); 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 66b4a9cc1..027f1c43b 100644 --- a/cake/tests/cases/libs/model/datasources/dbo_source.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo_source.test.php @@ -576,10 +576,14 @@ class DboSourceTest extends CakeTestCase { $result = $this->testDb->name(array('my-name', 'Foo-Model.*')); $expected = array('`my-name`', '`Foo-Model`.*'); $this->assertEqual($result, $expected); - + $result = $this->testDb->name(array('Team.P%', 'Team.G/G')); $expected = array('`Team`.`P%`', '`Team`.`G/G`'); $this->assertEqual($result, $expected); + + $result = $this->testDb->name('Model.name as y'); + $expected = '`Model`.`name` AS `y`'; + $this->assertEqual($result, $expected); } /** diff --git a/cake/tests/cases/libs/view/helpers/cache.test.php b/cake/tests/cases/libs/view/helpers/cache.test.php index 4aaa301c1..ec8d8b068 100644 --- a/cake/tests/cases/libs/view/helpers/cache.test.php +++ b/cake/tests/cases/libs/view/helpers/cache.test.php @@ -318,7 +318,6 @@ class CacheHelperTest extends CakeTestCase { $this->assertPattern('/\$this\-\>viewVars/', $contents); $this->assertPattern('/extract\(\$this\-\>viewVars, EXTR_SKIP\);/', $contents); $this->assertPattern('/php echo \$variable/', $contents); - $this->assertPattern('/variableValue/', $contents); @unlink($filename); } diff --git a/cake/tests/cases/libs/view/helpers/form.test.php b/cake/tests/cases/libs/view/helpers/form.test.php index 949857f1b..a7ca5da9e 100644 --- a/cake/tests/cases/libs/view/helpers/form.test.php +++ b/cake/tests/cases/libs/view/helpers/form.test.php @@ -1073,6 +1073,21 @@ class FormHelperTest extends CakeTestCase { $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 * @@ -4466,6 +4481,16 @@ class FormHelperTest extends CakeTestCase { $this->assertPattern('/]+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 * diff --git a/cake/tests/fixtures/datatype_fixture.php b/cake/tests/fixtures/datatype_fixture.php index 39055a018..3e392115e 100644 --- a/cake/tests/fixtures/datatype_fixture.php +++ b/cake/tests/fixtures/datatype_fixture.php @@ -41,6 +41,7 @@ class DatatypeFixture extends CakeTestFixture { public $fields = array( 'id' => array('type' => 'integer', 'null'=> false, 'default'=> 0, 'key' => 'primary'), '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 * @access public */ - public $records = array( - array('id' => 1, 'float_field' => 42.23), + var $records = array( + array('id' => 1, 'float_field' => 42.23, 'bool' => false), ); }