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';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
?>
|
||||||
?>
|
|
|
@ -2012,9 +2012,9 @@ class Model extends Overloadable {
|
||||||
$root = $return[0][$this->alias]['parent_id'];
|
$root = $return[0][$this->alias]['parent_id'];
|
||||||
foreach ($return as $key => $value) {
|
foreach ($return as $key => $value) {
|
||||||
if ($value[$this->alias]['parent_id'] != $root) {
|
if ($value[$this->alias]['parent_id'] != $root) {
|
||||||
unset ($return[$key]);
|
unset($return[$key]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $return;
|
return $return;
|
||||||
|
@ -2678,4 +2678,4 @@ class Model extends Overloadable {
|
||||||
if (!defined('CAKEPHP_UNIT_TEST_EXECUTION')) {
|
if (!defined('CAKEPHP_UNIT_TEST_EXECUTION')) {
|
||||||
Overloadable::overload('Model');
|
Overloadable::overload('Model');
|
||||||
}
|
}
|
||||||
?>
|
?>
|
|
@ -38,31 +38,31 @@ App::import('Core', 'db_acl');
|
||||||
class AclPerson extends CakeTestModel {
|
class AclPerson extends CakeTestModel {
|
||||||
/**
|
/**
|
||||||
* name property
|
* name property
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $name = 'AclPerson';
|
var $name = 'AclPerson';
|
||||||
/**
|
/**
|
||||||
* useTable property
|
* useTable property
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $useTable = 'people';
|
var $useTable = 'people';
|
||||||
/**
|
/**
|
||||||
* actsAs property
|
* actsAs property
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $actsAs = array('Acl' => 'requester');
|
var $actsAs = array('Acl' => 'requester');
|
||||||
/**
|
/**
|
||||||
* belongsTo property
|
* belongsTo property
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $belongsTo = array(
|
var $belongsTo = array(
|
||||||
'Mother' => array(
|
'Mother' => array(
|
||||||
'className' => 'AclPerson',
|
'className' => 'AclPerson',
|
||||||
|
@ -71,10 +71,10 @@ class AclPerson extends CakeTestModel {
|
||||||
);
|
);
|
||||||
/**
|
/**
|
||||||
* hasMany property
|
* hasMany property
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $hasMany = array(
|
var $hasMany = array(
|
||||||
'Child' => array(
|
'Child' => array(
|
||||||
'className' => 'AclPerson',
|
'className' => 'AclPerson',
|
||||||
|
@ -86,7 +86,7 @@ class AclPerson extends CakeTestModel {
|
||||||
* ParentNode
|
* ParentNode
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
**/
|
**/
|
||||||
function parentNode() {
|
function parentNode() {
|
||||||
if (!$this->id && empty($this->data)) {
|
if (!$this->id && empty($this->data)) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -94,14 +94,14 @@ class AclPerson extends CakeTestModel {
|
||||||
$data = $this->data;
|
$data = $this->data;
|
||||||
if (empty($this->data)) {
|
if (empty($this->data)) {
|
||||||
$data = $this->read();
|
$data = $this->read();
|
||||||
}
|
}
|
||||||
if (!$data['AclPerson']['mother_id']) {
|
if (!$data['AclPerson']['mother_id']) {
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
return array('AclPerson' => array('id' => $data['AclPerson']['mother_id']));
|
return array('AclPerson' => array('id' => $data['AclPerson']['mother_id']));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -113,30 +113,30 @@ class AclPerson extends CakeTestModel {
|
||||||
class AclUser extends CakeTestModel {
|
class AclUser extends CakeTestModel {
|
||||||
/**
|
/**
|
||||||
* name property
|
* name property
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $name = 'User';
|
var $name = 'User';
|
||||||
/**
|
/**
|
||||||
* useTable property
|
* useTable property
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $useTable = 'users';
|
var $useTable = 'users';
|
||||||
/**
|
/**
|
||||||
* actsAs property
|
* actsAs property
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $actsAs = array('Acl');
|
var $actsAs = array('Acl');
|
||||||
/**
|
/**
|
||||||
* parentNode
|
* parentNode
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function parentNode() {
|
function parentNode() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -151,30 +151,30 @@ class AclUser extends CakeTestModel {
|
||||||
class AclPost extends CakeTestModel {
|
class AclPost extends CakeTestModel {
|
||||||
/**
|
/**
|
||||||
* name property
|
* name property
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $name = 'Post';
|
var $name = 'Post';
|
||||||
/**
|
/**
|
||||||
* useTable property
|
* useTable property
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $useTable = 'posts';
|
var $useTable = 'posts';
|
||||||
/**
|
/**
|
||||||
* actsAs property
|
* actsAs property
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $actsAs = array('Acl' => 'controlled');
|
var $actsAs = array('Acl' => 'controlled');
|
||||||
/**
|
/**
|
||||||
* parentNode
|
* parentNode
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function parentNode() {
|
function parentNode() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -196,11 +196,11 @@ 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();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test Setup of AclBehavior
|
* Test Setup of AclBehavior
|
||||||
*
|
*
|
||||||
|
@ -211,13 +211,13 @@ class AclBehaviorTestCase extends CakeTestCase {
|
||||||
$this->assertTrue(isset($User->Behaviors->Acl->settings['User']));
|
$this->assertTrue(isset($User->Behaviors->Acl->settings['User']));
|
||||||
$this->assertEqual($User->Behaviors->Acl->settings['User']['type'], 'requester');
|
$this->assertEqual($User->Behaviors->Acl->settings['User']['type'], 'requester');
|
||||||
$this->assertTrue(is_object($User->Aro));
|
$this->assertTrue(is_object($User->Aro));
|
||||||
|
|
||||||
$Post =& new AclPost();
|
$Post =& new AclPost();
|
||||||
$this->assertTrue(isset($Post->Behaviors->Acl->settings['Post']));
|
$this->assertTrue(isset($Post->Behaviors->Acl->settings['Post']));
|
||||||
$this->assertEqual($Post->Behaviors->Acl->settings['Post']['type'], 'controlled');
|
$this->assertEqual($Post->Behaviors->Acl->settings['Post']['type'], 'controlled');
|
||||||
$this->assertTrue(is_object($Post->Aco));
|
$this->assertTrue(is_object($Post->Aco));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* test After Save
|
* test After Save
|
||||||
*
|
*
|
||||||
|
@ -230,15 +230,15 @@ class AclBehaviorTestCase extends CakeTestCase {
|
||||||
'author_id' => 1,
|
'author_id' => 1,
|
||||||
'title' => 'Acl Post',
|
'title' => 'Acl Post',
|
||||||
'body' => 'post body',
|
'body' => 'post body',
|
||||||
'published' => 1
|
'published' => 1
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
$Post->save($data);
|
$Post->save($data);
|
||||||
$result = $this->Aco->find('first', array('conditions' => array('Aco.model' => 'Post', 'Aco.foreign_key' => $Post->id)));
|
$result = $this->Aco->find('first', array('conditions' => array('Aco.model' => 'Post', 'Aco.foreign_key' => $Post->id)));
|
||||||
$this->assertTrue(is_array($result));
|
$this->assertTrue(is_array($result));
|
||||||
$this->assertEqual($result['Aco']['model'], 'Post');
|
$this->assertEqual($result['Aco']['model'], 'Post');
|
||||||
$this->assertEqual($result['Aco']['foreign_key'], $Post->id);
|
$this->assertEqual($result['Aco']['foreign_key'], $Post->id);
|
||||||
|
|
||||||
$aroData = array(
|
$aroData = array(
|
||||||
'Aro' => array(
|
'Aro' => array(
|
||||||
'model' => 'AclPerson',
|
'model' => 'AclPerson',
|
||||||
|
@ -247,7 +247,7 @@ class AclBehaviorTestCase extends CakeTestCase {
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$this->Aro->save($aroData);
|
$this->Aro->save($aroData);
|
||||||
|
|
||||||
$Person =& new AclPerson();
|
$Person =& new AclPerson();
|
||||||
$data = array(
|
$data = array(
|
||||||
'AclPerson' => array(
|
'AclPerson' => array(
|
||||||
|
@ -255,18 +255,18 @@ class AclBehaviorTestCase extends CakeTestCase {
|
||||||
'mother_id' => 2,
|
'mother_id' => 2,
|
||||||
'father_id' => 3,
|
'father_id' => 3,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
$Person->save($data);
|
$Person->save($data);
|
||||||
$result = $this->Aro->find('first', array('conditions' => array('Aro.model' => 'AclPerson', 'Aro.foreign_key' => $Person->id)));
|
$result = $this->Aro->find('first', array('conditions' => array('Aro.model' => 'AclPerson', 'Aro.foreign_key' => $Person->id)));
|
||||||
$this->assertTrue(is_array($result));
|
$this->assertTrue(is_array($result));
|
||||||
$this->assertEqual($result['Aro']['parent_id'], 5);
|
$this->assertEqual($result['Aro']['parent_id'], 5);
|
||||||
|
|
||||||
$node = $Person->node(array('model' => 'AclPerson', 'foreign_key' => 8));
|
$node = $Person->node(array('model' => 'AclPerson', 'foreign_key' => 8));
|
||||||
$this->assertEqual(sizeof($node), 2);
|
$this->assertEqual(sizeof($node), 2);
|
||||||
$this->assertEqual($node[0]['Aro']['parent_id'], 5);
|
$this->assertEqual($node[0]['Aro']['parent_id'], 5);
|
||||||
$this->assertEqual($node[1]['Aro']['parent_id'], null);
|
$this->assertEqual($node[1]['Aro']['parent_id'], null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test After Delete
|
* Test After Delete
|
||||||
*
|
*
|
||||||
|
@ -280,7 +280,7 @@ class AclBehaviorTestCase extends CakeTestCase {
|
||||||
'parent_id' => null
|
'parent_id' => null
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$this->Aro->save($aroData);
|
$this->Aro->save($aroData);
|
||||||
$Person =& new AclPerson();
|
$Person =& new AclPerson();
|
||||||
$data = array(
|
$data = array(
|
||||||
'AclPerson' => array(
|
'AclPerson' => array(
|
||||||
|
@ -288,38 +288,38 @@ class AclBehaviorTestCase extends CakeTestCase {
|
||||||
'mother_id' => 2,
|
'mother_id' => 2,
|
||||||
'father_id' => 3,
|
'father_id' => 3,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
$Person->save($data);
|
$Person->save($data);
|
||||||
$id = $Person->id;
|
$id = $Person->id;
|
||||||
$node = $Person->node();
|
$node = $Person->node();
|
||||||
$this->assertEqual(sizeof($node), 2);
|
$this->assertEqual(sizeof($node), 2);
|
||||||
$this->assertEqual($node[0]['Aro']['parent_id'], 5);
|
$this->assertEqual($node[0]['Aro']['parent_id'], 5);
|
||||||
$this->assertEqual($node[1]['Aro']['parent_id'], null);
|
$this->assertEqual($node[1]['Aro']['parent_id'], null);
|
||||||
|
|
||||||
$Person->delete($id);
|
$Person->delete($id);
|
||||||
$result = $this->Aro->find('first', array('conditions' => array('Aro.model' => 'AclPerson', 'Aro.foreign_key' => $id)));
|
$result = $this->Aro->find('first', array('conditions' => array('Aro.model' => 'AclPerson', 'Aro.foreign_key' => $id)));
|
||||||
$this->assertTrue(empty($result));
|
$this->assertTrue(empty($result));
|
||||||
$result = $this->Aro->find('first', array('conditions' => array('Aro.model' => 'AclPerson', 'Aro.foreign_key' => 2)));
|
$result = $this->Aro->find('first', array('conditions' => array('Aro.model' => 'AclPerson', 'Aro.foreign_key' => 2)));
|
||||||
$this->assertFalse(empty($result));
|
$this->assertFalse(empty($result));
|
||||||
|
|
||||||
$data = array(
|
$data = array(
|
||||||
'AclPerson' => array(
|
'AclPerson' => array(
|
||||||
'name' => 'Trent',
|
'name' => 'Trent',
|
||||||
'mother_id' => 2,
|
'mother_id' => 2,
|
||||||
'father_id' => 3,
|
'father_id' => 3,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
$Person->save($data);
|
$Person->save($data);
|
||||||
$id = $Person->id;
|
$id = $Person->id;
|
||||||
$Person->delete(2);
|
$Person->delete(2);
|
||||||
$result = $this->Aro->find('first', array('conditions' => array('Aro.model' => 'AclPerson', 'Aro.foreign_key' => $id)));
|
$result = $this->Aro->find('first', array('conditions' => array('Aro.model' => 'AclPerson', 'Aro.foreign_key' => $id)));
|
||||||
$this->assertTrue(empty($result));
|
$this->assertTrue(empty($result));
|
||||||
|
|
||||||
$result = $this->Aro->find('first', array('conditions' => array('Aro.model' => 'AclPerson', 'Aro.foreign_key' => 2)));
|
$result = $this->Aro->find('first', array('conditions' => array('Aro.model' => 'AclPerson', 'Aro.foreign_key' => 2)));
|
||||||
$this->assertTrue(empty($result));
|
$this->assertTrue(empty($result));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test Node()
|
* Test Node()
|
||||||
*
|
*
|
||||||
|
@ -335,13 +335,13 @@ class AclBehaviorTestCase extends CakeTestCase {
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$this->Aro->save($aroData);
|
$this->Aro->save($aroData);
|
||||||
|
|
||||||
$Person->id = 2;
|
$Person->id = 2;
|
||||||
$result = $Person->node();
|
$result = $Person->node();
|
||||||
$this->assertTrue(is_array($result));
|
$this->assertTrue(is_array($result));
|
||||||
$this->assertEqual(sizeof($result), 1);
|
$this->assertEqual(sizeof($result), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* tear down test
|
* tear down test
|
||||||
*
|
*
|
||||||
|
@ -351,6 +351,6 @@ class AclBehaviorTestCase extends CakeTestCase {
|
||||||
ClassRegistry::flush();
|
ClassRegistry::flush();
|
||||||
unset($this->Aro, $this->Aco);
|
unset($this->Aro, $this->Aco);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
|
@ -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,42 +318,20 @@ 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
|
||||||
*
|
*
|
||||||
* This class is defined purely to inherit the cacheSources variable otherwise testSchemaCreatTable will fail if
|
* This class is defined purely to inherit the cacheSources variable otherwise testSchemaCreatTable will fail if
|
||||||
* listSources has already been called and its source cache populated - I.e. if the test is run within a group
|
* listSources has already been called and its source cache populated - I.e. if the test is run within a group
|
||||||
*
|
*
|
||||||
* @uses CakeTestModel
|
* @uses CakeTestModel
|
||||||
* @package
|
* @package
|
||||||
* @subpackage cake.tests.cases.libs.model
|
* @subpackage cake.tests.cases.libs.model
|
||||||
*/
|
*/
|
||||||
class Testdescribe extends CakeTestModel {
|
class Testdescribe extends CakeTestModel {
|
||||||
/**
|
/**
|
||||||
* name property
|
* name property
|
||||||
*
|
*
|
||||||
* @var string 'Testdescribe'
|
* @var string 'Testdescribe'
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
|
@ -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'));
|
||||||
|
@ -499,4 +478,4 @@ class CakeSchemaTest extends CakeTestCase {
|
||||||
unset($this->Schema);
|
unset($this->Schema);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
|
@ -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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -730,4 +737,4 @@ class CakeTestCase extends UnitTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
Loading…
Add table
Reference in a new issue