mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Refactoring model constructor
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6678 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
d64e94e264
commit
8f3a2c6022
2 changed files with 13 additions and 11 deletions
|
@ -360,17 +360,7 @@ class Model extends Overloadable {
|
|||
$this->__createLinks();
|
||||
|
||||
if ($this->displayField == null) {
|
||||
if ($this->hasField('title')) {
|
||||
$this->displayField = 'title';
|
||||
}
|
||||
|
||||
if ($this->hasField('name')) {
|
||||
$this->displayField = 'name';
|
||||
}
|
||||
|
||||
if ($this->displayField == null) {
|
||||
$this->displayField = $this->primaryKey;
|
||||
}
|
||||
$this->displayField = $this->hasField(array('title', 'name', $this->primaryKey));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -377,6 +377,7 @@ class ModelTest extends CakeTestCase {
|
|||
|
||||
function testFindSelfAssociations() {
|
||||
$this->loadFixtures('Person');
|
||||
|
||||
$this->model =& new Person();
|
||||
$this->model->recursive = 2;
|
||||
$result = $this->model->read(null, 1);
|
||||
|
@ -3422,6 +3423,17 @@ class ModelTest extends CakeTestCase {
|
|||
}
|
||||
}
|
||||
|
||||
function testDisplayField() {
|
||||
$this->loadFixtures('Post', 'Comment', 'Person');
|
||||
$this->Post = new Post();
|
||||
$this->Comment = new Comment();
|
||||
$this->Person = new Person();
|
||||
|
||||
$this->assertEqual($this->Post->displayField, 'title');
|
||||
$this->assertEqual($this->Person->displayField, 'name');
|
||||
$this->assertEqual($this->Comment->displayField, 'id');
|
||||
}
|
||||
|
||||
function endTest() {
|
||||
ClassRegistry::flush();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue