mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 02:56:15 +00:00
making changes to all the model group to run. Currently I get 8/8 test cases complete: 1486 passes, 22 fails and 3 exceptions.
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7439 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
99e3b11a61
commit
76f7d6dc43
10 changed files with 111 additions and 124 deletions
|
@ -116,7 +116,6 @@ class ClassRegistry {
|
||||||
if (is_array($settings)) {
|
if (is_array($settings)) {
|
||||||
$plugin = null;
|
$plugin = null;
|
||||||
$settings = array_merge($defaults, $settings);
|
$settings = array_merge($defaults, $settings);
|
||||||
|
|
||||||
extract($settings, EXTR_OVERWRITE);
|
extract($settings, EXTR_OVERWRITE);
|
||||||
|
|
||||||
if (strpos($class, '.') !== false) {
|
if (strpos($class, '.') !== false) {
|
||||||
|
@ -128,9 +127,9 @@ class ClassRegistry {
|
||||||
$alias = $class;
|
$alias = $class;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($_this->_duplicate($alias, $class) && $count == 1) {
|
if ($model =& $_this->_duplicate($alias, $class)) {
|
||||||
$_this->map($alias, $class);
|
$_this->map($alias, $class);
|
||||||
return $_this->getObject($alias);
|
return $model;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($type === 'Model') {
|
if ($type === 'Model') {
|
||||||
|
@ -236,7 +235,6 @@ class ClassRegistry {
|
||||||
function &getObject($key) {
|
function &getObject($key) {
|
||||||
$_this =& ClassRegistry::getInstance();
|
$_this =& ClassRegistry::getInstance();
|
||||||
$key = Inflector::underscore($key);
|
$key = Inflector::underscore($key);
|
||||||
|
|
||||||
if (isset($_this->__objects[$key])) {
|
if (isset($_this->__objects[$key])) {
|
||||||
return $_this->__objects[$key];
|
return $_this->__objects[$key];
|
||||||
} else {
|
} else {
|
||||||
|
@ -282,18 +280,17 @@ class ClassRegistry {
|
||||||
function _duplicate($alias, $class) {
|
function _duplicate($alias, $class) {
|
||||||
$_this =& ClassRegistry::getInstance();
|
$_this =& ClassRegistry::getInstance();
|
||||||
$duplicate = false;
|
$duplicate = false;
|
||||||
|
|
||||||
if ($_this->isKeySet($alias)) {
|
if ($_this->isKeySet($alias)) {
|
||||||
$model = $_this->getObject($alias);
|
$model =& $_this->getObject($alias);
|
||||||
if (is_a($model, $class)) {
|
if ($model->name === $class) {
|
||||||
$duplicate = true;
|
$duplicate =& $model;
|
||||||
}
|
}
|
||||||
unset($model);
|
unset($model);
|
||||||
}
|
}
|
||||||
return $duplicate;
|
return $duplicate;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Add a key name pair to the registry to map name to class in the regisrty.
|
* Add a key name pair to the registry to map name to class in the registry.
|
||||||
*
|
*
|
||||||
* @param string $key Key to include in map
|
* @param string $key Key to include in map
|
||||||
* @param string $name Key that is being mapped
|
* @param string $name Key that is being mapped
|
||||||
|
|
|
@ -98,12 +98,13 @@ class ConnectionManager extends Object {
|
||||||
function &getDataSource($name) {
|
function &getDataSource($name) {
|
||||||
$_this =& ConnectionManager::getInstance();
|
$_this =& ConnectionManager::getInstance();
|
||||||
|
|
||||||
if (in_array($name, array_keys($_this->_dataSources))) {
|
if (!empty($_this->_dataSources[$name])) {
|
||||||
return $_this->_dataSources[$name];
|
$return =& $_this->_dataSources[$name];
|
||||||
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$connections = $_this->enumConnectionObjects();
|
$connections = $_this->enumConnectionObjects();
|
||||||
if (in_array($name, array_keys($connections))) {
|
if (!empty($connections[$name])) {
|
||||||
$conn = $connections[$name];
|
$conn = $connections[$name];
|
||||||
$class = $conn['classname'];
|
$class = $conn['classname'];
|
||||||
$_this->loadDataSource($name);
|
$_this->loadDataSource($name);
|
||||||
|
@ -114,7 +115,8 @@ class ConnectionManager extends Object {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $_this->_dataSources[$name];
|
$return =& $_this->_dataSources[$name];
|
||||||
|
return $return;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Gets the list of available DataSource connections
|
* Gets the list of available DataSource connections
|
||||||
|
@ -164,7 +166,7 @@ class ConnectionManager extends Object {
|
||||||
$conn = $connections[$connName];
|
$conn = $connections[$connName];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($conn['parent']) && !empty($conn['parent'])) {
|
if (!empty($conn['parent'])) {
|
||||||
$_this->loadDataSource($conn['parent']);
|
$_this->loadDataSource($conn['parent']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -225,7 +227,8 @@ class ConnectionManager extends Object {
|
||||||
|
|
||||||
$_this->config->{$name} = $config;
|
$_this->config->{$name} = $config;
|
||||||
$_this->_connectionsEnum[$name] = $_this->__getDriver($config);
|
$_this->_connectionsEnum[$name] = $_this->__getDriver($config);
|
||||||
return $_this->getDataSource($name);
|
$return =& $_this->getDataSource($name);
|
||||||
|
return $return;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Returns the file, class name, and parent for the given driver.
|
* Returns the file, class name, and parent for the given driver.
|
||||||
|
@ -262,5 +265,4 @@ class ConnectionManager extends Object {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
|
@ -193,7 +193,8 @@ class DataSource extends Object {
|
||||||
if ($this->cacheSources === false) {
|
if ($this->cacheSources === false) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if ($this->_sources != null) {
|
|
||||||
|
if ($this->_sources !== null) {
|
||||||
return $this->_sources;
|
return $this->_sources;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -213,9 +214,11 @@ class DataSource extends Object {
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function sources() {
|
function sources($reset = false) {
|
||||||
$return = array_map('strtolower', $this->listSources());
|
if ($reset === true) {
|
||||||
return $return;
|
$this->_sources = null;
|
||||||
|
}
|
||||||
|
return array_map('strtolower', $this->listSources());
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Returns a Model description (metadata) or null if none found.
|
* Returns a Model description (metadata) or null if none found.
|
||||||
|
|
|
@ -511,7 +511,7 @@ class DboSource extends DataSource {
|
||||||
} else {
|
} else {
|
||||||
$out = ("<small>[Aff:{$this->affected} Num:{$this->numRows} Took:{$this->took}ms]</small>");
|
$out = ("<small>[Aff:{$this->affected} Num:{$this->numRows} Took:{$this->took}ms]</small>");
|
||||||
}
|
}
|
||||||
e(sprintf("<p style = \"text-align:left\"><b>Query:</b> %s %s</p>", $sql, $out));
|
pr(sprintf("<p style = \"text-align:left\"><b>Query:</b> %s %s</p>", $sql, $out));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -2412,5 +2412,4 @@ class DboSource extends DataSource {
|
||||||
return 'string';
|
return 'string';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
|
@ -197,8 +197,8 @@ class AclBehaviorTestCase extends CakeTestCase {
|
||||||
function startTest() {
|
function startTest() {
|
||||||
Configure::write('Acl.database', 'test_suite');
|
Configure::write('Acl.database', 'test_suite');
|
||||||
|
|
||||||
$this->Aco = new Aco();
|
$this->Aco =& new Aco();
|
||||||
$this->Aro = new Aro();
|
$this->Aro =& new Aro();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1169,6 +1169,7 @@ class DboSourceTest extends CakeTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->testDb =& new DboTest($this->__config);
|
$this->testDb =& new DboTest($this->__config);
|
||||||
|
$this->testDb->cacheSources = false;
|
||||||
Configure::write('debug', 1);
|
Configure::write('debug', 1);
|
||||||
$this->debug = Configure::read('debug');
|
$this->debug = Configure::read('debug');
|
||||||
$this->Model =& new TestModel();
|
$this->Model =& new TestModel();
|
||||||
|
@ -3489,17 +3490,17 @@ class DboSourceTest extends CakeTestCase {
|
||||||
$Apple =& ClassRegistry::init('Apple');
|
$Apple =& ClassRegistry::init('Apple');
|
||||||
$Article =& ClassRegistry::init('Article');
|
$Article =& ClassRegistry::init('Article');
|
||||||
|
|
||||||
$result = $this->db->rawQuery('SELECT color, name FROM ' . $this->testDb->fullTableName('apples'));
|
$result = $this->testDb->rawQuery('SELECT color, name FROM ' . $this->testDb->fullTableName('apples'));
|
||||||
$this->assertTrue(!empty($result));
|
$this->assertTrue(!empty($result));
|
||||||
|
|
||||||
$result = $this->db->fetchRow($result);
|
$result = $this->testDb->fetchRow($result);
|
||||||
$expected = array($this->testDb->fullTableName('apples', false) => array(
|
$expected = array($this->testDb->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->db->fetchAll('SELECT name FROM ' . $this->testDb->fullTableName('apples') . ' ORDER BY id');
|
$result = $this->testDb->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->testDb->fullTableName('apples', false) => array('name' => 'Red Apple 1')),
|
||||||
array($this->testDb->fullTableName('apples', false) => array('name' => 'Bright Red Apple')),
|
array($this->testDb->fullTableName('apples', false) => array('name' => 'Bright Red Apple')),
|
||||||
|
@ -3511,7 +3512,7 @@ class DboSourceTest extends CakeTestCase {
|
||||||
);
|
);
|
||||||
$this->assertEqual($result, $expected);
|
$this->assertEqual($result, $expected);
|
||||||
|
|
||||||
$result = $this->db->field($this->testDb->fullTableName('apples', false), 'SELECT color, name FROM ' . $this->testDb->fullTableName('apples') . ' ORDER BY id');
|
$result = $this->testDb->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'
|
||||||
|
@ -3519,7 +3520,7 @@ class DboSourceTest extends CakeTestCase {
|
||||||
$this->assertEqual($result, $expected);
|
$this->assertEqual($result, $expected);
|
||||||
|
|
||||||
$Apple->unbindModel(array(), false);
|
$Apple->unbindModel(array(), false);
|
||||||
$result = $this->db->read($Apple, array(
|
$result = $this->testDb->read($Apple, array(
|
||||||
'fields' => array($Apple->escapeField('name')),
|
'fields' => array($Apple->escapeField('name')),
|
||||||
'conditions' => null,
|
'conditions' => null,
|
||||||
'recursive' => -1
|
'recursive' => -1
|
||||||
|
@ -3535,7 +3536,7 @@ class DboSourceTest extends CakeTestCase {
|
||||||
);
|
);
|
||||||
$this->assertEqual($result, $expected);
|
$this->assertEqual($result, $expected);
|
||||||
|
|
||||||
$result = $this->db->read($Article, array(
|
$result = $this->testDb->read($Article, array(
|
||||||
'fields' => array('id', 'user_id', 'title'),
|
'fields' => array('id', 'user_id', 'title'),
|
||||||
'conditions' => null,
|
'conditions' => null,
|
||||||
'recursive' => 1
|
'recursive' => 1
|
||||||
|
@ -3629,6 +3630,6 @@ class DboSourceTest extends CakeTestCase {
|
||||||
$this->testDb->error = $oldError;
|
$this->testDb->error = $oldError;
|
||||||
Configure::write('debug', $oldDebug);
|
Configure::write('debug', $oldDebug);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
?>
|
?>
|
|
@ -5556,5 +5556,4 @@ class ModelTest extends CakeTestCase {
|
||||||
ClassRegistry::flush();
|
ClassRegistry::flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
|
@ -318,28 +318,6 @@ class SchemaDatatype extends CakeTestModel {
|
||||||
*/
|
*/
|
||||||
var $useTable = 'datatypes';
|
var $useTable = 'datatypes';
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* PostsTag class
|
|
||||||
*
|
|
||||||
* @package cake
|
|
||||||
* @subpackage cake.tests.cases.libs.model
|
|
||||||
*/
|
|
||||||
class PostsTag extends CakeTestModel {
|
|
||||||
/**
|
|
||||||
* name property
|
|
||||||
*
|
|
||||||
* @var string 'PostsTag'
|
|
||||||
* @access public
|
|
||||||
*/
|
|
||||||
var $name = 'PostsTag';
|
|
||||||
/**
|
|
||||||
* useTable property
|
|
||||||
*
|
|
||||||
* @var string 'posts_tags'
|
|
||||||
* @access public
|
|
||||||
*/
|
|
||||||
var $useTable = 'posts_tags';
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* Testdescribe class
|
* Testdescribe class
|
||||||
*
|
*
|
||||||
|
@ -417,7 +395,6 @@ class CakeSchemaTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function testSchemaWrite() {
|
function testSchemaWrite() {
|
||||||
|
|
||||||
$write = $this->Schema->write(array('name' => 'MyOtherApp', 'tables' => $this->Schema->tables, 'path' => TMP . 'tests'));
|
$write = $this->Schema->write(array('name' => 'MyOtherApp', 'tables' => $this->Schema->tables, 'path' => TMP . 'tests'));
|
||||||
$file = file_get_contents(TMP . 'tests' . DS .'schema.php');
|
$file = file_get_contents(TMP . 'tests' . DS .'schema.php');
|
||||||
$this->assertEqual($write, $file);
|
$this->assertEqual($write, $file);
|
||||||
|
@ -475,6 +452,8 @@ class CakeSchemaTest extends CakeTestCase {
|
||||||
*/
|
*/
|
||||||
function testSchemaCreateTable() {
|
function testSchemaCreateTable() {
|
||||||
$db =& ConnectionManager::getDataSource('test_suite');
|
$db =& ConnectionManager::getDataSource('test_suite');
|
||||||
|
$db->cacheSources = false;
|
||||||
|
|
||||||
$db->query('CREATE TABLE ' . $db->fullTableName('testdescribes') . ' (id int(11) AUTO_INCREMENT, int_null int(10) unsigned NULL, int_not_null int(10) unsigned NOT NULL, primary key(id));');
|
$db->query('CREATE TABLE ' . $db->fullTableName('testdescribes') . ' (id int(11) AUTO_INCREMENT, int_null int(10) unsigned NULL, int_not_null int(10) unsigned NOT NULL, primary key(id));');
|
||||||
|
|
||||||
$Schema =& new CakeSchema(array('connection' => 'test_suite'));
|
$Schema =& new CakeSchema(array('connection' => 'test_suite'));
|
||||||
|
|
|
@ -371,6 +371,7 @@ class CakeTestCase extends UnitTestCase {
|
||||||
*/
|
*/
|
||||||
function start() {
|
function start() {
|
||||||
if (isset($this->_fixtures) && isset($this->db)) {
|
if (isset($this->_fixtures) && isset($this->db)) {
|
||||||
|
Configure::write('Cache.disable', true);
|
||||||
$cacheSources = $this->db->cacheSources;
|
$cacheSources = $this->db->cacheSources;
|
||||||
$this->db->cacheSources = false;
|
$this->db->cacheSources = false;
|
||||||
$sources = $this->db->listSources();
|
$sources = $this->db->listSources();
|
||||||
|
@ -395,6 +396,12 @@ class CakeTestCase extends UnitTestCase {
|
||||||
foreach (array_reverse($this->_fixtures) as $fixture) {
|
foreach (array_reverse($this->_fixtures) as $fixture) {
|
||||||
$fixture->drop($this->db);
|
$fixture->drop($this->db);
|
||||||
}
|
}
|
||||||
|
$this->db->sources(true);
|
||||||
|
Configure::write('Cache.disable', false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (class_exists('ClassRegistry')) {
|
||||||
|
ClassRegistry::flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue