Adding an additional test for View::entity().

Fixing issue where nulls would be shifted onto the entity array causing incorrect name attributes.  Fixes #867
This commit is contained in:
mark_story 2010-06-28 21:38:17 -04:00
parent f11f9ebc68
commit 94965f0f6c
2 changed files with 10 additions and 2 deletions

View file

@ -629,9 +629,9 @@ class View extends Object {
($count == 1 && !empty($this->association)) || ($count == 1 && !empty($this->association)) ||
($count == 1 && $this->model != $this->entityPath) || ($count == 1 && $this->model != $this->entityPath) ||
($count == 2 && !empty($this->fieldSuffix)) || ($count == 2 && !empty($this->fieldSuffix)) ||
is_numeric($path[0]) is_numeric($path[0]) && !empty($assoc)
) { ) {
array_unshift($path,$assoc); array_unshift($path, $assoc);
} }
return Set::filter($path); return Set::filter($path);
} }

View file

@ -891,6 +891,14 @@ class ViewTest extends CakeTestCase {
$View->association = 'Comment'; $View->association = 'Comment';
$View->field = 'user_id'; $View->field = 'user_id';
$this->assertEqual($View->entity(), array('Comment', 'user_id')); $this->assertEqual($View->entity(), array('Comment', 'user_id'));
$View->model = 0;
$View->association = null;
$View->field = 'Node';
$View->fieldSuffix = 'title';
$View->entityPath = '0.Node.title';
$expected = array(0, 'Node', 'title');
$this->assertEqual($View->entity(), $expected);
} }
/** /**