"Correcting Helper::setEntity() check if $parts[0] matches current model

Added tests for fix.
Adding escaping of \\ in FileEngine::write();"

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6119 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
phpnut 2007-12-06 07:43:19 +00:00
parent adcba2cc2d
commit 872dfbfcef
3 changed files with 15 additions and 2 deletions

View file

@ -127,7 +127,7 @@ class FileEngine extends CacheEngine {
$duration = $this->settings['duration'];
}
if (!empty($this->settings['serialize'])) {
$data = serialize($data);
$data = str_replace('\\', '\\\\', serialize($data));
}
if ($this->settings['lock']) {

View file

@ -328,7 +328,7 @@ class Helper extends Overloadable {
$sameScope = $hasField = false;
$parts = preg_split('/\/|\./', $entity);
if($parts[0] !== $view->model || count($parts) == 1) {
if($parts[0] === $view->model || count($parts) == 1) {
$sameScope = true;
if (ClassRegistry::isKeySet($view->model)) {
$modelObj =& ClassRegistry::getObject($view->model);

View file

@ -1376,6 +1376,19 @@ class FormHelperTest extends CakeTestCase {
$this->assertEqual($result, '<div class="good"><input type="submit" name="Whatever" value="save" /></div></form>');
}
function testMultipleFormWithIdFields() {
$this->Form->create('UserForm');
$result = $this->Form->input('id');
$this->assertEqual($result, '<input type="hidden" name="data[UserForm][id]" value="" id="UserFormId" />');
$result = $this->Form->input('My.id');
$this->assertEqual($result, '<input type="hidden" name="data[My][id]" value="" id="MyId" />');
$result = $this->Form->input('MyOther.id');
$this->assertEqual($result, '<input type="hidden" name="data[MyOther][id]" value="" id="MyOtherId" />');
}
function tearDown() {
ClassRegistry::removeObject('view');
ClassRegistry::removeObject('Contact');