mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 02:56:15 +00:00
Fixing registry so the model group has
8/8 test cases complete: 1509 passes, 0 fails and 0 exceptions. git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7442 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
1d94d3ccfd
commit
cda0009723
2 changed files with 19 additions and 18 deletions
|
@ -235,16 +235,16 @@ class ClassRegistry {
|
||||||
function &getObject($key) {
|
function &getObject($key) {
|
||||||
$_this =& ClassRegistry::getInstance();
|
$_this =& ClassRegistry::getInstance();
|
||||||
$key = Inflector::underscore($key);
|
$key = Inflector::underscore($key);
|
||||||
|
$return = false;
|
||||||
if (isset($_this->__objects[$key])) {
|
if (isset($_this->__objects[$key])) {
|
||||||
return $_this->__objects[$key];
|
$return =& $_this->__objects[$key];
|
||||||
} else {
|
} else {
|
||||||
$key = $_this->__getMap($key);
|
$key = $_this->__getMap($key);
|
||||||
if (isset($_this->__objects[$key])) {
|
if (isset($_this->__objects[$key])) {
|
||||||
return $_this->__objects[$key];
|
$return =& $_this->__objects[$key];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$return = false;
|
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
|
@ -282,7 +282,7 @@ class ClassRegistry {
|
||||||
$duplicate = false;
|
$duplicate = false;
|
||||||
if ($_this->isKeySet($alias)) {
|
if ($_this->isKeySet($alias)) {
|
||||||
$model =& $_this->getObject($alias);
|
$model =& $_this->getObject($alias);
|
||||||
if ($model->name === $class) {
|
if (is_a($model, $class)) {
|
||||||
$duplicate =& $model;
|
$duplicate =& $model;
|
||||||
}
|
}
|
||||||
unset($model);
|
unset($model);
|
||||||
|
|
|
@ -3511,29 +3511,29 @@ class DboSourceTest extends CakeTestCase {
|
||||||
$Apple =& ClassRegistry::init('Apple');
|
$Apple =& ClassRegistry::init('Apple');
|
||||||
$Article =& ClassRegistry::init('Article');
|
$Article =& ClassRegistry::init('Article');
|
||||||
|
|
||||||
$result = $this->testDb->rawQuery('SELECT color, name FROM ' . $this->testDb->fullTableName('apples'));
|
$result = $this->db->rawQuery('SELECT color, name FROM ' . $this->db->fullTableName('apples'));
|
||||||
$this->assertTrue(!empty($result));
|
$this->assertTrue(!empty($result));
|
||||||
|
|
||||||
$result = $this->testDb->fetchRow($result);
|
$result = $this->db->fetchRow($result);
|
||||||
$expected = array($this->testDb->fullTableName('apples', false) => array(
|
$expected = array($this->db->fullTableName('apples', false) => array(
|
||||||
'color' => 'Red 1',
|
'color' => 'Red 1',
|
||||||
'name' => 'Red Apple 1'
|
'name' => 'Red Apple 1'
|
||||||
));
|
));
|
||||||
$this->assertEqual($result, $expected);
|
$this->assertEqual($result, $expected);
|
||||||
|
|
||||||
$result = $this->testDb->fetchAll('SELECT name FROM ' . $this->testDb->fullTableName('apples') . ' ORDER BY id');
|
$result = $this->db->fetchAll('SELECT name FROM ' . $this->testDb->fullTableName('apples') . ' ORDER BY id');
|
||||||
$expected = array(
|
$expected = array(
|
||||||
array($this->testDb->fullTableName('apples', false) => array('name' => 'Red Apple 1')),
|
array($this->db->fullTableName('apples', false) => array('name' => 'Red Apple 1')),
|
||||||
array($this->testDb->fullTableName('apples', false) => array('name' => 'Bright Red Apple')),
|
array($this->db->fullTableName('apples', false) => array('name' => 'Bright Red Apple')),
|
||||||
array($this->testDb->fullTableName('apples', false) => array('name' => 'green blue')),
|
array($this->db->fullTableName('apples', false) => array('name' => 'green blue')),
|
||||||
array($this->testDb->fullTableName('apples', false) => array('name' => 'Test Name')),
|
array($this->db->fullTableName('apples', false) => array('name' => 'Test Name')),
|
||||||
array($this->testDb->fullTableName('apples', false) => array('name' => 'Blue Green')),
|
array($this->db->fullTableName('apples', false) => array('name' => 'Blue Green')),
|
||||||
array($this->testDb->fullTableName('apples', false) => array('name' => 'My new apple')),
|
array($this->db->fullTableName('apples', false) => array('name' => 'My new apple')),
|
||||||
array($this->testDb->fullTableName('apples', false) => array('name' => 'Some odd color'))
|
array($this->db->fullTableName('apples', false) => array('name' => 'Some odd color'))
|
||||||
);
|
);
|
||||||
$this->assertEqual($result, $expected);
|
$this->assertEqual($result, $expected);
|
||||||
|
|
||||||
$result = $this->testDb->field($this->testDb->fullTableName('apples', false), 'SELECT color, name FROM ' . $this->testDb->fullTableName('apples') . ' ORDER BY id');
|
$result = $this->db->field($this->testDb->fullTableName('apples', false), 'SELECT color, name FROM ' . $this->testDb->fullTableName('apples') . ' ORDER BY id');
|
||||||
$expected = array(
|
$expected = array(
|
||||||
'color' => 'Red 1',
|
'color' => 'Red 1',
|
||||||
'name' => 'Red Apple 1'
|
'name' => 'Red Apple 1'
|
||||||
|
@ -3541,7 +3541,7 @@ class DboSourceTest extends CakeTestCase {
|
||||||
$this->assertEqual($result, $expected);
|
$this->assertEqual($result, $expected);
|
||||||
|
|
||||||
$Apple->unbindModel(array(), false);
|
$Apple->unbindModel(array(), false);
|
||||||
$result = $this->testDb->read($Apple, array(
|
$result = $this->db->read($Apple, array(
|
||||||
'fields' => array($Apple->escapeField('name')),
|
'fields' => array($Apple->escapeField('name')),
|
||||||
'conditions' => null,
|
'conditions' => null,
|
||||||
'recursive' => -1
|
'recursive' => -1
|
||||||
|
@ -3557,11 +3557,12 @@ class DboSourceTest extends CakeTestCase {
|
||||||
);
|
);
|
||||||
$this->assertEqual($result, $expected);
|
$this->assertEqual($result, $expected);
|
||||||
|
|
||||||
$result = $this->testDb->read($Article, array(
|
$result = $this->db->read($Article, array(
|
||||||
'fields' => array('id', 'user_id', 'title'),
|
'fields' => array('id', 'user_id', 'title'),
|
||||||
'conditions' => null,
|
'conditions' => null,
|
||||||
'recursive' => 1
|
'recursive' => 1
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->assertTrue(Set::matches('/Article[id=1]', $result));
|
$this->assertTrue(Set::matches('/Article[id=1]', $result));
|
||||||
$this->assertTrue(Set::matches('/Comment[id=1]', $result));
|
$this->assertTrue(Set::matches('/Comment[id=1]', $result));
|
||||||
$this->assertTrue(Set::matches('/Comment[id=2]', $result));
|
$this->assertTrue(Set::matches('/Comment[id=2]', $result));
|
||||||
|
|
Loading…
Add table
Reference in a new issue