Adding fix for Ticket #2232.

Added tests for ticket

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@4714 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
phpnut 2007-03-30 00:08:10 +00:00
parent 41012b86ba
commit 3a62793d0e
3 changed files with 254 additions and 232 deletions

View file

@ -787,7 +787,23 @@ class DboSource extends DataSource {
$data[$association] = $merge[0][$association]; $data[$association] = $merge[0][$association];
} else { } else {
if(is_array($merge[0][$association])){ if(is_array($merge[0][$association])){
$data[$association] = array_merge($merge[0][$association], $data[$association]); foreach ($data[$association] as $k => $v) {
if(!is_array($v)){
$dataAssocTmp[$k] = $v;
}
}
foreach ($merge[0][$association] as $k => $v) {
if(!is_array($v)){
$mergeAssocTmp[$k] = $v;
}
}
if ($mergeAssocTmp == $dataAssocTmp) {
$data[$association] = array_merge($merge[0][$association], $data[$association]);
} else {
$data[$association][$association] = $merge[0][$association];
}
} }
} }
} }
@ -830,7 +846,7 @@ class DboSource extends DataSource {
if (!isset($queryData['selfJoin'])) { if (!isset($queryData['selfJoin'])) {
$queryData['selfJoin'] = array(); $queryData['selfJoin'] = array();
$self = array( $self = array(
'fields' => $this->fields($model, null, $queryData['fields']), 'fields' => $this->fields($model, null, $queryData['fields']),
'joins' => array(array( 'joins' => array(array(
@ -846,7 +862,7 @@ class DboSource extends DataSource {
'conditions'=> $queryData['conditions'], 'conditions'=> $queryData['conditions'],
'order' => $queryData['order'] 'order' => $queryData['order']
); );
if (!empty($queryData['joins'])) { if (!empty($queryData['joins'])) {
foreach($queryData['joins'] as $join) { foreach($queryData['joins'] as $join) {
$self['joins'][] = $join; $self['joins'][] = $join;

View file

@ -151,55 +151,61 @@
*/ */
class ModelTest extends CakeTestCase { class ModelTest extends CakeTestCase {
var $fixtures = array( 'core.category', 'core.category_thread', 'core.user', 'core.article', 'core.tag', 'core.articles_tag', 'core.comment', 'core.attachment' ); var $fixtures = array( 'core.category', 'core.category_thread', 'core.user', 'core.article', 'core.tag', 'core.articles_tag', 'core.comment', 'core.attachment' );
function start() { function start() {
parent::start(); parent::start();
Configure::write('debug', 2); Configure::write('debug', 2);
} }
function end() { function end() {
parent::end(); parent::end();
Configure::write('debug', DEBUG); Configure::write('debug', DEBUG);
} }
function testIdentity() { function testIdentity() {
$this->model =& new Test(); $this->model =& new Test();
$result = $this->model->name; $result = $this->model->name;
$expected = 'Test'; $expected = 'Test';
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
} }
function testCreation() { function testCreation() {
$this->model =& new Test(); $this->model =& new Test();
$result = $this->model->create(); $result = $this->model->create();
$expected = array('Test' => array('notes' => 'write some notes here')); $expected = array('Test' => array('notes' => 'write some notes here'));
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
$this->model =& new User(); $this->model =& new User();
$result = $this->model->_tableInfo->value; $result = $this->model->_tableInfo->value;
$expected = array ( 0 => array ( 'name' => 'id', 'type' => 'integer', 'null' => false, 'default' => NULL, 'length' => 11, ), 1 => array ( 'name' => 'user', 'type' => 'string', 'null' => false, 'default' => '', 'length' => 255, ), 2 => array ( 'name' => 'password', 'type' => 'string', 'null' => false, 'default' => '', 'length' => 255, ), 3 => array ( 'name' => 'created', 'type' => 'datetime', 'null' => true, 'default' => NULL, 'length' => NULL, ), 4 => array ( 'name' => 'updated', 'type' => 'datetime', 'null' => true, 'default' => NULL, 'length' => NULL)); $expected = array ( 0 => array ( 'name' => 'id', 'type' => 'integer', 'null' => false, 'default' => NULL, 'length' => 11, ), 1 => array ( 'name' => 'user', 'type' => 'string', 'null' => false, 'default' => '', 'length' => 255, ), 2 => array ( 'name' => 'password', 'type' => 'string', 'null' => false, 'default' => '', 'length' => 255, ), 3 => array ( 'name' => 'created', 'type' => 'datetime', 'null' => true, 'default' => NULL, 'length' => NULL, ), 4 => array ( 'name' => 'updated', 'type' => 'datetime', 'null' => true, 'default' => NULL, 'length' => NULL));
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
$this->model =& new Article(); $this->model =& new Article();
$result = $this->model->create(); $result = $this->model->create();
$expected = array ('Article' => array('published' => 'N')); $expected = array ('Article' => array('published' => 'N'));
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
} }
function testFindAllFakeThread() { function testFindAllFakeThread() {
$this->model =& new CategoryThread(); $this->model =& new CategoryThread();
$this->db->fullDebug = true;
$this->model->recursive = 10;
$this->model->id = 1;
$data = $this->model->read();
pr($data); $this->db->fullDebug = true;
$this->model->recursive = 6;
$this->model->id = 7;
$result = $this->model->read();
$expected = array('CategoryThread' => array('id' => 7, 'parent_id' => 6, 'name' => 'Category 2.1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31'),
'ParentCategory' => array('id' => 6, 'parent_id' => 5, 'name' => 'Category 2', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31',
'ParentCategory' => array('id' => 5, 'parent_id' => 4, 'name' => 'Category 1.1.1.1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31',
'ParentCategory' => array('id' => 4, 'parent_id' => 3, 'name' => 'Category 1.1.2', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31',
'ParentCategory' => array('id' => 3, 'parent_id' => 2, 'name' => 'Category 1.1.1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31',
'ParentCategory' => array('id' => 2, 'parent_id' => 1, 'name' => 'Category 1.1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31',
'ParentCategory' => array('id' => 1, 'parent_id' => 0, 'name' => 'Category 1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31')))))));
$this->assertEqual($result, $expected);
} }
function testFindAll() { function testFindAll() {
$this->model =& new User(); $this->model =& new User();
$result = $this->model->findAll(); $result = $this->model->findAll();
$expected = array( $expected = array(
array ( 'User' => array ( 'id' => '1', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31')), array ( 'User' => array ( 'id' => '1', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31')),
@ -208,21 +214,21 @@ class ModelTest extends CakeTestCase {
array ( 'User' => array ( 'id' => '4', 'user' => 'garrett', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:22:23', 'updated' => '2007-03-17 01:24:31')) array ( 'User' => array ( 'id' => '4', 'user' => 'garrett', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:22:23', 'updated' => '2007-03-17 01:24:31'))
); );
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
$result = $this->model->findAll('User.id > 2'); $result = $this->model->findAll('User.id > 2');
$expected = array( $expected = array(
array ( 'User' => array ( 'id' => '3', 'user' => 'larry', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:20:23', 'updated' => '2007-03-17 01:22:31')), array ( 'User' => array ( 'id' => '3', 'user' => 'larry', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:20:23', 'updated' => '2007-03-17 01:22:31')),
array ( 'User' => array ( 'id' => '4', 'user' => 'garrett', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:22:23', 'updated' => '2007-03-17 01:24:31')) array ( 'User' => array ( 'id' => '4', 'user' => 'garrett', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:22:23', 'updated' => '2007-03-17 01:24:31'))
); );
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
$result = $this->model->findAll(array('User.id' => '!= 0', 'User.user' => 'LIKE %arr%')); $result = $this->model->findAll(array('User.id' => '!= 0', 'User.user' => 'LIKE %arr%'));
$expected = array( $expected = array(
array ( 'User' => array ( 'id' => '3', 'user' => 'larry', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:20:23', 'updated' => '2007-03-17 01:22:31')), array ( 'User' => array ( 'id' => '3', 'user' => 'larry', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:20:23', 'updated' => '2007-03-17 01:22:31')),
array ( 'User' => array ( 'id' => '4', 'user' => 'garrett', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:22:23', 'updated' => '2007-03-17 01:24:31')) array ( 'User' => array ( 'id' => '4', 'user' => 'garrett', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:22:23', 'updated' => '2007-03-17 01:24:31'))
); );
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
$result = $this->model->findAll(array('User.id' => '0')); $result = $this->model->findAll(array('User.id' => '0'));
$expected = array(); $expected = array();
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
@ -235,7 +241,7 @@ class ModelTest extends CakeTestCase {
array ( 'User' => array ( 'id' => '4', 'user' => 'garrett', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:22:23', 'updated' => '2007-03-17 01:24:31')) array ( 'User' => array ( 'id' => '4', 'user' => 'garrett', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:22:23', 'updated' => '2007-03-17 01:24:31'))
); );
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
$result = $this->model->findAll(null, 'User.id, User.user'); $result = $this->model->findAll(null, 'User.id, User.user');
$expected = array( $expected = array(
array ( 'User' => array ( 'id' => '1', 'user' => 'mariano')), array ( 'User' => array ( 'id' => '1', 'user' => 'mariano')),
@ -253,7 +259,7 @@ class ModelTest extends CakeTestCase {
array ( 'User' => array ( 'user' => 'nate')) array ( 'User' => array ( 'user' => 'nate'))
); );
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
$result = $this->model->findAll(null, 'User.user', 'User.user ASC'); $result = $this->model->findAll(null, 'User.user', 'User.user ASC');
$expected = array( $expected = array(
array ( 'User' => array ( 'user' => 'garrett')), array ( 'User' => array ( 'user' => 'garrett')),
@ -262,7 +268,7 @@ class ModelTest extends CakeTestCase {
array ( 'User' => array ( 'user' => 'nate')) array ( 'User' => array ( 'user' => 'nate'))
); );
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
$result = $this->model->findAll(null, 'User.user', 'User.user DESC'); $result = $this->model->findAll(null, 'User.user', 'User.user DESC');
$expected = array( $expected = array(
array ( 'User' => array ( 'user' => 'nate')), array ( 'User' => array ( 'user' => 'nate')),
@ -271,7 +277,7 @@ class ModelTest extends CakeTestCase {
array ( 'User' => array ( 'user' => 'garrett')) array ( 'User' => array ( 'user' => 'garrett'))
); );
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
$result = $this->model->findAll(null, null, null, 3, 1); $result = $this->model->findAll(null, null, null, 3, 1);
$expected = array( $expected = array(
array ( 'User' => array ( 'id' => '1', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31')), array ( 'User' => array ( 'id' => '1', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31')),
@ -279,13 +285,13 @@ class ModelTest extends CakeTestCase {
array ( 'User' => array ( 'id' => '3', 'user' => 'larry', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:20:23', 'updated' => '2007-03-17 01:22:31')) array ( 'User' => array ( 'id' => '3', 'user' => 'larry', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:20:23', 'updated' => '2007-03-17 01:22:31'))
); );
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
$result = $this->model->findAll(null, null, null, 3, 2); $result = $this->model->findAll(null, null, null, 3, 2);
$expected = array( $expected = array(
array ( 'User' => array ( 'id' => '4', 'user' => 'garrett', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:22:23', 'updated' => '2007-03-17 01:24:31')) array ( 'User' => array ( 'id' => '4', 'user' => 'garrett', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:22:23', 'updated' => '2007-03-17 01:24:31'))
); );
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
$result = $this->model->findAll(null, null, null, 3, 3); $result = $this->model->findAll(null, null, null, 3, 3);
$expected = array(); $expected = array();
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
@ -314,28 +320,28 @@ class ModelTest extends CakeTestCase {
function testBindUnbind() { function testBindUnbind() {
$this->model =& new User(); $this->model =& new User();
$result = $this->model->hasMany; $result = $this->model->hasMany;
$expected = array(); $expected = array();
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
$result = $this->model->bindModel(array('hasMany' => array('Comment'))); $result = $this->model->bindModel(array('hasMany' => array('Comment')));
$this->assertTrue($result); $this->assertTrue($result);
$result = $this->model->findAll(null, 'User.id, User.user'); $result = $this->model->findAll(null, 'User.id, User.user');
$expected = array( $expected = array(
array ( 'User' => array ( 'id' => '1', 'user' => 'mariano'), 'Comment' => array( array ( 'User' => array ( 'id' => '1', 'user' => 'mariano'), 'Comment' => array(
array( 'id' => '3', 'article_id' => '1', 'user_id' => '1', 'comment' => 'Third Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:49:23', 'updated' => '2007-03-18 10:51:31'), array( 'id' => '3', 'article_id' => '1', 'user_id' => '1', 'comment' => 'Third Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:49:23', 'updated' => '2007-03-18 10:51:31'),
array( 'id' => '4', 'article_id' => '1', 'user_id' => '1', 'comment' => 'Fourth Comment for First Article', 'published' => 'N', 'created' => '2007-03-18 10:51:23', 'updated' => '2007-03-18 10:53:31'), array( 'id' => '4', 'article_id' => '1', 'user_id' => '1', 'comment' => 'Fourth Comment for First Article', 'published' => 'N', 'created' => '2007-03-18 10:51:23', 'updated' => '2007-03-18 10:53:31'),
array( 'id' => '5', 'article_id' => '2', 'user_id' => '1', 'comment' => 'First Comment for Second Article', 'published' => 'Y', 'created' => '2007-03-18 10:53:23', 'updated' => '2007-03-18 10:55:31') array( 'id' => '5', 'article_id' => '2', 'user_id' => '1', 'comment' => 'First Comment for Second Article', 'published' => 'Y', 'created' => '2007-03-18 10:53:23', 'updated' => '2007-03-18 10:55:31')
)), )),
array ( 'User' => array ( 'id' => '2', 'user' => 'nate'), 'Comment' => array( array ( 'User' => array ( 'id' => '2', 'user' => 'nate'), 'Comment' => array(
array( 'id' => '1', 'article_id' => '1', 'user_id' => '2', 'comment' => 'First Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:45:23', 'updated' => '2007-03-18 10:47:31'), array( 'id' => '1', 'article_id' => '1', 'user_id' => '2', 'comment' => 'First Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:45:23', 'updated' => '2007-03-18 10:47:31'),
array( 'id' => '6', 'article_id' => '2', 'user_id' => '2', 'comment' => 'Second Comment for Second Article', 'published' => 'Y', 'created' => '2007-03-18 10:55:23', 'updated' => '2007-03-18 10:57:31') array( 'id' => '6', 'article_id' => '2', 'user_id' => '2', 'comment' => 'Second Comment for Second Article', 'published' => 'Y', 'created' => '2007-03-18 10:55:23', 'updated' => '2007-03-18 10:57:31')
)), )),
array ( 'User' => array ( 'id' => '3', 'user' => 'larry'), 'Comment' => array()), array ( 'User' => array ( 'id' => '3', 'user' => 'larry'), 'Comment' => array()),
array ( 'User' => array ( 'id' => '4', 'user' => 'garrett'), 'Comment' => array( array ( 'User' => array ( 'id' => '4', 'user' => 'garrett'), 'Comment' => array(
array( 'id' => '2', 'article_id' => '1', 'user_id' => '4', 'comment' => 'Second Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:47:23', 'updated' => '2007-03-18 10:49:31') array( 'id' => '2', 'article_id' => '1', 'user_id' => '4', 'comment' => 'Second Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:47:23', 'updated' => '2007-03-18 10:49:31')
)) ))
); );
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
@ -346,36 +352,36 @@ class ModelTest extends CakeTestCase {
$result = $this->model->bindModel(array('hasMany' => array('Comment')), false); $result = $this->model->bindModel(array('hasMany' => array('Comment')), false);
$this->assertTrue($result); $this->assertTrue($result);
$result = $this->model->findAll(null, 'User.id, User.user'); $result = $this->model->findAll(null, 'User.id, User.user');
$expected = array( $expected = array(
array ( 'User' => array ( 'id' => '1', 'user' => 'mariano'), 'Comment' => array( array ( 'User' => array ( 'id' => '1', 'user' => 'mariano'), 'Comment' => array(
array( 'id' => '3', 'article_id' => '1', 'user_id' => '1', 'comment' => 'Third Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:49:23', 'updated' => '2007-03-18 10:51:31'), array( 'id' => '3', 'article_id' => '1', 'user_id' => '1', 'comment' => 'Third Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:49:23', 'updated' => '2007-03-18 10:51:31'),
array( 'id' => '4', 'article_id' => '1', 'user_id' => '1', 'comment' => 'Fourth Comment for First Article', 'published' => 'N', 'created' => '2007-03-18 10:51:23', 'updated' => '2007-03-18 10:53:31'), array( 'id' => '4', 'article_id' => '1', 'user_id' => '1', 'comment' => 'Fourth Comment for First Article', 'published' => 'N', 'created' => '2007-03-18 10:51:23', 'updated' => '2007-03-18 10:53:31'),
array( 'id' => '5', 'article_id' => '2', 'user_id' => '1', 'comment' => 'First Comment for Second Article', 'published' => 'Y', 'created' => '2007-03-18 10:53:23', 'updated' => '2007-03-18 10:55:31') array( 'id' => '5', 'article_id' => '2', 'user_id' => '1', 'comment' => 'First Comment for Second Article', 'published' => 'Y', 'created' => '2007-03-18 10:53:23', 'updated' => '2007-03-18 10:55:31')
)), )),
array ( 'User' => array ( 'id' => '2', 'user' => 'nate'), 'Comment' => array( array ( 'User' => array ( 'id' => '2', 'user' => 'nate'), 'Comment' => array(
array( 'id' => '1', 'article_id' => '1', 'user_id' => '2', 'comment' => 'First Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:45:23', 'updated' => '2007-03-18 10:47:31'), array( 'id' => '1', 'article_id' => '1', 'user_id' => '2', 'comment' => 'First Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:45:23', 'updated' => '2007-03-18 10:47:31'),
array( 'id' => '6', 'article_id' => '2', 'user_id' => '2', 'comment' => 'Second Comment for Second Article', 'published' => 'Y', 'created' => '2007-03-18 10:55:23', 'updated' => '2007-03-18 10:57:31') array( 'id' => '6', 'article_id' => '2', 'user_id' => '2', 'comment' => 'Second Comment for Second Article', 'published' => 'Y', 'created' => '2007-03-18 10:55:23', 'updated' => '2007-03-18 10:57:31')
)), )),
array ( 'User' => array ( 'id' => '3', 'user' => 'larry'), 'Comment' => array()), array ( 'User' => array ( 'id' => '3', 'user' => 'larry'), 'Comment' => array()),
array ( 'User' => array ( 'id' => '4', 'user' => 'garrett'), 'Comment' => array( array ( 'User' => array ( 'id' => '4', 'user' => 'garrett'), 'Comment' => array(
array( 'id' => '2', 'article_id' => '1', 'user_id' => '4', 'comment' => 'Second Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:47:23', 'updated' => '2007-03-18 10:49:31') array( 'id' => '2', 'article_id' => '1', 'user_id' => '4', 'comment' => 'Second Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:47:23', 'updated' => '2007-03-18 10:49:31')
)) ))
); );
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
$result = $this->model->hasMany; $result = $this->model->hasMany;
$expected = array( 'Comment' => array('className' => 'Comment', 'foreignKey' => 'user_id', 'conditions' => null, 'fields' => null, 'order' => null, 'limit' => null, 'offset' => null, 'dependent' => null, 'exclusive' => null, 'finderQuery' => null, 'counterQuery' => null) ); $expected = array( 'Comment' => array('className' => 'Comment', 'foreignKey' => 'user_id', 'conditions' => null, 'fields' => null, 'order' => null, 'limit' => null, 'offset' => null, 'dependent' => null, 'exclusive' => null, 'finderQuery' => null, 'counterQuery' => null) );
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
$result = $this->model->unbindModel(array('hasMany' => array('Comment'))); $result = $this->model->unbindModel(array('hasMany' => array('Comment')));
$this->assertTrue($result); $this->assertTrue($result);
$result = $this->model->hasMany; $result = $this->model->hasMany;
$expected = array(); $expected = array();
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
$result = $this->model->findAll(null, 'User.id, User.user'); $result = $this->model->findAll(null, 'User.id, User.user');
$expected = array( $expected = array(
array ( 'User' => array ( 'id' => '1', 'user' => 'mariano')), array ( 'User' => array ( 'id' => '1', 'user' => 'mariano')),
@ -384,28 +390,28 @@ class ModelTest extends CakeTestCase {
array ( 'User' => array ( 'id' => '4', 'user' => 'garrett')) array ( 'User' => array ( 'id' => '4', 'user' => 'garrett'))
); );
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
$result = $this->model->findAll(null, 'User.id, User.user'); $result = $this->model->findAll(null, 'User.id, User.user');
$expected = array( $expected = array(
array ( 'User' => array ( 'id' => '1', 'user' => 'mariano'), 'Comment' => array( array ( 'User' => array ( 'id' => '1', 'user' => 'mariano'), 'Comment' => array(
array( 'id' => '3', 'article_id' => '1', 'user_id' => '1', 'comment' => 'Third Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:49:23', 'updated' => '2007-03-18 10:51:31'), array( 'id' => '3', 'article_id' => '1', 'user_id' => '1', 'comment' => 'Third Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:49:23', 'updated' => '2007-03-18 10:51:31'),
array( 'id' => '4', 'article_id' => '1', 'user_id' => '1', 'comment' => 'Fourth Comment for First Article', 'published' => 'N', 'created' => '2007-03-18 10:51:23', 'updated' => '2007-03-18 10:53:31'), array( 'id' => '4', 'article_id' => '1', 'user_id' => '1', 'comment' => 'Fourth Comment for First Article', 'published' => 'N', 'created' => '2007-03-18 10:51:23', 'updated' => '2007-03-18 10:53:31'),
array( 'id' => '5', 'article_id' => '2', 'user_id' => '1', 'comment' => 'First Comment for Second Article', 'published' => 'Y', 'created' => '2007-03-18 10:53:23', 'updated' => '2007-03-18 10:55:31') array( 'id' => '5', 'article_id' => '2', 'user_id' => '1', 'comment' => 'First Comment for Second Article', 'published' => 'Y', 'created' => '2007-03-18 10:53:23', 'updated' => '2007-03-18 10:55:31')
)), )),
array ( 'User' => array ( 'id' => '2', 'user' => 'nate'), 'Comment' => array( array ( 'User' => array ( 'id' => '2', 'user' => 'nate'), 'Comment' => array(
array( 'id' => '1', 'article_id' => '1', 'user_id' => '2', 'comment' => 'First Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:45:23', 'updated' => '2007-03-18 10:47:31'), array( 'id' => '1', 'article_id' => '1', 'user_id' => '2', 'comment' => 'First Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:45:23', 'updated' => '2007-03-18 10:47:31'),
array( 'id' => '6', 'article_id' => '2', 'user_id' => '2', 'comment' => 'Second Comment for Second Article', 'published' => 'Y', 'created' => '2007-03-18 10:55:23', 'updated' => '2007-03-18 10:57:31') array( 'id' => '6', 'article_id' => '2', 'user_id' => '2', 'comment' => 'Second Comment for Second Article', 'published' => 'Y', 'created' => '2007-03-18 10:55:23', 'updated' => '2007-03-18 10:57:31')
)), )),
array ( 'User' => array ( 'id' => '3', 'user' => 'larry'), 'Comment' => array()), array ( 'User' => array ( 'id' => '3', 'user' => 'larry'), 'Comment' => array()),
array ( 'User' => array ( 'id' => '4', 'user' => 'garrett'), 'Comment' => array( array ( 'User' => array ( 'id' => '4', 'user' => 'garrett'), 'Comment' => array(
array( 'id' => '2', 'article_id' => '1', 'user_id' => '4', 'comment' => 'Second Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:47:23', 'updated' => '2007-03-18 10:49:31') array( 'id' => '2', 'article_id' => '1', 'user_id' => '4', 'comment' => 'Second Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:47:23', 'updated' => '2007-03-18 10:49:31')
)) ))
); );
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
$result = $this->model->unbindModel(array('hasMany' => array('Comment')), false); $result = $this->model->unbindModel(array('hasMany' => array('Comment')), false);
$this->assertTrue($result); $this->assertTrue($result);
$result = $this->model->findAll(null, 'User.id, User.user'); $result = $this->model->findAll(null, 'User.id, User.user');
$expected = array( $expected = array(
array ( 'User' => array ( 'id' => '1', 'user' => 'mariano')), array ( 'User' => array ( 'id' => '1', 'user' => 'mariano')),
@ -414,27 +420,27 @@ class ModelTest extends CakeTestCase {
array ( 'User' => array ( 'id' => '4', 'user' => 'garrett')) array ( 'User' => array ( 'id' => '4', 'user' => 'garrett'))
); );
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
$result = $this->model->hasMany; $result = $this->model->hasMany;
$expected = array(); $expected = array();
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
$result = $this->model->bindModel(array('hasMany' => array('Comment' => array('className' => 'Comment', 'conditions' => 'Comment.published = \'Y\'') ))); $result = $this->model->bindModel(array('hasMany' => array('Comment' => array('className' => 'Comment', 'conditions' => 'Comment.published = \'Y\'') )));
$this->assertTrue($result); $this->assertTrue($result);
$result = $this->model->findAll(null, 'User.id, User.user'); $result = $this->model->findAll(null, 'User.id, User.user');
$expected = array( $expected = array(
array ( 'User' => array ( 'id' => '1', 'user' => 'mariano'), 'Comment' => array( array ( 'User' => array ( 'id' => '1', 'user' => 'mariano'), 'Comment' => array(
array( 'id' => '3', 'article_id' => '1', 'user_id' => '1', 'comment' => 'Third Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:49:23', 'updated' => '2007-03-18 10:51:31'), array( 'id' => '3', 'article_id' => '1', 'user_id' => '1', 'comment' => 'Third Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:49:23', 'updated' => '2007-03-18 10:51:31'),
array( 'id' => '5', 'article_id' => '2', 'user_id' => '1', 'comment' => 'First Comment for Second Article', 'published' => 'Y', 'created' => '2007-03-18 10:53:23', 'updated' => '2007-03-18 10:55:31') array( 'id' => '5', 'article_id' => '2', 'user_id' => '1', 'comment' => 'First Comment for Second Article', 'published' => 'Y', 'created' => '2007-03-18 10:53:23', 'updated' => '2007-03-18 10:55:31')
)), )),
array ( 'User' => array ( 'id' => '2', 'user' => 'nate'), 'Comment' => array( array ( 'User' => array ( 'id' => '2', 'user' => 'nate'), 'Comment' => array(
array( 'id' => '1', 'article_id' => '1', 'user_id' => '2', 'comment' => 'First Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:45:23', 'updated' => '2007-03-18 10:47:31'), array( 'id' => '1', 'article_id' => '1', 'user_id' => '2', 'comment' => 'First Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:45:23', 'updated' => '2007-03-18 10:47:31'),
array( 'id' => '6', 'article_id' => '2', 'user_id' => '2', 'comment' => 'Second Comment for Second Article', 'published' => 'Y', 'created' => '2007-03-18 10:55:23', 'updated' => '2007-03-18 10:57:31') array( 'id' => '6', 'article_id' => '2', 'user_id' => '2', 'comment' => 'Second Comment for Second Article', 'published' => 'Y', 'created' => '2007-03-18 10:55:23', 'updated' => '2007-03-18 10:57:31')
)), )),
array ( 'User' => array ( 'id' => '3', 'user' => 'larry'), 'Comment' => array()), array ( 'User' => array ( 'id' => '3', 'user' => 'larry'), 'Comment' => array()),
array ( 'User' => array ( 'id' => '4', 'user' => 'garrett'), 'Comment' => array( array ( 'User' => array ( 'id' => '4', 'user' => 'garrett'), 'Comment' => array(
array( 'id' => '2', 'article_id' => '1', 'user_id' => '4', 'comment' => 'Second Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:47:23', 'updated' => '2007-03-18 10:49:31') array( 'id' => '2', 'article_id' => '1', 'user_id' => '4', 'comment' => 'Second Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:47:23', 'updated' => '2007-03-18 10:49:31')
)) ))
); );
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
@ -459,47 +465,47 @@ class ModelTest extends CakeTestCase {
function testFindMagic() { function testFindMagic() {
$this->model =& new User(); $this->model =& new User();
$result = $this->model->findByUser('mariano'); $result = $this->model->findByUser('mariano');
$expected = array ( 'User' => array ( $expected = array ( 'User' => array (
'id' => '1', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' 'id' => '1', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31'
)); ));
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
$result = $this->model->findByPassword('5f4dcc3b5aa765d61d8327deb882cf99'); $result = $this->model->findByPassword('5f4dcc3b5aa765d61d8327deb882cf99');
$expected = array ( 'User' => array ( $expected = array ( 'User' => array (
'id' => '1', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' 'id' => '1', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31'
)); ));
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
} }
function testRead() { function testRead() {
$this->model =& new User(); $this->model =& new User();
$result = $this->model->read(); $result = $this->model->read();
$this->assertFalse($result); $this->assertFalse($result);
$this->model->id = 2; $this->model->id = 2;
$result = $this->model->read(); $result = $this->model->read();
$expected = array('User' => array ( 'id' => '2', 'user' => 'nate', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:18:23', 'updated' => '2007-03-17 01:20:31')); $expected = array('User' => array ( 'id' => '2', 'user' => 'nate', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:18:23', 'updated' => '2007-03-17 01:20:31'));
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
$result = $this->model->read(null, 2); $result = $this->model->read(null, 2);
$expected = array('User' => array ( 'id' => '2', 'user' => 'nate', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:18:23', 'updated' => '2007-03-17 01:20:31')); $expected = array('User' => array ( 'id' => '2', 'user' => 'nate', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:18:23', 'updated' => '2007-03-17 01:20:31'));
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
$this->model->id = 2; $this->model->id = 2;
$result = $this->model->read(array('id', 'user')); $result = $this->model->read(array('id', 'user'));
$expected = array('User' => array ( 'id' => '2', 'user' => 'nate')); $expected = array('User' => array ( 'id' => '2', 'user' => 'nate'));
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
$result = $this->model->read('id, user', 2); $result = $this->model->read('id, user', 2);
$expected = array('User' => array ( 'id' => '2', 'user' => 'nate')); $expected = array('User' => array ( 'id' => '2', 'user' => 'nate'));
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
$result = $this->model->bindModel(array('hasMany' => array('Article'))); $result = $this->model->bindModel(array('hasMany' => array('Article')));
$this->assertTrue($result); $this->assertTrue($result);
$this->model->id = 1; $this->model->id = 1;
$result = $this->model->read('id, user'); $result = $this->model->read('id, user');
$expected = array( $expected = array(
@ -511,7 +517,7 @@ class ModelTest extends CakeTestCase {
); );
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
} }
function testRecursiveRead() { function testRecursiveRead() {
$this->model =& new User(); $this->model =& new User();
@ -541,10 +547,10 @@ class ModelTest extends CakeTestCase {
$expected = array( $expected = array(
'User' => array ( 'id' => '3', 'user' => 'larry'), 'User' => array ( 'id' => '3', 'user' => 'larry'),
'Article' => array( 'Article' => array(
array( array(
'id' => '2', 'user_id' => '3', 'title' => 'Second Article', 'body' => 'Second Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31', 'id' => '2', 'user_id' => '3', 'title' => 'Second Article', 'body' => 'Second Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31',
'User' => array ( 'User' => array (
'id' => '3', 'user' => 'larry', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:20:23', 'updated' => '2007-03-17 01:22:31' 'id' => '3', 'user' => 'larry', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:20:23', 'updated' => '2007-03-17 01:22:31'
), ),
'Comment' => array( 'Comment' => array(
array( 'id' => '5', 'article_id' => '2', 'user_id' => '1', 'comment' => 'First Comment for Second Article', 'published' => 'Y', 'created' => '2007-03-18 10:53:23', 'updated' => '2007-03-18 10:55:31'), array( 'id' => '5', 'article_id' => '2', 'user_id' => '1', 'comment' => 'First Comment for Second Article', 'published' => 'Y', 'created' => '2007-03-18 10:53:23', 'updated' => '2007-03-18 10:55:31'),
@ -559,164 +565,164 @@ class ModelTest extends CakeTestCase {
); );
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
} }
function testRecursiveFindAll() { function testRecursiveFindAll() {
$this->model =& new Article(); $this->model =& new Article();
$result = $this->model->findAll(array('Article.user_id' => 1)); $result = $this->model->findAll(array('Article.user_id' => 1));
$expected = array ( $expected = array (
array ( array (
'Article' => array ( 'Article' => array (
'id' => '1', 'user_id' => '1', 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' 'id' => '1', 'user_id' => '1', 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31'
), ),
'User' => array ( 'User' => array (
'id' => '1', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' 'id' => '1', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31'
), ),
'Comment' => array ( 'Comment' => array (
array ( 'id' => '1', 'article_id' => '1', 'user_id' => '2', 'comment' => 'First Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:45:23', 'updated' => '2007-03-18 10:47:31'), array ( 'id' => '1', 'article_id' => '1', 'user_id' => '2', 'comment' => 'First Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:45:23', 'updated' => '2007-03-18 10:47:31'),
array ( 'id' => '2', 'article_id' => '1', 'user_id' => '4', 'comment' => 'Second Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:47:23', 'updated' => '2007-03-18 10:49:31'), array ( 'id' => '2', 'article_id' => '1', 'user_id' => '4', 'comment' => 'Second Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:47:23', 'updated' => '2007-03-18 10:49:31'),
array ( 'id' => '3', 'article_id' => '1', 'user_id' => '1', 'comment' => 'Third Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:49:23', 'updated' => '2007-03-18 10:51:31'), array ( 'id' => '3', 'article_id' => '1', 'user_id' => '1', 'comment' => 'Third Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:49:23', 'updated' => '2007-03-18 10:51:31'),
array ( 'id' => '4', 'article_id' => '1', 'user_id' => '1', 'comment' => 'Fourth Comment for First Article', 'published' => 'N', 'created' => '2007-03-18 10:51:23', 'updated' => '2007-03-18 10:53:31') array ( 'id' => '4', 'article_id' => '1', 'user_id' => '1', 'comment' => 'Fourth Comment for First Article', 'published' => 'N', 'created' => '2007-03-18 10:51:23', 'updated' => '2007-03-18 10:53:31')
), ),
'Tag' => array ( 'Tag' => array (
array ( 'id' => '1', 'tag' => 'tag1', 'created' => '2007-03-18 12:22:23', 'updated' => '2007-03-18 12:24:31'), array ( 'id' => '1', 'tag' => 'tag1', 'created' => '2007-03-18 12:22:23', 'updated' => '2007-03-18 12:24:31'),
array ( 'id' => '2', 'tag' => 'tag2', 'created' => '2007-03-18 12:24:23', 'updated' => '2007-03-18 12:26:31') array ( 'id' => '2', 'tag' => 'tag2', 'created' => '2007-03-18 12:24:23', 'updated' => '2007-03-18 12:26:31')
) )
), ),
array ( array (
'Article' => array ( 'Article' => array (
'id' => '3', 'user_id' => '1', 'title' => 'Third Article', 'body' => 'Third Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31' 'id' => '3', 'user_id' => '1', 'title' => 'Third Article', 'body' => 'Third Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31'
), ),
'User' => array ( 'User' => array (
'id' => '1', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' 'id' => '1', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31'
), ),
'Comment' => array ( ), 'Comment' => array ( ),
'Tag' => array ( ) 'Tag' => array ( )
) )
); );
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
$result = $this->model->findAll(array('Article.user_id' => 3), null, null, null, 1, 2); $result = $this->model->findAll(array('Article.user_id' => 3), null, null, null, 1, 2);
$expected = array ( $expected = array (
array ( array (
'Article' => array ( 'Article' => array (
'id' => '2', 'user_id' => '3', 'title' => 'Second Article', 'body' => 'Second Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31' 'id' => '2', 'user_id' => '3', 'title' => 'Second Article', 'body' => 'Second Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31'
), ),
'User' => array ( 'User' => array (
'id' => '3', 'user' => 'larry', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:20:23', 'updated' => '2007-03-17 01:22:31' 'id' => '3', 'user' => 'larry', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:20:23', 'updated' => '2007-03-17 01:22:31'
), ),
'Comment' => array ( 'Comment' => array (
array ( array (
'id' => '5', 'article_id' => '2', 'user_id' => '1', 'comment' => 'First Comment for Second Article', 'published' => 'Y', 'created' => '2007-03-18 10:53:23', 'updated' => '2007-03-18 10:55:31', 'id' => '5', 'article_id' => '2', 'user_id' => '1', 'comment' => 'First Comment for Second Article', 'published' => 'Y', 'created' => '2007-03-18 10:53:23', 'updated' => '2007-03-18 10:55:31',
'Article' => array ( 'Article' => array (
'id' => '2', 'user_id' => '3', 'title' => 'Second Article', 'body' => 'Second Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31' 'id' => '2', 'user_id' => '3', 'title' => 'Second Article', 'body' => 'Second Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31'
), ),
'User' => array ( 'User' => array (
'id' => '1', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' 'id' => '1', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31'
), ),
'Attachment' => array( 'Attachment' => array(
'id' => '1', 'comment_id' => 5, 'attachment' => 'attachment.zip', 'created' => '2007-03-18 10:51:23', 'updated' => '2007-03-18 10:53:31' 'id' => '1', 'comment_id' => 5, 'attachment' => 'attachment.zip', 'created' => '2007-03-18 10:51:23', 'updated' => '2007-03-18 10:53:31'
) )
), ),
array ( array (
'id' => '6', 'article_id' => '2', 'user_id' => '2', 'comment' => 'Second Comment for Second Article', 'published' => 'Y', 'created' => '2007-03-18 10:55:23', 'updated' => '2007-03-18 10:57:31', 'id' => '6', 'article_id' => '2', 'user_id' => '2', 'comment' => 'Second Comment for Second Article', 'published' => 'Y', 'created' => '2007-03-18 10:55:23', 'updated' => '2007-03-18 10:57:31',
'Article' => array ( 'Article' => array (
'id' => '2', 'user_id' => '3', 'title' => 'Second Article', 'body' => 'Second Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31' 'id' => '2', 'user_id' => '3', 'title' => 'Second Article', 'body' => 'Second Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31'
), ),
'User' => array ( 'User' => array (
'id' => '2', 'user' => 'nate', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:18:23', 'updated' => '2007-03-17 01:20:31' 'id' => '2', 'user' => 'nate', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:18:23', 'updated' => '2007-03-17 01:20:31'
), ),
'Attachment' => false 'Attachment' => false
) )
), ),
'Tag' => array ( 'Tag' => array (
array ( 'id' => '1', 'tag' => 'tag1', 'created' => '2007-03-18 12:22:23', 'updated' => '2007-03-18 12:24:31'), array ( 'id' => '1', 'tag' => 'tag1', 'created' => '2007-03-18 12:22:23', 'updated' => '2007-03-18 12:24:31'),
array ( 'id' => '3', 'tag' => 'tag3', 'created' => '2007-03-18 12:26:23', 'updated' => '2007-03-18 12:28:31') array ( 'id' => '3', 'tag' => 'tag3', 'created' => '2007-03-18 12:26:23', 'updated' => '2007-03-18 12:28:31')
) )
) )
); );
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
} }
function testSaveField() { function testSaveField() {
$this->model =& new Article(); $this->model =& new Article();
$this->model->id = 1; $this->model->id = 1;
$result = $this->model->saveField('title', 'New First Article'); $result = $this->model->saveField('title', 'New First Article');
$this->assertTrue($result); $this->assertTrue($result);
$this->model->recursive = -1; $this->model->recursive = -1;
$result = $this->model->read(array('id', 'user_id', 'title', 'body'), 1); $result = $this->model->read(array('id', 'user_id', 'title', 'body'), 1);
$expected = array('Article' => array ( $expected = array('Article' => array (
'id' => '1', 'user_id' => '1', 'title' => 'New First Article', 'body' => 'First Article Body' 'id' => '1', 'user_id' => '1', 'title' => 'New First Article', 'body' => 'First Article Body'
)); ));
$this->model->id = 1; $this->model->id = 1;
$result = $this->model->saveField('title', ''); $result = $this->model->saveField('title', '');
$this->assertTrue($result); $this->assertTrue($result);
$this->model->recursive = -1; $this->model->recursive = -1;
$result = $this->model->read(array('id', 'user_id', 'title', 'body'), 1); $result = $this->model->read(array('id', 'user_id', 'title', 'body'), 1);
$expected = array('Article' => array ( $expected = array('Article' => array (
'id' => '1', 'user_id' => '1', 'title' => '', 'body' => 'First Article Body' 'id' => '1', 'user_id' => '1', 'title' => '', 'body' => 'First Article Body'
)); ));
$this->model->id = 1; $this->model->id = 1;
$result = $this->model->saveField('title', 'First Article'); $result = $this->model->saveField('title', 'First Article');
$this->assertTrue($result); $this->assertTrue($result);
$this->model->recursive = -1; $this->model->recursive = -1;
$result = $this->model->read(array('id', 'user_id', 'title', 'body'), 1); $result = $this->model->read(array('id', 'user_id', 'title', 'body'), 1);
$expected = array('Article' => array ( $expected = array('Article' => array (
'id' => '1', 'user_id' => '1', 'title' => 'First Article', 'body' => 'First Article Body' 'id' => '1', 'user_id' => '1', 'title' => 'First Article', 'body' => 'First Article Body'
)); ));
$this->model->id = 1; $this->model->id = 1;
$result = $this->model->saveField('title', '', true); $result = $this->model->saveField('title', '', true);
$this->assertFalse($result); $this->assertFalse($result);
} }
function testSave() { function testSave() {
$this->model =& new User(); $this->model =& new User();
$data = array('User' => array('user' => 'user', 'password' => '')); $data = array('User' => array('user' => 'user', 'password' => ''));
$result = $this->model->save($data); $result = $this->model->save($data);
$this->assertFalse($result); $this->assertFalse($result);
$this->assertTrue(!empty($this->model->validationErrors)); $this->assertTrue(!empty($this->model->validationErrors));
$this->model =& new Article(); $this->model =& new Article();
$data = array('Article' => array('user_id' => '', 'title' => '', 'body' => '')); $data = array('Article' => array('user_id' => '', 'title' => '', 'body' => ''));
$result = $this->model->create($data) && $this->model->save(); $result = $this->model->create($data) && $this->model->save();
$this->assertFalse($result); $this->assertFalse($result);
$this->assertTrue(!empty($this->model->validationErrors)); $this->assertTrue(!empty($this->model->validationErrors));
$data = array('Article' => array('id' => 1, 'user_id' => '1', 'title' => 'New First Article', 'body' => '')); $data = array('Article' => array('id' => 1, 'user_id' => '1', 'title' => 'New First Article', 'body' => ''));
$result = $this->model->create($data) && $this->model->save(); $result = $this->model->create($data) && $this->model->save();
$this->assertFalse($result); $this->assertFalse($result);
$data = array('Article' => array('id' => 1, 'title' => 'New First Article')); $data = array('Article' => array('id' => 1, 'title' => 'New First Article'));
$result = $this->model->create() && $this->model->save($data, false); $result = $this->model->create() && $this->model->save($data, false);
$this->assertTrue($result); $this->assertTrue($result);
$this->model->recursive = -1; $this->model->recursive = -1;
$result = $this->model->read(array('id', 'user_id', 'title', 'body', 'published'), 1); $result = $this->model->read(array('id', 'user_id', 'title', 'body', 'published'), 1);
$expected = array('Article' => array ( $expected = array('Article' => array (
'id' => '1', 'user_id' => '1', 'title' => 'New First Article', 'body' => 'First Article Body', 'published' => 'N' 'id' => '1', 'user_id' => '1', 'title' => 'New First Article', 'body' => 'First Article Body', 'published' => 'N'
)); ));
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
$data = array('Article' => array('id' => 1, 'user_id' => '2', 'title' => 'First Article', 'body' => 'New First Article Body', 'published' => 'Y')); $data = array('Article' => array('id' => 1, 'user_id' => '2', 'title' => 'First Article', 'body' => 'New First Article Body', 'published' => 'Y'));
$result = $this->model->create() && $this->model->save($data, true, array('title', 'published')); $result = $this->model->create() && $this->model->save($data, true, array('title', 'published'));
$this->assertTrue($result); $this->assertTrue($result);
$this->model->recursive = -1; $this->model->recursive = -1;
$result = $this->model->read(array('id', 'user_id', 'title', 'body', 'published'), 1); $result = $this->model->read(array('id', 'user_id', 'title', 'body', 'published'), 1);
$expected = array('Article' => array ( $expected = array('Article' => array (
'id' => '1', 'user_id' => '1', 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y' 'id' => '1', 'user_id' => '1', 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y'
)); ));
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
$data = array( $data = array(
'Article' => array( 'Article' => array(
'user_id' => '2', 'title' => 'New Article', 'body' => 'New Article Body', 'created' => '2007-03-18 14:55:23', 'updated' => '2007-03-18 14:57:31' 'user_id' => '2', 'title' => 'New Article', 'body' => 'New Article Body', 'created' => '2007-03-18 14:55:23', 'updated' => '2007-03-18 14:57:31'
@ -727,172 +733,172 @@ class ModelTest extends CakeTestCase {
); );
$result = $this->model->create() && $this->model->save($data); $result = $this->model->create() && $this->model->save($data);
$this->assertTrue($result); $this->assertTrue($result);
$this->model->recursive = 2; $this->model->recursive = 2;
$result = $this->model->read(null, 4); $result = $this->model->read(null, 4);
$expected = array ( $expected = array (
'Article' => array ( 'Article' => array (
'id' => '4', 'user_id' => '2', 'title' => 'New Article', 'body' => 'New Article Body', 'published' => 'N', 'created' => '2007-03-18 14:55:23', 'updated' => '2007-03-18 14:57:31' 'id' => '4', 'user_id' => '2', 'title' => 'New Article', 'body' => 'New Article Body', 'published' => 'N', 'created' => '2007-03-18 14:55:23', 'updated' => '2007-03-18 14:57:31'
), ),
'User' => array( 'User' => array(
'id' => '2', 'user' => 'nate', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:18:23', 'updated' => '2007-03-17 01:20:31' 'id' => '2', 'user' => 'nate', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:18:23', 'updated' => '2007-03-17 01:20:31'
), ),
'Comment' => array ( ), 'Comment' => array ( ),
'Tag' => array ( 'Tag' => array (
array ( 'id' => '1', 'tag' => 'tag1', 'created' => '2007-03-18 12:22:23', 'updated' => '2007-03-18 12:24:31'), array ( 'id' => '1', 'tag' => 'tag1', 'created' => '2007-03-18 12:22:23', 'updated' => '2007-03-18 12:24:31'),
array ( 'id' => '3', 'tag' => 'tag3', 'created' => '2007-03-18 12:26:23', 'updated' => '2007-03-18 12:28:31') array ( 'id' => '3', 'tag' => 'tag3', 'created' => '2007-03-18 12:26:23', 'updated' => '2007-03-18 12:28:31')
) )
); );
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
$data = array('Comment' => array( $data = array('Comment' => array(
'article_id' => '4', 'user_id' => '1', 'comment' => 'Comment New Article', 'published' => 'Y', 'created' => '2007-03-18 14:57:23', 'updated' => '2007-03-18 14:59:31' 'article_id' => '4', 'user_id' => '1', 'comment' => 'Comment New Article', 'published' => 'Y', 'created' => '2007-03-18 14:57:23', 'updated' => '2007-03-18 14:59:31'
)); ));
$result = $this->model->Comment->create() && $this->model->Comment->save($data); $result = $this->model->Comment->create() && $this->model->Comment->save($data);
$this->assertTrue($result); $this->assertTrue($result);
$data = array('Attachment' => array( $data = array('Attachment' => array(
'comment_id' => '7', 'attachment' => 'newattachment.zip', 'created' => '2007-03-18 15:02:23', 'updated' => '2007-03-18 15:04:31' 'comment_id' => '7', 'attachment' => 'newattachment.zip', 'created' => '2007-03-18 15:02:23', 'updated' => '2007-03-18 15:04:31'
)); ));
$result = $this->model->Comment->Attachment->save($data); $result = $this->model->Comment->Attachment->save($data);
$this->assertTrue($result); $this->assertTrue($result);
$this->model->recursive = 2; $this->model->recursive = 2;
$result = $this->model->read(null, 4); $result = $this->model->read(null, 4);
$expected = array ( $expected = array (
'Article' => array ( 'Article' => array (
'id' => '4', 'user_id' => '2', 'title' => 'New Article', 'body' => 'New Article Body', 'published' => 'N', 'created' => '2007-03-18 14:55:23', 'updated' => '2007-03-18 14:57:31' 'id' => '4', 'user_id' => '2', 'title' => 'New Article', 'body' => 'New Article Body', 'published' => 'N', 'created' => '2007-03-18 14:55:23', 'updated' => '2007-03-18 14:57:31'
), ),
'User' => array( 'User' => array(
'id' => '2', 'user' => 'nate', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:18:23', 'updated' => '2007-03-17 01:20:31' 'id' => '2', 'user' => 'nate', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:18:23', 'updated' => '2007-03-17 01:20:31'
), ),
'Comment' => array ( 'Comment' => array (
array ( array (
'id' => '7', 'article_id' => '4', 'user_id' => '1', 'comment' => 'Comment New Article', 'published' => 'Y', 'created' => '2007-03-18 14:57:23', 'updated' => '2007-03-18 14:59:31', 'id' => '7', 'article_id' => '4', 'user_id' => '1', 'comment' => 'Comment New Article', 'published' => 'Y', 'created' => '2007-03-18 14:57:23', 'updated' => '2007-03-18 14:59:31',
'Article' => array ( 'Article' => array (
'id' => '4', 'user_id' => '2', 'title' => 'New Article', 'body' => 'New Article Body', 'published' => 'N', 'created' => '2007-03-18 14:55:23', 'updated' => '2007-03-18 14:57:31' 'id' => '4', 'user_id' => '2', 'title' => 'New Article', 'body' => 'New Article Body', 'published' => 'N', 'created' => '2007-03-18 14:55:23', 'updated' => '2007-03-18 14:57:31'
), ),
'User' => array ( 'User' => array (
'id' => '1', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' 'id' => '1', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31'
), ),
'Attachment' => array( 'Attachment' => array(
'id' => '2', 'comment_id' => '7', 'attachment' => 'newattachment.zip', 'created' => '2007-03-18 15:02:23', 'updated' => '2007-03-18 15:04:31' 'id' => '2', 'comment_id' => '7', 'attachment' => 'newattachment.zip', 'created' => '2007-03-18 15:02:23', 'updated' => '2007-03-18 15:04:31'
) )
) )
), ),
'Tag' => array ( 'Tag' => array (
array ( 'id' => '1', 'tag' => 'tag1', 'created' => '2007-03-18 12:22:23', 'updated' => '2007-03-18 12:24:31'), array ( 'id' => '1', 'tag' => 'tag1', 'created' => '2007-03-18 12:22:23', 'updated' => '2007-03-18 12:24:31'),
array ( 'id' => '3', 'tag' => 'tag3', 'created' => '2007-03-18 12:26:23', 'updated' => '2007-03-18 12:28:31') array ( 'id' => '3', 'tag' => 'tag3', 'created' => '2007-03-18 12:26:23', 'updated' => '2007-03-18 12:28:31')
) )
); );
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
} }
function testRecursiveDel() { function testRecursiveDel() {
$this->model =& new Article(); $this->model =& new Article();
$result = $this->model->del(2); $result = $this->model->del(2);
$this->assertTrue($result); $this->assertTrue($result);
$this->model->recursive = 2; $this->model->recursive = 2;
$result = $this->model->read(null, 2); $result = $this->model->read(null, 2);
$this->assertFalse($result); $this->assertFalse($result);
$result = $this->model->Comment->read(null, 5); $result = $this->model->Comment->read(null, 5);
$this->assertFalse($result); $this->assertFalse($result);
$result = $this->model->Comment->read(null, 6); $result = $this->model->Comment->read(null, 6);
$this->assertFalse($result); $this->assertFalse($result);
$result = $this->model->Comment->Attachment->read(null, 1); $result = $this->model->Comment->Attachment->read(null, 1);
$this->assertFalse($result); $this->assertFalse($result);
$result = $this->model->findCount(); $result = $this->model->findCount();
$this->assertEqual($result, 2); $this->assertEqual($result, 2);
$result = $this->model->Comment->findCount(); $result = $this->model->Comment->findCount();
$this->assertEqual($result, 4); $this->assertEqual($result, 4);
$result = $this->model->Comment->Attachment->findCount(); $result = $this->model->Comment->Attachment->findCount();
$this->assertEqual($result, 0); $this->assertEqual($result, 0);
} }
function testFindAllThreaded() { function testFindAllThreaded() {
$this->model =& new Category(); $this->model =& new Category();
$result = $this->model->findAllThreaded(); $result = $this->model->findAllThreaded();
$expected = array ( $expected = array (
array ( array (
'Category' => array ( 'id' => '1', 'parent_id' => '0', 'name' => 'Category 1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31'), 'Category' => array ( 'id' => '1', 'parent_id' => '0', 'name' => 'Category 1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31'),
'children' => array ( 'children' => array (
array ( array (
'Category' => array ( 'id' => '2', 'parent_id' => '1', 'name' => 'Category 1.1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31'), 'Category' => array ( 'id' => '2', 'parent_id' => '1', 'name' => 'Category 1.1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31'),
'children' => array ( ) 'children' => array ( )
), ),
array ( array (
'Category' => array ( 'id' => '3', 'parent_id' => '1', 'name' => 'Category 1.2', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31'), 'Category' => array ( 'id' => '3', 'parent_id' => '1', 'name' => 'Category 1.2', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31'),
'children' => array ( ) 'children' => array ( )
) )
) )
), ),
array ( array (
'Category' => array ( 'id' => '4', 'parent_id' => '0', 'name' => 'Category 2', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31'), 'Category' => array ( 'id' => '4', 'parent_id' => '0', 'name' => 'Category 2', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31'),
'children' => array ( ) 'children' => array ( )
), ),
array ( array (
'Category' => array ( 'id' => '5', 'parent_id' => '0', 'name' => 'Category 3', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31'), 'Category' => array ( 'id' => '5', 'parent_id' => '0', 'name' => 'Category 3', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31'),
'children' => array ( 'children' => array (
array ( array (
'Category' => array ( 'id' => '6', 'parent_id' => '5', 'name' => 'Category 3.1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31'), 'Category' => array ( 'id' => '6', 'parent_id' => '5', 'name' => 'Category 3.1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31'),
'children' => array ( ) 'children' => array ( )
) )
) )
) )
); );
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
$result = $this->model->findAllThreaded(array('Category.name' => 'LIKE Category 1%')); $result = $this->model->findAllThreaded(array('Category.name' => 'LIKE Category 1%'));
$expected = array ( $expected = array (
array ( array (
'Category' => array ( 'id' => '1', 'parent_id' => '0', 'name' => 'Category 1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31'), 'Category' => array ( 'id' => '1', 'parent_id' => '0', 'name' => 'Category 1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31'),
'children' => array ( 'children' => array (
array ( array (
'Category' => array ( 'id' => '2', 'parent_id' => '1', 'name' => 'Category 1.1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31'), 'Category' => array ( 'id' => '2', 'parent_id' => '1', 'name' => 'Category 1.1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31'),
'children' => array ( ) 'children' => array ( )
), ),
array ( array (
'Category' => array ( 'id' => '3', 'parent_id' => '1', 'name' => 'Category 1.2', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31'), 'Category' => array ( 'id' => '3', 'parent_id' => '1', 'name' => 'Category 1.2', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31'),
'children' => array ( ) 'children' => array ( )
) )
) )
) )
); );
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
$result = $this->model->findAllThreaded(null, 'id, parent_id, name'); $result = $this->model->findAllThreaded(null, 'id, parent_id, name');
$expected = array ( $expected = array (
array ( array (
'Category' => array ( 'id' => '1', 'parent_id' => '0', 'name' => 'Category 1'), 'Category' => array ( 'id' => '1', 'parent_id' => '0', 'name' => 'Category 1'),
'children' => array ( 'children' => array (
array ( array (
'Category' => array ( 'id' => '2', 'parent_id' => '1', 'name' => 'Category 1.1'), 'Category' => array ( 'id' => '2', 'parent_id' => '1', 'name' => 'Category 1.1'),
'children' => array ( ) 'children' => array ( )
), ),
array ( array (
'Category' => array ( 'id' => '3', 'parent_id' => '1', 'name' => 'Category 1.2'), 'Category' => array ( 'id' => '3', 'parent_id' => '1', 'name' => 'Category 1.2'),
'children' => array ( ) 'children' => array ( )
) )
) )
), ),
array ( array (
'Category' => array ( 'id' => '4', 'parent_id' => '0', 'name' => 'Category 2'), 'Category' => array ( 'id' => '4', 'parent_id' => '0', 'name' => 'Category 2'),
'children' => array ( ) 'children' => array ( )
), ),
array ( array (
'Category' => array ( 'id' => '5', 'parent_id' => '0', 'name' => 'Category 3'), 'Category' => array ( 'id' => '5', 'parent_id' => '0', 'name' => 'Category 3'),
'children' => array ( 'children' => array (
array ( array (
'Category' => array ( 'id' => '6', 'parent_id' => '5', 'name' => 'Category 3.1'), 'Category' => array ( 'id' => '6', 'parent_id' => '5', 'name' => 'Category 3.1'),
'children' => array ( ) 'children' => array ( )
) )
) )
@ -900,10 +906,10 @@ class ModelTest extends CakeTestCase {
); );
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
} }
function testFindNeighbours() { function testFindNeighbours() {
$this->model =& new Article(); $this->model =& new Article();
$result = $this->model->findNeighbours(null, 'Article.id', '2'); $result = $this->model->findNeighbours(null, 'Article.id', '2');
$expected = array( $expected = array(
'prev' => array( 'prev' => array(
@ -914,7 +920,7 @@ class ModelTest extends CakeTestCase {
) )
); );
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
$result = $this->model->findNeighbours(null, 'Article.id', '3'); $result = $this->model->findNeighbours(null, 'Article.id', '3');
$expected = array( $expected = array(
'prev' => array( 'prev' => array(

View file

@ -45,9 +45,9 @@ class CategoryThreadFixture extends CakeTestFixture {
array('id' => 1, 'parent_id' => 0, 'name' => 'Category 1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31'), array('id' => 1, 'parent_id' => 0, 'name' => 'Category 1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31'),
array('id' => 2, 'parent_id' => 1, 'name' => 'Category 1.1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31'), array('id' => 2, 'parent_id' => 1, 'name' => 'Category 1.1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31'),
array('id' => 3, 'parent_id' => 2, 'name' => 'Category 1.1.1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31'), array('id' => 3, 'parent_id' => 2, 'name' => 'Category 1.1.1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31'),
array('id' => 4, 'parent_id' => 2, 'name' => 'Category 1.1.2', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31'), array('id' => 4, 'parent_id' => 3, 'name' => 'Category 1.1.2', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31'),
array('id' => 5, 'parent_id' => 3, 'name' => 'Category 1.1.1.1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31'), array('id' => 5, 'parent_id' => 4, 'name' => 'Category 1.1.1.1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31'),
array('id' => 6, 'parent_id' => 0, 'name' => 'Category 2', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31'), array('id' => 6, 'parent_id' => 5, 'name' => 'Category 2', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31'),
array('id' => 7, 'parent_id' => 6, 'name' => 'Category 2.1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31') array('id' => 7, 'parent_id' => 6, 'name' => 'Category 2.1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31')
); );
} }