diff --git a/cake/basics.php b/cake/basics.php
index 5a968cdeb..58ee67c41 100644
--- a/cake/basics.php
+++ b/cake/basics.php
@@ -282,7 +282,7 @@ if (!function_exists('sortByKey')) {
if (defined('SERVER_IIS') && SERVER_IIS === true) {
return str_replace('\\\\', '\\', env('PATH_TRANSLATED'));
}
- break;
+ break;
case 'DOCUMENT_ROOT':
$name = env('SCRIPT_NAME');
$filename = env('SCRIPT_FILENAME');
@@ -291,20 +291,31 @@ if (!function_exists('sortByKey')) {
$offset = 4;
}
return substr($filename, 0, strlen($filename) - (strlen($name) + $offset));
- break;
+ break;
case 'PHP_SELF':
return str_replace(env('DOCUMENT_ROOT'), '', env('SCRIPT_FILENAME'));
- break;
+ break;
case 'CGI_MODE':
return (PHP_SAPI === 'cgi');
- break;
+ break;
case 'HTTP_BASE':
$host = env('HTTP_HOST');
- if (substr_count($host, '.') !== 1) {
- return preg_replace('/^([^.])*/i', null, env('HTTP_HOST'));
+ $parts = explode('.', $host);
+ $count = count($parts);
+
+ if ($count === 1) {
+ return '.' . $host;
+ } elseif ($count === 2) {
+ return '.' . $host;
+ } elseif ($count === 3) {
+ $gTLD = array('aero', 'asia', 'biz', 'cat', 'com', 'coop', 'edu', 'gov', 'info', 'int', 'jobs', 'mil', 'mobi', 'museum', 'name', 'net', 'org', 'pro', 'tel', 'travel', 'xxx');
+ if (in_array($parts[1], $gTLD)) {
+ return '.' . $host;
+ }
}
- return '.' . $host;
- break;
+ array_shift($parts);
+ return '.' . implode('.', $parts);
+ break;
}
return null;
}
diff --git a/cake/console/templates/default/classes/fixture.ctp b/cake/console/templates/default/classes/fixture.ctp
index dd1b5b478..bbb727dd6 100644
--- a/cake/console/templates/default/classes/fixture.ctp
+++ b/cake/console/templates/default/classes/fixture.ctp
@@ -20,7 +20,7 @@
*/
?>
-/* Fixture generated on: */
+/* Fixture generated on: */
class Fixture extends CakeTestFixture {
public $name = '';
diff --git a/cake/console/templates/default/classes/test.ctp b/cake/console/templates/default/classes/test.ctp
index f9dd98b0b..6e8c1ba76 100644
--- a/cake/console/templates/default/classes/test.ctp
+++ b/cake/console/templates/default/classes/test.ctp
@@ -18,7 +18,7 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
echo "
App::import('', '');
diff --git a/cake/libs/cache/memcache.php b/cake/libs/cache/memcache.php
index 79d98376e..8db15b131 100644
--- a/cake/libs/cache/memcache.php
+++ b/cake/libs/cache/memcache.php
@@ -116,8 +116,7 @@ class MemcacheEngine extends CacheEngine {
/**
* Write data for key into cache. When using memcache as your cache engine
* remember that the Memcache pecl extension does not support cache expiry times greater
- * than 30 days in the future. If you wish to create cache entries that do not expire, set the duration
- * to `0` in your cache configuration.
+ * than 30 days in the future. Any duration greater than 30 days will be treated as never expiring.
*
* @param string $key Identifier for the data
* @param mixed $value Data to be cached
@@ -126,6 +125,9 @@ class MemcacheEngine extends CacheEngine {
* @see http://php.net/manual/en/memcache.set.php
*/
public function write($key, $value, $duration) {
+ if ($duration > 30 * DAY) {
+ $duration = 0;
+ }
return $this->__Memcache->set($key, $value, $this->settings['compress'], $duration);
}
diff --git a/cake/libs/controller/components/request_handler.php b/cake/libs/controller/components/request_handler.php
index 3889f716c..f818ef63b 100644
--- a/cake/libs/controller/components/request_handler.php
+++ b/cake/libs/controller/components/request_handler.php
@@ -132,6 +132,7 @@ class RequestHandlerComponent extends Component {
}
}
}
+ $this->params = $controller->params;
$this->_set($settings);
}
@@ -585,7 +586,9 @@ class RequestHandlerComponent extends Component {
}
if ($cType != null) {
- $this->response->type($cType);
+ if (empty($this->request->params['requested'])) {
+ $this->response->type($cType);
+ }
if (!empty($options['charset'])) {
$this->response->charset($options['charset']);
diff --git a/cake/libs/model/cake_schema.php b/cake/libs/model/cake_schema.php
index a38e0ed7b..fb3a77c13 100644
--- a/cake/libs/model/cake_schema.php
+++ b/cake/libs/model/cake_schema.php
@@ -365,7 +365,7 @@ class CakeSchema extends Object {
$out .= "}\n";
$file = new SplFileObject($path . DS . $file, 'w+');
- $content = "";
+ $content = "";
if ($file->fwrite($content)) {
return $content;
}
diff --git a/cake/libs/route/cake_route.php b/cake/libs/route/cake_route.php
index be944951f..798d26c92 100644
--- a/cake/libs/route/cake_route.php
+++ b/cake/libs/route/cake_route.php
@@ -173,7 +173,7 @@ class CakeRoute {
/**
* Checks to see if the given URL can be parsed by this route.
- * If the route can be parsed an array of parameters will be returned if not
+ * If the route can be parsed an array of parameters will be returned; if not
* false will be returned. String urls are parsed if they match a routes regular expression.
*
* @param string $url The url to attempt to parse.
@@ -245,8 +245,8 @@ class CakeRoute {
}
/**
- * Attempt to match a url array. If the url matches the route parameters + settings, then
- * return a generated string url. If the url doesn't match the route parameters false will be returned.
+ * Attempt to match a url array. If the url matches the route parameters and settings, then
+ * return a generated string url. If the url doesn't match the route parameters, false will be returned.
* This method handles the reverse routing or conversion of url arrays into string urls.
*
* @param array $url An array of parameters to check matching with.
diff --git a/cake/libs/router.php b/cake/libs/router.php
index c0737ae25..16af52f67 100644
--- a/cake/libs/router.php
+++ b/cake/libs/router.php
@@ -221,21 +221,25 @@ class Router {
* Shows connecting a route with custom route parameters as well as providing patterns for those parameters.
* Patterns for routing parameters do not need capturing groups, as one will be added for each route params.
*
- * $options offers two 'special' keys. `pass` and `persist` have special meaning in the $options array.
+ * $options offers three 'special' keys. `pass`, `persist` and `routeClass` have special meaning in the $options array.
*
* `pass` is used to define which of the routed parameters should be shifted into the pass array. Adding a
* parameter to pass will remove it from the regular route array. Ex. `'pass' => array('slug')`
*
* `persist` is used to define which route parameters should be automatically included when generating
- * new urls. You can override peristent parameters by redifining them in a url or remove them by
+ * new urls. You can override persistent parameters by redefining them in a url or remove them by
* setting the parameter to `false`. Ex. `'persist' => array('lang')`
*
+ * `routeClass` is used to extend and change how individual routes parse requests and handle reverse routing,
+ * via a custom routing class. Ex. `'routeClass' => 'SlugRoute'`
+ *
* @param string $route A string describing the template of the route
* @param array $defaults An array describing the default route parameters. These parameters will be used by default
* and can supply routing parameters that are not dynamic. See above.
* @param array $options An array matching the named elements in the route to regular expressions which that
* element should match. Also contains additional parameters such as which routed parameters should be
- * shifted into the passed arguments. As well as supplying patterns for routing parameters.
+ * shifted into the passed arguments, supplying patterns for routing parameters and supplying the name of a
+ * custom routing class.
* @see routes
* @return array Array of routes
* @throws RouterException
@@ -731,7 +735,7 @@ class Router {
*
* @param $which A zero-based array index representing the route to move. For example,
* if 3 routes have been added, the last route would be 2.
- * @return boolean Retuns false if no route exists at the position specified by $which.
+ * @return boolean Returns false if no route exists at the position specified by $which.
*/
public static function promote($which = null) {
if ($which === null) {
@@ -752,7 +756,7 @@ class Router {
* Returns an URL pointing to a combination of controller and action. Param
* $url can be:
*
- * - Empty - the method will find address to actuall controller/action.
+ * - Empty - the method will find address to actual controller/action.
* - '/' - the method will find base URL of application.
* - A combination of controller/action - the method will find url for it.
*
@@ -1068,7 +1072,7 @@ class Router {
}
/**
- * Reverses a parsed parameter array into a string. Works similarily to Router::url(), but
+ * Reverses a parsed parameter array into a string. Works similarly to Router::url(), but
* Since parsed URL's contain additional 'pass' and 'named' as well as 'url.url' keys.
* Those keys need to be specially handled in order to reverse a params array into a string url.
*
@@ -1199,7 +1203,7 @@ class Router {
}
/**
- * Takes an passed params and converts it to args
+ * Takes a passed params and converts it to args
*
* @param array $params
* @return array Array containing passed and named parameters
@@ -1263,5 +1267,6 @@ class Router {
return compact('pass', 'named');
}
}
+
//Save the initial state
Router::reload();
diff --git a/cake/libs/session/database_session.php b/cake/libs/session/database_session.php
index 574d1f5c0..ceff5fdb0 100644
--- a/cake/libs/session/database_session.php
+++ b/cake/libs/session/database_session.php
@@ -106,6 +106,9 @@ class DatabaseSession implements CakeSessionHandlerInterface {
* @access private
*/
public function write($id, $data) {
+ if (!$id) {
+ return false;
+ }
$expires = time() + (Configure::read('Session.timeout') * 60);
return ClassRegistry::getObject('Session')->save(compact('id', 'data', 'expires'));
}
diff --git a/cake/libs/view/helpers/form.php b/cake/libs/view/helpers/form.php
index dd1c7d85f..ab56d4e3a 100644
--- a/cake/libs/view/helpers/form.php
+++ b/cake/libs/view/helpers/form.php
@@ -1001,7 +1001,10 @@ class FormHelper extends AppHelper {
if (empty($options['value'])) {
$options['value'] = 1;
- } elseif (!empty($value) && $value === $options['value']) {
+ } elseif (
+ (!isset($options['checked']) && !empty($value) && $value === $options['value']) ||
+ !empty($options['checked'])
+ ) {
$options['checked'] = 'checked';
}
if ($options['hiddenField']) {
@@ -2021,7 +2024,7 @@ class FormHelper extends AppHelper {
return $options;
}
- $name = $this->_View->field;
+ $name = !empty($this->_View->field) ? $this->_View->field : $this->_View->model;
if (!empty($this->_View->fieldSuffix)) {
$name .= '[' . $this->_View->fieldSuffix . ']';
}
diff --git a/cake/libs/view/helpers/text.php b/cake/libs/view/helpers/text.php
index 12eff3893..307859513 100644
--- a/cake/libs/view/helpers/text.php
+++ b/cake/libs/view/helpers/text.php
@@ -180,8 +180,9 @@ class TextHelper extends AppHelper {
*/
public function autoLinkEmails($text, $options = array()) {
$this->_linkOptions = $options;
+ $atom = '[a-z0-9!#$%&\'*+\/=?^_`{|}~-]';
return preg_replace_callback(
- '#([_A-Za-z0-9+-]+(?:\.[_A-Za-z0-9+-]+)*@[A-Za-z0-9-]+(?:\.[A-Za-z0-9-]+)*)#',
+ '/(' . $atom . '+(?:\.' . $atom . '+)*@[a-z0-9-]+(?:\.[a-z0-9-]+)*)/i',
array(&$this, '_linkEmails'),
$text
);
diff --git a/cake/libs/view/view.php b/cake/libs/view/view.php
index 7318a829d..9702874c1 100644
--- a/cake/libs/view/view.php
+++ b/cake/libs/view/view.php
@@ -326,6 +326,7 @@ class View extends Object {
return $contents;
}
}
+
$file = $this->_getElementFilename($name, $plugin);
if ($file) {
@@ -698,10 +699,7 @@ class View extends Object {
}
$paths = $this->_paths($this->plugin);
- $exts = array($this->ext);
- if ($this->ext !== '.ctp') {
- array_push($exts, '.ctp');
- }
+ $exts = $this->_getExtensions();
foreach ($exts as $ext) {
foreach ($paths as $path) {
if (file_exists($path . $name . $ext)) {
@@ -741,11 +739,8 @@ class View extends Object {
}
$paths = $this->_paths($this->plugin);
$file = 'layouts' . DS . $subDir . $name;
-
- $exts = array($this->ext);
- if ($this->ext !== '.ctp') {
- array_push($exts, '.ctp');
- }
+
+ $exts = $this->_getExtensions();
foreach ($exts as $ext) {
foreach ($paths as $path) {
if (file_exists($path . $file . $ext)) {
@@ -756,6 +751,21 @@ class View extends Object {
throw new MissingLayoutException(array('file' => $paths[0] . $file . $this->ext));
}
+
+/**
+ * Get the extensions that view files can use.
+ *
+ * @return array Array of extensions view files use.
+ * @access protected
+ */
+ function _getExtensions() {
+ $exts = array($this->ext);
+ if ($this->ext !== '.ctp') {
+ array_push($exts, '.ctp');
+ }
+ return $exts;
+ }
+
/**
* Finds an element filename, returns false on failure.
*
@@ -765,9 +775,12 @@ class View extends Object {
*/
protected function _getElementFileName($name, $plugin = null) {
$paths = $this->_paths($plugin);
- foreach ($paths as $path) {
- if (file_exists($path . 'elements' . DS . $name . $this->ext)) {
- return $path . 'elements' . DS . $name . $this->ext;
+ $exts = $this->_getExtensions();
+ foreach ($exts as $ext) {
+ foreach ($paths as $path) {
+ if (file_exists($path . 'elements' . DS . $name . $this->ext)) {
+ return $path . 'elements' . DS . $name . $this->ext;
+ }
}
}
return false;
diff --git a/cake/tests/cases/basics.test.php b/cake/tests/cases/basics.test.php
index c5f4c3ca3..e3090938a 100644
--- a/cake/tests/cases/basics.test.php
+++ b/cake/tests/cases/basics.test.php
@@ -90,7 +90,13 @@ class BasicsTest extends CakeTestCase {
$__ENV = $_ENV;
$_SERVER['HTTP_HOST'] = 'localhost';
- $this->assertEqual(env('HTTP_BASE'), '');
+ $this->assertEqual(env('HTTP_BASE'), '.localhost');
+
+ $_SERVER['HTTP_HOST'] = 'com.ar';
+ $this->assertEqual(env('HTTP_BASE'), '.com.ar');
+
+ $_SERVER['HTTP_HOST'] = 'example.ar';
+ $this->assertEqual(env('HTTP_BASE'), '.example.ar');
$_SERVER['HTTP_HOST'] = 'example.com';
$this->assertEqual(env('HTTP_BASE'), '.example.com');
@@ -101,9 +107,21 @@ class BasicsTest extends CakeTestCase {
$_SERVER['HTTP_HOST'] = 'subdomain.example.com';
$this->assertEqual(env('HTTP_BASE'), '.example.com');
+ $_SERVER['HTTP_HOST'] = 'example.com.ar';
+ $this->assertEqual(env('HTTP_BASE'), '.example.com.ar');
+
+ $_SERVER['HTTP_HOST'] = 'www.example.com.ar';
+ $this->assertEqual(env('HTTP_BASE'), '.example.com.ar');
+
+ $_SERVER['HTTP_HOST'] = 'subdomain.example.com.ar';
+ $this->assertEqual(env('HTTP_BASE'), '.example.com.ar');
+
$_SERVER['HTTP_HOST'] = 'double.subdomain.example.com';
$this->assertEqual(env('HTTP_BASE'), '.subdomain.example.com');
+ $_SERVER['HTTP_HOST'] = 'double.subdomain.example.com.ar';
+ $this->assertEqual(env('HTTP_BASE'), '.subdomain.example.com.ar');
+
$_SERVER = $_ENV = array();
$_SERVER['SCRIPT_NAME'] = '/a/test/test.php';
diff --git a/cake/tests/cases/libs/cache/memcache.test.php b/cake/tests/cases/libs/cache/memcache.test.php
index 42324a8bc..aea370cc0 100644
--- a/cake/tests/cases/libs/cache/memcache.test.php
+++ b/cake/tests/cases/libs/cache/memcache.test.php
@@ -31,8 +31,14 @@ class TestMemcacheEngine extends MemcacheEngine {
function parseServerString($server) {
return $this->_parseServerString($server);
}
+
+ function setMemcache(&$memcache) {
+ $this->__Memcache = $memcache;
+ }
}
+Mock::generate('Memcache', 'MemcacheMockMemcache');
+
/**
* MemcacheEngineTest class
*
@@ -357,7 +363,23 @@ class MemcacheEngineTest extends CakeTestCase {
$this->assertTrue($result, 'Could not write with duration 0');
$result = Cache::read('test_key', 'memcache');
$this->assertEqual($result, 'written!');
-
+ }
+
+/**
+ * test that durations greater than 30 days never expire
+ *
+ * @return void
+ */
+ function testLongDurationEqualToZero() {
+ $memcache =& new TestMemcacheEngine();
+ $memcache->settings['compress'] = false;
+
+ $mock = new MemcacheMockMemcache();
+ $memcache->setMemcache($mock);
+ $mock->expectAt(0, 'set', array('key', 'value', false, 0));
+
+ $value = 'value';
+ $memcache->write('key', $value, 50 * DAY);
}
}
diff --git a/cake/tests/cases/libs/cake_session.test.php b/cake/tests/cases/libs/cake_session.test.php
index 3673121fd..e88a01aec 100644
--- a/cake/tests/cases/libs/cake_session.test.php
+++ b/cake/tests/cases/libs/cake_session.test.php
@@ -702,4 +702,35 @@ class CakeSessionTest extends CakeTestCase {
$this->assertEquals(CakeSession::$time + $timeoutSeconds, $_SESSION['Config']['time']);
}
+/**
+ * testReadAndWriteWithDatabaseStorage method
+ *
+ * @access public
+ * @return void
+ */
+ function testDatabaseStorageEmptySessionId() {
+ unset($_SESSION);
+ session_destroy();
+ Configure::write('Session.table', 'sessions');
+ Configure::write('Session.model', 'Session');
+ Configure::write('Session.database', 'test_suite');
+ Configure::write('Session.save', 'database');
+ $this->setUp();
+ $id = $this->Session->id();
+
+ $this->Session->id = '';
+ session_id('');
+
+ $this->Session->write('SessionTestCase', 'This is a Test');
+ $this->assertEqual($this->Session->read('SessionTestCase'), 'This is a Test');
+
+ session_write_close();
+
+ unset($_SESSION);
+ ini_set('session.save_handler', 'files');
+ Configure::write('Session.save', 'php');
+ session_id($id);
+ $this->setUp();
+ }
+
}
diff --git a/cake/tests/cases/libs/model/model_write.test.php b/cake/tests/cases/libs/model/model_write.test.php
index 44a6585c6..27e5fde37 100644
--- a/cake/tests/cases/libs/model/model_write.test.php
+++ b/cake/tests/cases/libs/model/model_write.test.php
@@ -1505,7 +1505,6 @@ class ModelWriteTest extends BaseModelTest {
);
$TestModel->save($data);
$result = $TestModel->read(null, 1);
- $time = date('Y-M-D H:i:s');
$expected = array(4, 5);
$this->assertEqual(Set::extract('/JoinC/JoinAsJoinC/id', $result), $expected);
$expected = array('new record', 'new record');
diff --git a/cake/tests/cases/libs/view/helpers/form.test.php b/cake/tests/cases/libs/view/helpers/form.test.php
index 6a4f29403..c4f1e9dd7 100644
--- a/cake/tests/cases/libs/view/helpers/form.test.php
+++ b/cake/tests/cases/libs/view/helpers/form.test.php
@@ -2168,6 +2168,35 @@ class FormHelperTest extends CakeTestCase {
'/div'
);
$this->assertTags($result, $expected);
+
+ $this->Form->data = array();
+ $result = $this->Form->input('Publisher.id', array(
+ 'label' => 'Publisher',
+ 'type' => 'select',
+ 'multiple' => 'checkbox',
+ 'options' => array('Value 1' => 'Label 1', 'Value 2' => 'Label 2')
+ ));
+ $expected = array(
+ array('div' => array('class' => 'input select')),
+ array('label' => array('for' => 'PublisherId')),
+ 'Publisher',
+ '/label',
+ 'input' => array('type' => 'hidden', 'name' => 'data[Publisher][id]', 'value' => '', 'id' => 'PublisherId'),
+ array('div' => array('class' => 'checkbox')),
+ array('input' => array('type' => 'checkbox', 'name' => 'data[Publisher][id][]', 'value' => 'Value 1', 'id' => 'PublisherIdValue1')),
+ array('label' => array('for' => 'PublisherIdValue1')),
+ 'Label 1',
+ '/label',
+ '/div',
+ array('div' => array('class' => 'checkbox')),
+ array('input' => array('type' => 'checkbox', 'name' => 'data[Publisher][id][]', 'value' => 'Value 2', 'id' => 'PublisherIdValue2')),
+ array('label' => array('for' => 'PublisherIdValue2')),
+ 'Label 2',
+ '/label',
+ '/div',
+ '/div'
+ );
+ $this->assertTags($result, $expected);
}
/**
@@ -3123,7 +3152,7 @@ class FormHelperTest extends CakeTestCase {
'/select'
);
$this->assertTags($result, $expected);
-
+
$options = array(
'>< Key' => array(
1 => 'One',
@@ -3500,7 +3529,7 @@ class FormHelperTest extends CakeTestCase {
*/
function testSelectMultipleCheckboxDiv() {
$result = $this->Form->select(
- 'Model.tags',
+ 'Model.tags',
array('first', 'second'),
array('multiple' => 'checkbox', 'class' => 'my-class')
);
@@ -3528,7 +3557,7 @@ class FormHelperTest extends CakeTestCase {
$result = $this->Form->input('Model.tags', array(
'options' => array('first', 'second'),
- 'multiple' => 'checkbox',
+ 'multiple' => 'checkbox',
'class' => 'my-class',
'div' => false,
'label' => false
@@ -3762,27 +3791,6 @@ class FormHelperTest extends CakeTestCase {
);
$this->assertTags($result, $expected);
- $result = $this->Form->checkbox('Model.field', array('checked' => 'checked'));
- $expected = array(
- 'input' => array('type' => 'hidden', 'name' => 'data[Model][field]', 'value' => '0', 'id' => 'ModelField_'),
- array('input' => array('type' => 'checkbox', 'name' => 'data[Model][field]', 'value' => '1', 'id' => 'ModelField', 'checked' => 'checked'))
- );
- $this->assertTags($result, $expected);
-
- $result = $this->Form->checkbox('Model.field', array('checked' => 1));
- $expected = array(
- 'input' => array('type' => 'hidden', 'name' => 'data[Model][field]', 'value' => '0', 'id' => 'ModelField_'),
- array('input' => array('type' => 'checkbox', 'name' => 'data[Model][field]', 'value' => '1', 'id' => 'ModelField', 'checked' => 'checked'))
- );
- $this->assertTags($result, $expected);
-
- $result = $this->Form->checkbox('Model.field', array('checked' => true));
- $expected = array(
- 'input' => array('type' => 'hidden', 'name' => 'data[Model][field]', 'value' => '0', 'id' => 'ModelField_'),
- array('input' => array('type' => 'checkbox', 'name' => 'data[Model][field]', 'value' => '1', 'id' => 'ModelField', 'checked' => 'checked'))
- );
- $this->assertTags($result, $expected);
-
$this->Form->validationErrors['Model']['field'] = 1;
$this->Form->request->data['Contact']['published'] = 1;
$result = $this->Form->checkbox('Contact.published', array('id' => 'theID'));
@@ -3823,6 +3831,49 @@ class FormHelperTest extends CakeTestCase {
$this->assertTags($result, $expected);
}
+/**
+ * test the checked option for checkboxes.
+ *
+ * @return void
+ */
+ function testCheckboxCheckedOption() {
+ $result = $this->Form->checkbox('Model.field', array('checked' => 'checked'));
+ $expected = array(
+ 'input' => array('type' => 'hidden', 'name' => 'data[Model][field]', 'value' => '0', 'id' => 'ModelField_'),
+ array('input' => array('type' => 'checkbox', 'name' => 'data[Model][field]', 'value' => '1', 'id' => 'ModelField', 'checked' => 'checked'))
+ );
+ $this->assertTags($result, $expected);
+
+ $result = $this->Form->checkbox('Model.field', array('checked' => 1));
+ $expected = array(
+ 'input' => array('type' => 'hidden', 'name' => 'data[Model][field]', 'value' => '0', 'id' => 'ModelField_'),
+ array('input' => array('type' => 'checkbox', 'name' => 'data[Model][field]', 'value' => '1', 'id' => 'ModelField', 'checked' => 'checked'))
+ );
+ $this->assertTags($result, $expected);
+
+ $result = $this->Form->checkbox('Model.field', array('checked' => true));
+ $expected = array(
+ 'input' => array('type' => 'hidden', 'name' => 'data[Model][field]', 'value' => '0', 'id' => 'ModelField_'),
+ array('input' => array('type' => 'checkbox', 'name' => 'data[Model][field]', 'value' => '1', 'id' => 'ModelField', 'checked' => 'checked'))
+ );
+ $this->assertTags($result, $expected);
+
+ $result = $this->Form->checkbox('Model.field', array('checked' => false));
+ $expected = array(
+ 'input' => array('type' => 'hidden', 'name' => 'data[Model][field]', 'value' => '0', 'id' => 'ModelField_'),
+ array('input' => array('type' => 'checkbox', 'name' => 'data[Model][field]', 'value' => '1', 'id' => 'ModelField'))
+ );
+ $this->assertTags($result, $expected);
+
+ $this->Form->request->data['Model']['field'] = 1;
+ $result = $this->Form->checkbox('Model.field', array('checked' => false));
+ $expected = array(
+ 'input' => array('type' => 'hidden', 'name' => 'data[Model][field]', 'value' => '0', 'id' => 'ModelField_'),
+ array('input' => array('type' => 'checkbox', 'name' => 'data[Model][field]', 'value' => '1', 'id' => 'ModelField'))
+ );
+ $this->assertTags($result, $expected);
+ }
+
/**
* Test that disabling a checkbox also disables the hidden input so no value is submitted
*
@@ -5751,6 +5802,28 @@ class FormHelperTest extends CakeTestCase {
)));
}
+/**
+ * test get form, and inputs when the model param is false
+ *
+ * @return void
+ */
+ function testGetFormWithFalseModel() {
+ $encoding = strtolower(Configure::read('App.encoding'));
+ $result = $this->Form->create(false, array('type' => 'get'));
+
+ $expected = array('form' => array(
+ 'id' => 'addForm', 'method' => 'get', 'action' => '/contact_test/add',
+ 'accept-charset' => $encoding
+ ));
+ $this->assertTags($result, $expected);
+
+ $result = $this->Form->text('reason');
+ $expected = array(
+ 'input' => array('type' => 'text', 'name' => 'reason', 'id' => 'reason')
+ );
+ $this->assertTags($result, $expected);
+ }
+
/**
* test that datetime() works with GET style forms.
*
diff --git a/cake/tests/cases/libs/view/helpers/text.test.php b/cake/tests/cases/libs/view/helpers/text.test.php
index 03ad9ee2f..f02549044 100644
--- a/cake/tests/cases/libs/view/helpers/text.test.php
+++ b/cake/tests/cases/libs/view/helpers/text.test.php
@@ -273,6 +273,16 @@ class TextHelperTest extends CakeTestCase {
$expected = 'Text with a url www.cot.ag/cuIb2Q and more';
$result = $this->Text->autoLinkUrls($text);
$this->assertEqual($expected, $result);
+
+ $text = 'Text with a url http://www.does--not--work.com and more';
+ $expected = 'Text with a url http://www.does--not--work.com and more';
+ $result = $this->Text->autoLinkUrls($text);
+ $this->assertEqual($expected, $result);
+
+ $text = 'Text with a url http://www.not--work.com and more';
+ $expected = 'Text with a url http://www.not--work.com and more';
+ $result = $this->Text->autoLinkUrls($text);
+ $this->assertEqual($expected, $result);
}
/**
@@ -291,6 +301,11 @@ class TextHelperTest extends CakeTestCase {
$expected = 'Text with email@example.com address';
$result = $this->Text->autoLinkEmails($text);
$this->assertPattern('#^' . $expected . '$#', $result);
+
+ $text = "Text with o'hare._-bob@example.com address";
+ $expected = 'Text with o'hare._-bob@example.com address';
+ $result = $this->Text->autoLinkEmails($text);
+ $this->assertEqual($expected, $result);
$text = 'Text with email@example.com address';
$expected = 'Text with email@example.com address';
diff --git a/cake/tests/cases/libs/view/view.test.php b/cake/tests/cases/libs/view/view.test.php
index 70ef8a6ca..2b6417e5a 100644
--- a/cake/tests/cases/libs/view/view.test.php
+++ b/cake/tests/cases/libs/view/view.test.php
@@ -544,6 +544,21 @@ class ViewTest extends CakeTestCase {
$this->assertInstanceOf('HtmlHelper', $View->Html);
}
+/**
+ * test that ctp is used as a fallback file extension for elements
+ *
+ * @return void
+ */
+ function testElementCtpFallback() {
+ $View = new TestView($this->PostsController);
+ $View->ext = '.missing';
+ $element = 'test_element';
+ $expected = 'this is the test element';
+ $result = $View->element($element);
+
+ $this->assertEqual($expected, $result);
+ }
+
/**
* testLoadHelpers method
*