mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 17:16:18 +00:00
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:
parent
f11f9ebc68
commit
94965f0f6c
2 changed files with 10 additions and 2 deletions
|
@ -629,7 +629,7 @@ 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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue