Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

7577 lines (7242 sloc) 198.628 kb
<?php
/**
* ModelReadTest file
*
* PHP 5
*
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
* Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice
*
* @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
* @package cake.tests.cases.libs.model
* @since CakePHP(tm) v 1.2.0.4206
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
require_once dirname(__FILE__) . DS . 'ModelTestBase.php';
/**
* ModelReadTest
*
* @package cake.tests.cases.libs.model.operations
*/
class ModelReadTest extends BaseModelTest {
/**
* testFetchingNonUniqueFKJoinTableRecords()
*
* Tests if the results are properly returned in the case there are non-unique FK's
* in the join table but another fields value is different. For example:
* something_id | something_else_id | doomed = 1
* something_id | something_else_id | doomed = 0
* Should return both records and not just one.
*
* @access public
* @return void
*/
function testFetchingNonUniqueFKJoinTableRecords() {
$this->loadFixtures('Something', 'SomethingElse', 'JoinThing');
$Something = new Something();
$joinThingData = array(
'JoinThing' => array(
'something_id' => 1,
'something_else_id' => 2,
'doomed' => '0',
'created' => '2007-03-18 10:39:23',
'updated' => '2007-03-18 10:41:31'
)
);
$Something->JoinThing->create($joinThingData);
$Something->JoinThing->save();
$result = $Something->JoinThing->find('all', array('conditions' => array('something_else_id' => 2)));
$this->assertEqual($result[0]['JoinThing']['doomed'], true);
$this->assertEqual($result[1]['JoinThing']['doomed'], false);
$result = $Something->find('first');
$this->assertEqual(count($result['SomethingElse']), 2);
$doomed = Set::extract('/JoinThing/doomed', $result['SomethingElse']);
$this->assertTrue(in_array(true, $doomed));
$this->assertTrue(in_array(false, $doomed));
}
/**
* testGroupBy method
*
* These tests will never pass with Postgres or Oracle as all fields in a select must be
* part of an aggregate function or in the GROUP BY statement.
*
* @access public
* @return void
*/
function testGroupBy() {
$db = ConnectionManager::getDataSource('test');
$isStrictGroupBy = $this->db instanceof Postgres || $this->db instanceof Sqlite || $this->db instanceof Oracle;
$message = 'Postgres and Oracle have strict GROUP BY and are incompatible with this test.';
if ($this->skipIf($isStrictGroupBy, $message )) {
return;
}
$this->loadFixtures('Project', 'Product', 'Thread', 'Message', 'Bid');
$Thread = new Thread();
$Product = new Product();
$result = $Thread->find('all', array(
'group' => 'Thread.project_id',
'order' => 'Thread.id ASC'
));
$expected = array(
array(
'Thread' => array(
'id' => 1,
'project_id' => 1,
'name' => 'Project 1, Thread 1'
),
'Project' => array(
'id' => 1,
'name' => 'Project 1'
),
'Message' => array(
array(
'id' => 1,
'thread_id' => 1,
'name' => 'Thread 1, Message 1'
))),
array(
'Thread' => array(
'id' => 3,
'project_id' => 2,
'name' => 'Project 2, Thread 1'
),
'Project' => array(
'id' => 2,
'name' => 'Project 2'
),
'Message' => array(
array(
'id' => 3,
'thread_id' => 3,
'name' => 'Thread 3, Message 1'
))));
$this->assertEqual($expected, $result);
$rows = $Thread->find('all', array(
'group' => 'Thread.project_id',
'fields' => array('Thread.project_id', 'COUNT(*) AS total')
));
$result = array();
foreach($rows as $row) {
$result[$row['Thread']['project_id']] = $row[0]['total'];
}
$expected = array(
1 => 2,
2 => 1
);
$this->assertEqual($expected, $result);
$rows = $Thread->find('all', array(
'group' => 'Thread.project_id',
'fields' => array('Thread.project_id', 'COUNT(*) AS total'),
'order'=> 'Thread.project_id'
));
$result = array();
foreach($rows as $row) {
$result[$row['Thread']['project_id']] = $row[0]['total'];
}
$expected = array(
1 => 2,
2 => 1
);
$this->assertEqual($expected, $result);
$result = $Thread->find('all', array(
'conditions' => array('Thread.project_id' => 1),
'group' => 'Thread.project_id'
));
$expected = array(
array(
'Thread' => array(
'id' => 1,
'project_id' => 1,
'name' => 'Project 1, Thread 1'
),
'Project' => array(
'id' => 1,
'name' => 'Project 1'
),
'Message' => array(
array(
'id' => 1,
'thread_id' => 1,
'name' => 'Thread 1, Message 1'
))));
$this->assertEqual($expected, $result);
$result = $Thread->find('all', array(
'conditions' => array('Thread.project_id' => 1),
'group' => 'Thread.project_id, Project.id'
));
$this->assertEqual($expected, $result);
$result = $Thread->find('all', array(
'conditions' => array('Thread.project_id' => 1),
'group' => 'project_id'
));
$this->assertEqual($expected, $result);
$result = $Thread->find('all', array(
'conditions' => array('Thread.project_id' => 1),
'group' => array('project_id')
));
$this->assertEqual($expected, $result);
$result = $Thread->find('all', array(
'conditions' => array('Thread.project_id' => 1),
'group' => array('project_id', 'Project.id')
));
$this->assertEqual($expected, $result);
$result = $Thread->find('all', array(
'conditions' => array('Thread.project_id' => 1),
'group' => array('Thread.project_id', 'Project.id')
));
$this->assertEqual($expected, $result);
$expected = array(
array('Product' => array('type' => 'Clothing'), array('price' => 32)),
array('Product' => array('type' => 'Food'), array('price' => 9)),
array('Product' => array('type' => 'Music'), array( 'price' => 4)),
array('Product' => array('type' => 'Toy'), array('price' => 3))
);
$result = $Product->find('all',array(
'fields'=>array('Product.type', 'MIN(Product.price) as price'),
'group'=> 'Product.type',
'order' => 'Product.type ASC'
));
$this->assertEqual($expected, $result);
$result = $Product->find('all', array(
'fields'=>array('Product.type', 'MIN(Product.price) as price'),
'group'=> array('Product.type'),
'order' => 'Product.type ASC'));
$this->assertEqual($expected, $result);
}
/**
* testOldQuery method
*
* @access public
* @return void
*/
function testOldQuery() {
$this->loadFixtures('Article', 'User', 'Tag', 'ArticlesTag', 'Comment', 'Attachment');
$Article = new Article();
$query = 'SELECT title FROM ';
$query .= $this->db->fullTableName('articles');
$query .= ' WHERE ' . $this->db->fullTableName('articles') . '.id IN (1,2)';
$results = $Article->query($query);
$this->assertTrue(is_array($results));
$this->assertEqual(count($results), 2);
$query = 'SELECT title, body FROM ';
$query .= $this->db->fullTableName('articles');
$query .= ' WHERE ' . $this->db->fullTableName('articles') . '.id = 1';
$results = $Article->query($query, false);
$this->assertFalse($this->db->getQueryCache($query));
$this->assertTrue(is_array($results));
$query = 'SELECT title, id FROM ';
$query .= $this->db->fullTableName('articles');
$query .= ' WHERE ' . $this->db->fullTableName('articles');
$query .= '.published = ' . $this->db->value('Y');
$results = $Article->query($query, true);
$result = $this->db->getQueryCache($query);
$this->assertFalse(empty($result));
$this->assertTrue(is_array($results));
}
/**
* testPreparedQuery method
*
* @access public
* @return void
*/
function testPreparedQuery() {
$this->loadFixtures('Article', 'User', 'Tag', 'ArticlesTag');
$Article = new Article();
$query = 'SELECT title, published FROM ';
$query .= $this->db->fullTableName('articles');
$query .= ' WHERE ' . $this->db->fullTableName('articles');
$query .= '.id = ? AND ' . $this->db->fullTableName('articles') . '.published = ?';
$params = array(1, 'Y');
$result = $Article->query($query, $params);
$expected = array(
'0' => array(
$this->db->fullTableName('articles', false) => array(
'title' => 'First Article', 'published' => 'Y')
));
if (isset($result[0][0])) {
$expected[0][0] = $expected[0][$this->db->fullTableName('articles', false)];
unset($expected[0][$this->db->fullTableName('articles', false)]);
}
$this->assertEqual($expected, $result);
$result = $this->db->getQueryCache($query, $params);
$this->assertFalse(empty($result));
$query = 'SELECT id, created FROM ';
$query .= $this->db->fullTableName('articles');
$query .= ' WHERE ' . $this->db->fullTableName('articles') . '.title = ?';
$params = array('First Article');
$result = $Article->query($query, $params, false);
$this->assertTrue(is_array($result));
$this->assertTrue(
isset($result[0][$this->db->fullTableName('articles', false)])
|| isset($result[0][0])
);
$result = $this->db->getQueryCache($query, $params);
$this->assertTrue(empty($result));
$query = 'SELECT title FROM ';
$query .= $this->db->fullTableName('articles');
$query .= ' WHERE ' . $this->db->fullTableName('articles') . '.title LIKE ?';
$params = array('%First%');
$result = $Article->query($query, $params);
$this->assertTrue(is_array($result));
$this->assertTrue(
isset($result[0][$this->db->fullTableName('articles', false)]['title'])
|| isset($result[0][0]['title'])
);
//related to ticket #5035
$query = 'SELECT title FROM ';
$query .= $this->db->fullTableName('articles') . ' WHERE title = ? AND published = ?';
$params = array('First? Article', 'Y');
$Article->query($query, $params);
$result = $this->db->getQueryCache($query, $params);
$this->assertFalse($result === false);
}
/**
* testParameterMismatch method
*
* @access public
* @return void
*/
function testParameterMismatch() {
$this->loadFixtures('Article', 'User', 'Tag', 'ArticlesTag');
$Article = new Article();
$query = 'SELECT * FROM ' . $this->db->fullTableName('articles');
$query .= ' WHERE ' . $this->db->fullTableName('articles');
$query .= '.published = ? AND ' . $this->db->fullTableName('articles') . '.user_id = ?';
$params = array('Y');
$this->expectError();
ob_start();
$result = $Article->query($query, $params);
ob_end_clean();
$this->assertEqual($result, null);
}
/**
* testVeryStrangeUseCase method
*
* @access public
* @return void
*/
function testVeryStrangeUseCase() {
$message = "skipping SELECT * FROM ? WHERE ? = ? AND ? = ?; prepared query.";
$message .= " MSSQL is incompatible with this test.";
if ($this->skipIf($this->db instanceof Mssql, $message)) {
return;
}
$this->loadFixtures('Article', 'User', 'Tag', 'ArticlesTag');
$Article = new Article();
$query = 'SELECT * FROM ? WHERE ? = ? AND ? = ?';
$param = array(
$this->db->fullTableName('articles'),
$this->db->fullTableName('articles') . '.user_id', '3',
$this->db->fullTableName('articles') . '.published', 'Y'
);
$this->expectError();
ob_start();
$result = $Article->query($query, $param);
ob_end_clean();
}
/**
* testRecursiveUnbind method
*
* @access public
* @return void
*/
function testRecursiveUnbind() {
if ($this->skipIf($this->db instanceof Mssql, 'The test of testRecursiveUnbind test is not compatible with Mssql, because it check for time columns.')) {
return;
}
$this->loadFixtures('Apple', 'Sample');
$TestModel = new Apple();
$TestModel->recursive = 2;
$result = $TestModel->find('all');
$expected = array(
array(
'Apple' => array (
'id' => 1,
'apple_id' => 2,
'color' => 'Red 1',
'name' => 'Red Apple 1',
'created' => '2006-11-22 10:38:58',
'date' => '1951-01-04',
'modified' => '2006-12-01 13:31:26',
'mytime' => '22:57:17'
),
'Parent' => array(
'id' => 2,
'apple_id' => 1,
'color' => 'Bright Red 1',
'name' => 'Bright Red Apple',
'created' => '2006-11-22 10:43:13',
'date' => '2014-01-01',
'modified' => '2006-11-30 18:38:10',
'mytime' => '22:57:17',
'Parent' => array(
'id' => 1,
'apple_id' => 2,
'color' => 'Red 1',
'name' => 'Red Apple 1',
'created' => '2006-11-22 10:38:58',
'date' => '1951-01-04',
'modified' => '2006-12-01 13:31:26',
'mytime' => '22:57:17'
),
'Sample' => array(
'id' => 2,
'apple_id' => 2,
'name' => 'sample2'
),
'Child' => array(
array(
'id' => 1,
'apple_id' => 2,
'color' => 'Red 1',
'name' => 'Red Apple 1',
'created' => '2006-11-22 10:38:58',
'date' => '1951-01-04',
'modified' => '2006-12-01 13:31:26',
'mytime' => '22:57:17'
),
array(
'id' => 3,
'apple_id' => 2,
'color' => 'blue green',
'name' => 'green blue',
'created' => '2006-12-25 05:13:36',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:23:24',
'mytime' => '22:57:17'
),
array(
'id' => 4,
'apple_id' => 2,
'color' => 'Blue Green',
'name' => 'Test Name',
'created' => '2006-12-25 05:23:36',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:23:36',
'mytime' => '22:57:17'
))),
'Sample' => array(
'id' =>'',
'apple_id' => '',
'name' => ''
),
'Child' => array(
array(
'id' => 2,
'apple_id' => 1,
'color' => 'Bright Red 1',
'name' => 'Bright Red Apple',
'created' => '2006-11-22 10:43:13',
'date' => '2014-01-01',
'modified' => '2006-11-30 18:38:10',
'mytime' => '22:57:17',
'Parent' => array(
'id' => 1,
'apple_id' => 2,
'color' => 'Red 1',
'name' => 'Red Apple 1',
'created' => '2006-11-22 10:38:58',
'date' => '1951-01-04',
'modified' => '2006-12-01 13:31:26',
'mytime' => '22:57:17'
),
'Sample' => array(
'id' => 2,
'apple_id' => 2,
'name' => 'sample2'
),
'Child' => array(
array(
'id' => 1,
'apple_id' => 2,
'color' => 'Red 1',
'name' => 'Red Apple 1',
'created' => '2006-11-22 10:38:58',
'date' => '1951-01-04',
'modified' => '2006-12-01 13:31:26',
'mytime' => '22:57:17'
),
array(
'id' => 3,
'apple_id' => 2,
'color' => 'blue green',
'name' => 'green blue',
'created' => '2006-12-25 05:13:36',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:23:24',
'mytime' => '22:57:17'
),
array(
'id' => 4,
'apple_id' => 2,
'color' => 'Blue Green',
'name' => 'Test Name',
'created' => '2006-12-25 05:23:36',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:23:36',
'mytime' => '22:57:17'
))))),
array(
'Apple' => array(
'id' => 2,
'apple_id' => 1,
'color' => 'Bright Red 1',
'name' => 'Bright Red Apple',
'created' => '2006-11-22 10:43:13',
'date' => '2014-01-01',
'modified' => '2006-11-30 18:38:10',
'mytime' => '22:57:17'
),
'Parent' => array(
'id' => 1,
'apple_id' => 2,
'color' => 'Red 1',
'name' => 'Red Apple 1',
'created' => '2006-11-22 10:38:58',
'date' => '1951-01-04',
'modified' => '2006-12-01 13:31:26',
'mytime' => '22:57:17',
'Parent' => array(
'id' => 2,
'apple_id' => 1,
'color' => 'Bright Red 1',
'name' => 'Bright Red Apple',
'created' => '2006-11-22 10:43:13',
'date' => '2014-01-01',
'modified' => '2006-11-30 18:38:10',
'mytime' => '22:57:17'
),
'Sample' => array(),
'Child' => array(
array(
'id' => 2,
'apple_id' => 1,
'color' => 'Bright Red 1',
'name' => 'Bright Red Apple',
'created' => '2006-11-22 10:43:13',
'date' => '2014-01-01',
'modified' => '2006-11-30 18:38:10',
'mytime' => '22:57:17'
))),
'Sample' => array(
'id' => 2,
'apple_id' => 2,
'name' => 'sample2',
'Apple' => array(
'id' => 2,
'apple_id' => 1,
'color' => 'Bright Red 1',
'name' => 'Bright Red Apple',
'created' => '2006-11-22 10:43:13',
'date' => '2014-01-01',
'modified' => '2006-11-30 18:38:10',
'mytime' => '22:57:17'
)),
'Child' => array(
array(
'id' => 1,
'apple_id' => 2,
'color' => 'Red 1',
'name' => 'Red Apple 1',
'created' => '2006-11-22 10:38:58',
'date' => '1951-01-04',
'modified' => '2006-12-01 13:31:26',
'mytime' => '22:57:17',
'Parent' => array(
'id' => 2,
'apple_id' => 1,
'color' => 'Bright Red 1',
'name' => 'Bright Red Apple',
'created' => '2006-11-22 10:43:13',
'date' => '2014-01-01',
'modified' => '2006-11-30 18:38:10',
'mytime' => '22:57:17'
),
'Sample' => array(),
'Child' => array(
array(
'id' => 2,
'apple_id' => 1,
'color' => 'Bright Red 1',
'name' => 'Bright Red Apple',
'created' => '2006-11-22 10:43:13',
'date' => '2014-01-01',
'modified' => '2006-11-30 18:38:10',
'mytime' => '22:57:17'
))),
array(
'id' => 3,
'apple_id' => 2,
'color' => 'blue green',
'name' => 'green blue',
'created' => '2006-12-25 05:13:36',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:23:24',
'mytime' => '22:57:17',
'Parent' => array(
'id' => 2,
'apple_id' => 1,
'color' => 'Bright Red 1',
'name' => 'Bright Red Apple',
'created' => '2006-11-22 10:43:13',
'date' => '2014-01-01',
'modified' => '2006-11-30 18:38:10',
'mytime' => '22:57:17'
),
'Sample' => array(
'id' => 1,
'apple_id' => 3,
'name' => 'sample1'
)),
array(
'id' => 4,
'apple_id' => 2,
'color' => 'Blue Green',
'name' => 'Test Name',
'created' => '2006-12-25 05:23:36',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:23:36',
'mytime' => '22:57:17',
'Parent' => array(
'id' => 2,
'apple_id' => 1,
'color' => 'Bright Red 1',
'name' => 'Bright Red Apple',
'created' => '2006-11-22 10:43:13',
'date' => '2014-01-01',
'modified' => '2006-11-30 18:38:10',
'mytime' => '22:57:17'
),
'Sample' => array(
'id' => 3,
'apple_id' => 4,
'name' => 'sample3'
),
'Child' => array(
array(
'id' => 6,
'apple_id' => 4,
'color' => 'My new appleOrange',
'name' => 'My new apple',
'created' => '2006-12-25 05:29:39',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:29:39',
'mytime' => '22:57:17'
))))),
array(
'Apple' => array(
'id' => 3,
'apple_id' => 2,
'color' => 'blue green',
'name' => 'green blue',
'created' => '2006-12-25 05:13:36',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:23:24',
'mytime' => '22:57:17'
),
'Parent' => array(
'id' => 2,
'apple_id' => 1,
'color' => 'Bright Red 1',
'name' => 'Bright Red Apple',
'created' => '2006-11-22 10:43:13',
'date' => '2014-01-01',
'modified' => '2006-11-30 18:38:10',
'mytime' => '22:57:17',
'Parent' => array(
'id' => 1,
'apple_id' => 2,
'color' => 'Red 1',
'name' => 'Red Apple 1',
'created' => '2006-11-22 10:38:58',
'date' => '1951-01-04',
'modified' => '2006-12-01 13:31:26',
'mytime' => '22:57:17'
),
'Sample' => array(
'id' => 2,
'apple_id' => 2,
'name' => 'sample2'
),
'Child' => array(
array(
'id' => 1,
'apple_id' => 2,
'color' => 'Red 1',
'name' => 'Red Apple 1',
'created' => '2006-11-22 10:38:58',
'date' => '1951-01-04',
'modified' => '2006-12-01 13:31:26',
'mytime' => '22:57:17'
),
array(
'id' => 3,
'apple_id' => 2,
'color' => 'blue green',
'name' => 'green blue',
'created' => '2006-12-25 05:13:36',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:23:24',
'mytime' => '22:57:17'
),
array(
'id' => 4,
'apple_id' => 2,
'color' => 'Blue Green',
'name' => 'Test Name',
'created' => '2006-12-25 05:23:36',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:23:36',
'mytime' => '22:57:17'
))),
'Sample' => array(
'id' => 1,
'apple_id' => 3,
'name' => 'sample1',
'Apple' => array(
'id' => 3,
'apple_id' => 2,
'color' => 'blue green',
'name' => 'green blue',
'created' => '2006-12-25 05:13:36',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:23:24',
'mytime' => '22:57:17'
)),
'Child' => array()
),
array(
'Apple' => array(
'id' => 4,
'apple_id' => 2,
'color' => 'Blue Green',
'name' => 'Test Name',
'created' => '2006-12-25 05:23:36',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:23:36',
'mytime' => '22:57:17'
),
'Parent' => array(
'id' => 2,
'apple_id' => 1,
'color' => 'Bright Red 1',
'name' => 'Bright Red Apple',
'created' => '2006-11-22 10:43:13',
'date' => '2014-01-01',
'modified' => '2006-11-30 18:38:10',
'mytime' => '22:57:17',
'Parent' => array(
'id' => 1,
'apple_id' => 2,
'color' => 'Red 1',
'name' => 'Red Apple 1',
'created' => '2006-11-22 10:38:58',
'date' => '1951-01-04',
'modified' => '2006-12-01 13:31:26', 'mytime' => '22:57:17'),
'Sample' => array('id' => 2, 'apple_id' => 2, 'name' => 'sample2'),
'Child' => array(
array(
'id' => 1,
'apple_id' => 2,
'color' => 'Red 1',
'name' => 'Red Apple 1',
'created' => '2006-11-22 10:38:58',
'date' => '1951-01-04',
'modified' => '2006-12-01 13:31:26',
'mytime' => '22:57:17'
),
array(
'id' => 3,
'apple_id' => 2,
'color' => 'blue green',
'name' => 'green blue',
'created' => '2006-12-25 05:13:36',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:23:24',
'mytime' => '22:57:17'
),
array(
'id' => 4,
'apple_id' => 2,
'color' => 'Blue Green',
'name' => 'Test Name',
'created' => '2006-12-25 05:23:36',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:23:36',
'mytime' => '22:57:17'
))),
'Sample' => array(
'id' => 3,
'apple_id' => 4,
'name' => 'sample3',
'Apple' => array(
'id' => 4,
'apple_id' => 2,
'color' => 'Blue Green',
'name' => 'Test Name',
'created' => '2006-12-25 05:23:36',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:23:36',
'mytime' => '22:57:17'
)),
'Child' => array(
array(
'id' => 6,
'apple_id' => 4,
'color' => 'My new appleOrange',
'name' => 'My new apple',
'created' => '2006-12-25 05:29:39',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:29:39',
'mytime' => '22:57:17',
'Parent' => array(
'id' => 4,
'apple_id' => 2,
'color' => 'Blue Green',
'name' => 'Test Name',
'created' => '2006-12-25 05:23:36',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:23:36',
'mytime' => '22:57:17'
),
'Sample' => array(),
'Child' => array(
array(
'id' => 7,
'apple_id' => 6,
'color' => 'Some wierd color',
'name' => 'Some odd color',
'created' => '2006-12-25 05:34:21',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:34:21',
'mytime' => '22:57:17'
))))),
array(
'Apple' => array(
'id' => 5,
'apple_id' => 5,
'color' => 'Green',
'name' => 'Blue Green',
'created' => '2006-12-25 05:24:06',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:29:16',
'mytime' => '22:57:17'
),
'Parent' => array(
'id' => 5,
'apple_id' => 5,
'color' => 'Green',
'name' => 'Blue Green',
'created' => '2006-12-25 05:24:06',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:29:16',
'mytime' => '22:57:17',
'Parent' => array(
'id' => 5,
'apple_id' => 5,
'color' => 'Green',
'name' => 'Blue Green',
'created' => '2006-12-25 05:24:06',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:29:16',
'mytime' => '22:57:17'
),
'Sample' => array(
'id' => 4,
'apple_id' => 5,
'name' => 'sample4'
),
'Child' => array(
array(
'id' => 5,
'apple_id' => 5,
'color' => 'Green',
'name' => 'Blue Green',
'created' => '2006-12-25 05:24:06',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:29:16',
'mytime' => '22:57:17'
))),
'Sample' => array(
'id' => 4,
'apple_id' => 5,
'name' => 'sample4',
'Apple' => array(
'id' => 5,
'apple_id' => 5,
'color' => 'Green',
'name' => 'Blue Green',
'created' => '2006-12-25 05:24:06',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:29:16',
'mytime' => '22:57:17'
)),
'Child' => array(
array(
'id' => 5,
'apple_id' => 5,
'color' => 'Green',
'name' => 'Blue Green',
'created' => '2006-12-25 05:24:06',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:29:16',
'mytime' => '22:57:17',
'Parent' => array(
'id' => 5,
'apple_id' => 5,
'color' => 'Green',
'name' => 'Blue Green',
'created' => '2006-12-25 05:24:06',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:29:16',
'mytime' => '22:57:17'
),
'Sample' => array(
'id' => 4,
'apple_id' => 5,
'name' => 'sample4'
),
'Child' => array(
array(
'id' => 5,
'apple_id' => 5,
'color' => 'Green',
'name' => 'Blue Green',
'created' => '2006-12-25 05:24:06',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:29:16',
'mytime' => '22:57:17'
))))),
array(
'Apple' => array(
'id' => 6,
'apple_id' => 4,
'color' => 'My new appleOrange',
'name' => 'My new apple',
'created' => '2006-12-25 05:29:39',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:29:39',
'mytime' => '22:57:17'
),
'Parent' => array(
'id' => 4,
'apple_id' => 2,
'color' => 'Blue Green',
'name' => 'Test Name',
'created' => '2006-12-25 05:23:36',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:23:36',
'mytime' => '22:57:17',
'Parent' => array(
'id' => 2,
'apple_id' => 1,
'color' => 'Bright Red 1',
'name' => 'Bright Red Apple',
'created' => '2006-11-22 10:43:13',
'date' => '2014-01-01',
'modified' => '2006-11-30 18:38:10',
'mytime' => '22:57:17'
),
'Sample' => array(
'id' => 3,
'apple_id' => 4,
'name' => 'sample3'
),
'Child' => array(
array(
'id' => 6,
'apple_id' => 4,
'color' => 'My new appleOrange',
'name' => 'My new apple',
'created' => '2006-12-25 05:29:39',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:29:39',
'mytime' => '22:57:17'
))),
'Sample' => array(
'id' => '',
'apple_id' => '',
'name' => ''
),
'Child' => array(
array(
'id' => 7,
'apple_id' => 6,
'color' => 'Some wierd color',
'name' => 'Some odd color',
'created' => '2006-12-25 05:34:21',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:34:21',
'mytime' => '22:57:17',
'Parent' => array(
'id' => 6,
'apple_id' => 4,
'color' => 'My new appleOrange',
'name' => 'My new apple',
'created' => '2006-12-25 05:29:39',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:29:39',
'mytime' => '22:57:17'
),
'Sample' => array()
))),
array(
'Apple' => array(
'id' => 7,
'apple_id' => 6,
'color' =>
'Some wierd color',
'name' => 'Some odd color',
'created' => '2006-12-25 05:34:21',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:34:21',
'mytime' => '22:57:17'
),
'Parent' => array(
'id' => 6,
'apple_id' => 4,
'color' => 'My new appleOrange',
'name' => 'My new apple',
'created' => '2006-12-25 05:29:39',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:29:39',
'mytime' => '22:57:17',
'Parent' => array(
'id' => 4,
'apple_id' => 2,
'color' => 'Blue Green',
'name' => 'Test Name',
'created' => '2006-12-25 05:23:36',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:23:36',
'mytime' => '22:57:17'
),
'Sample' => array(),
'Child' => array(
array(
'id' => 7,
'apple_id' => 6,
'color' => 'Some wierd color',
'name' => 'Some odd color',
'created' => '2006-12-25 05:34:21',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:34:21',
'mytime' => '22:57:17'
))),
'Sample' => array(
'id' => '',
'apple_id' => '',
'name' => ''
),
'Child' => array()));
$this->assertEqual($expected, $result);
$result = $TestModel->Parent->unbindModel(array('hasOne' => array('Sample')));
$this->assertTrue($result);
$result = $TestModel->find('all');
$expected = array(
array(
'Apple' => array(
'id' => 1,
'apple_id' => 2,
'color' => 'Red 1',
'name' => 'Red Apple 1',
'created' => '2006-11-22 10:38:58',
'date' => '1951-01-04',
'modified' => '2006-12-01 13:31:26',
'mytime' => '22:57:17'),
'Parent' => array(
'id' => 2,
'apple_id' => 1,
'color' => 'Bright Red 1',
'name' => 'Bright Red Apple',
'created' => '2006-11-22 10:43:13',
'date' => '2014-01-01',
'modified' => '2006-11-30 18:38:10',
'mytime' => '22:57:17',
'Parent' => array(
'id' => 1,
'apple_id' => 2,
'color' => 'Red 1',
'name' => 'Red Apple 1',
'created' => '2006-11-22 10:38:58',
'date' => '1951-01-04',
'modified' => '2006-12-01 13:31:26',
'mytime' => '22:57:17'
),
'Child' => array(
array(
'id' => 1,
'apple_id' => 2,
'color' => 'Red 1',
'name' => 'Red Apple 1',
'created' => '2006-11-22 10:38:58',
'date' => '1951-01-04',
'modified' => '2006-12-01 13:31:26',
'mytime' => '22:57:17'
),
array(
'id' => 3,
'apple_id' => 2,
'color' => 'blue green',
'name' => 'green blue',
'created' => '2006-12-25 05:13:36',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:23:24',
'mytime' => '22:57:17'
),
array(
'id' => 4,
'apple_id' => 2,
'color' => 'Blue Green',
'name' => 'Test Name',
'created' => '2006-12-25 05:23:36',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:23:36',
'mytime' => '22:57:17'
))),
'Sample' => array(
'id' =>'',
'apple_id' => '',
'name' => ''
),
'Child' => array(
array(
'id' => 2,
'apple_id' => 1,
'color' => 'Bright Red 1',
'name' => 'Bright Red Apple',
'created' => '2006-11-22 10:43:13',
'date' => '2014-01-01',
'modified' => '2006-11-30 18:38:10',
'mytime' => '22:57:17',
'Parent' => array(
'id' => 1,
'apple_id' => 2,
'color' => 'Red 1',
'name' => 'Red Apple 1',
'created' => '2006-11-22 10:38:58',
'date' => '1951-01-04',
'modified' => '2006-12-01 13:31:26',
'mytime' => '22:57:17'
),
'Sample' => array(
'id' => 2,
'apple_id' => 2,
'name' => 'sample2'
),
'Child' => array(
array(
'id' => 1,
'apple_id' => 2,
'color' => 'Red 1',
'name' => 'Red Apple 1',
'created' => '2006-11-22 10:38:58',
'date' => '1951-01-04',
'modified' => '2006-12-01 13:31:26',
'mytime' => '22:57:17'
),
array(
'id' => 3,
'apple_id' => 2,
'color' => 'blue green',
'name' => 'green blue',
'created' => '2006-12-25 05:13:36',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:23:24',
'mytime' => '22:57:17'
),
array(
'id' => 4,
'apple_id' => 2,
'color' => 'Blue Green',
'name' => 'Test Name',
'created' => '2006-12-25 05:23:36',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:23:36',
'mytime' => '22:57:17'
))))),
array(
'Apple' => array(
'id' => 2,
'apple_id' => 1,
'color' => 'Bright Red 1',
'name' => 'Bright Red Apple',
'created' => '2006-11-22 10:43:13',
'date' => '2014-01-01',
'modified' => '2006-11-30 18:38:10',
'mytime' => '22:57:17'
),
'Parent' => array(
'id' => 1,
'apple_id' => 2,
'color' => 'Red 1',
'name' => 'Red Apple 1',
'created' => '2006-11-22 10:38:58',
'date' => '1951-01-04',
'modified' => '2006-12-01 13:31:26',
'mytime' => '22:57:17',
'Parent' => array(
'id' => 2,
'apple_id' => 1,
'color' => 'Bright Red 1',
'name' => 'Bright Red Apple',
'created' => '2006-11-22 10:43:13',
'date' => '2014-01-01',
'modified' => '2006-11-30 18:38:10',
'mytime' => '22:57:17'
),
'Child' => array(
array(
'id' => 2,
'apple_id' => 1,
'color' => 'Bright Red 1',
'name' => 'Bright Red Apple',
'created' => '2006-11-22 10:43:13',
'date' => '2014-01-01',
'modified' => '2006-11-30 18:38:10',
'mytime' => '22:57:17'
))),
'Sample' => array(
'id' => 2,
'apple_id' => 2,
'name' => 'sample2',
'Apple' => array(
'id' => 2,
'apple_id' => 1,
'color' => 'Bright Red 1',
'name' => 'Bright Red Apple',
'created' => '2006-11-22 10:43:13',
'date' => '2014-01-01',
'modified' => '2006-11-30 18:38:10',
'mytime' => '22:57:17'
)),
'Child' => array(
array(
'id' => 1,
'apple_id' => 2,
'color' => 'Red 1',
'name' => 'Red Apple 1',
'created' => '2006-11-22 10:38:58',
'date' => '1951-01-04',
'modified' => '2006-12-01 13:31:26',
'mytime' => '22:57:17',
'Parent' => array(
'id' => 2,
'apple_id' => 1,
'color' => 'Bright Red 1',
'name' => 'Bright Red Apple',
'created' => '2006-11-22 10:43:13',
'date' => '2014-01-01',
'modified' => '2006-11-30 18:38:10',
'mytime' => '22:57:17'
),
'Sample' => array(),
'Child' => array(
array(
'id' => 2,
'apple_id' => 1,
'color' => 'Bright Red 1',
'name' => 'Bright Red Apple',
'created' => '2006-11-22 10:43:13',
'date' => '2014-01-01', 'modified' =>
'2006-11-30 18:38:10',
'mytime' => '22:57:17'
))),
array(
'id' => 3,
'apple_id' => 2,
'color' => 'blue green',
'name' => 'green blue',
'created' => '2006-12-25 05:13:36',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:23:24',
'mytime' => '22:57:17',
'Parent' => array(
'id' => 2,
'apple_id' => 1,
'color' => 'Bright Red 1',
'name' => 'Bright Red Apple',
'created' => '2006-11-22 10:43:13',
'date' => '2014-01-01',
'modified' => '2006-11-30 18:38:10',
'mytime' => '22:57:17'
),
'Sample' => array(
'id' => 1,
'apple_id' => 3,
'name' => 'sample1'
)),
array(
'id' => 4,
'apple_id' => 2,
'color' => 'Blue Green',
'name' => 'Test Name',
'created' => '2006-12-25 05:23:36',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:23:36',
'mytime' => '22:57:17',
'Parent' => array(
'id' => 2,
'apple_id' => 1,
'color' => 'Bright Red 1',
'name' => 'Bright Red Apple',
'created' => '2006-11-22 10:43:13',
'date' => '2014-01-01',
'modified' => '2006-11-30 18:38:10',
'mytime' => '22:57:17'
),
'Sample' => array(
'id' => 3,
'apple_id' => 4,
'name' => 'sample3'
),
'Child' => array(
array(
'id' => 6,
'apple_id' => 4,
'color' => 'My new appleOrange',
'name' => 'My new apple',
'created' => '2006-12-25 05:29:39',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:29:39',
'mytime' => '22:57:17'
))))),
array(
'Apple' => array(
'id' => 3,
'apple_id' => 2,
'color' => 'blue green',
'name' => 'green blue',
'created' => '2006-12-25 05:13:36',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:23:24',
'mytime' => '22:57:17'
),
'Parent' => array(
'id' => 2,
'apple_id' => 1,
'color' => 'Bright Red 1',
'name' => 'Bright Red Apple',
'created' => '2006-11-22 10:43:13',
'date' => '2014-01-01',
'modified' => '2006-11-30 18:38:10',
'mytime' => '22:57:17',
'Parent' => array(
'id' => 1,
'apple_id' => 2,
'color' => 'Red 1',
'name' => 'Red Apple 1',
'created' => '2006-11-22 10:38:58',
'date' => '1951-01-04',
'modified' => '2006-12-01 13:31:26',
'mytime' => '22:57:17'
),
'Child' => array(
array(
'id' => 1,
'apple_id' => 2,
'color' => 'Red 1',
'name' => 'Red Apple 1',
'created' => '2006-11-22 10:38:58',
'date' => '1951-01-04',
'modified' => '2006-12-01 13:31:26',
'mytime' => '22:57:17'
),
array(
'id' => 3,
'apple_id' => 2,
'color' => 'blue green',
'name' => 'green blue',
'created' => '2006-12-25 05:13:36',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:23:24',
'mytime' => '22:57:17'
),
array(
'id' => 4,
'apple_id' => 2,
'color' => 'Blue Green',
'name' => 'Test Name',
'created' => '2006-12-25 05:23:36',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:23:36',
'mytime' => '22:57:17'
))),
'Sample' => array(
'id' => 1,
'apple_id' => 3,
'name' => 'sample1',
'Apple' => array(
'id' => 3,
'apple_id' => 2,
'color' => 'blue green',
'name' => 'green blue',
'created' => '2006-12-25 05:13:36',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:23:24',
'mytime' => '22:57:17'
)),
'Child' => array()
),
array(
'Apple' => array(
'id' => 4,
'apple_id' => 2,
'color' => 'Blue Green',
'name' => 'Test Name',
'created' => '2006-12-25 05:23:36',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:23:36',
'mytime' => '22:57:17'
),
'Parent' => array(
'id' => 2,
'apple_id' => 1,
'color' => 'Bright Red 1',
'name' => 'Bright Red Apple',
'created' => '2006-11-22 10:43:13',
'date' => '2014-01-01',
'modified' => '2006-11-30 18:38:10',
'mytime' => '22:57:17',
'Parent' => array(
'id' => 1,
'apple_id' => 2,
'color' => 'Red 1',
'name' => 'Red Apple 1',
'created' => '2006-11-22 10:38:58',
'date' => '1951-01-04',
'modified' => '2006-12-01 13:31:26',
'mytime' => '22:57:17'
),
'Child' => array(
array(
'id' => 1,
'apple_id' => 2,
'color' => 'Red 1',
'name' => 'Red Apple 1',
'created' => '2006-11-22 10:38:58',
'date' => '1951-01-04',
'modified' => '2006-12-01 13:31:26',
'mytime' => '22:57:17'
),
array(
'id' => 3,
'apple_id' => 2,
'color' => 'blue green',
'name' => 'green blue',
'created' => '2006-12-25 05:13:36',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:23:24',
'mytime' => '22:57:17'
),
array(
'id' => 4,
'apple_id' => 2,
'color' => 'Blue Green',
'name' => 'Test Name',
'created' => '2006-12-25 05:23:36',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:23:36',
'mytime' => '22:57:17'
))),
'Sample' => array(
'id' => 3,
'apple_id' => 4,
'name' => 'sample3',
'Apple' => array(
'id' => 4,
'apple_id' => 2,
'color' => 'Blue Green',
'name' => 'Test Name',
'created' => '2006-12-25 05:23:36',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:23:36',
'mytime' => '22:57:17'
)),
'Child' => array(
array(
'id' => 6,
'apple_id' => 4,
'color' => 'My new appleOrange',
'name' => 'My new apple',
'created' => '2006-12-25 05:29:39',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:29:39',
'mytime' => '22:57:17',
'Parent' => array(
'id' => 4,
'apple_id' => 2,
'color' => 'Blue Green',
'name' => 'Test Name',
'created' => '2006-12-25 05:23:36',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:23:36',
'mytime' => '22:57:17'
),
'Sample' => array(),
'Child' => array(
array(
'id' => 7,
'apple_id' => 6,
'color' => 'Some wierd color',
'name' => 'Some odd color',
'created' => '2006-12-25 05:34:21',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:34:21',
'mytime' => '22:57:17'
))))),
array(
'Apple' => array(
'id' => 5,
'apple_id' => 5,
'color' => 'Green',
'name' => 'Blue Green',
'created' => '2006-12-25 05:24:06',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:29:16',
'mytime' => '22:57:17'
),
'Parent' => array(
'id' => 5,
'apple_id' => 5,
'color' => 'Green',
'name' => 'Blue Green',
'created' => '2006-12-25 05:24:06',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:29:16',
'mytime' => '22:57:17',
'Parent' => array(
'id' => 5,
'apple_id' => 5,
'color' => 'Green',
'name' => 'Blue Green',
'created' => '2006-12-25 05:24:06',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:29:16',
'mytime' => '22:57:17'
),
'Child' => array(
array(
'id' => 5,
'apple_id' => 5,
'color' => 'Green',
'name' => 'Blue Green',
'created' => '2006-12-25 05:24:06',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:29:16',
'mytime' => '22:57:17'
))),
'Sample' => array(
'id' => 4,
'apple_id' => 5,
'name' => 'sample4',
'Apple' => array(
'id' => 5,
'apple_id' => 5,
'color' => 'Green',
'name' => 'Blue Green',
'created' => '2006-12-25 05:24:06',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:29:16',
'mytime' => '22:57:17'
)),
'Child' => array(
array(
'id' => 5,
'apple_id' => 5,
'color' => 'Green',
'name' => 'Blue Green',
'created' => '2006-12-25 05:24:06',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:29:16',
'mytime' => '22:57:17',
'Parent' => array(
'id' => 5,
'apple_id' => 5,
'color' => 'Green',
'name' => 'Blue Green',
'created' => '2006-12-25 05:24:06',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:29:16',
'mytime' => '22:57:17'
),
'Sample' => array(
'id' => 4,
'apple_id' => 5,
'name' => 'sample4'
),
'Child' => array(
array(
'id' => 5,
'apple_id' => 5,
'color' => 'Green',
'name' => 'Blue Green',
'created' => '2006-12-25 05:24:06',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:29:16',
'mytime' => '22:57:17'
))))),
array(
'Apple' => array(
'id' => 6,
'apple_id' => 4,
'color' => 'My new appleOrange',
'name' => 'My new apple',
'created' => '2006-12-25 05:29:39',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:29:39',
'mytime' => '22:57:17'
),
'Parent' => array(
'id' => 4,
'apple_id' => 2,
'color' => 'Blue Green',
'name' => 'Test Name',
'created' => '2006-12-25 05:23:36',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:23:36',
'mytime' => '22:57:17',
'Parent' => array(
'id' => 2,
'apple_id' => 1,
'color' => 'Bright Red 1',
'name' => 'Bright Red Apple',
'created' => '2006-11-22 10:43:13',
'date' => '2014-01-01',
'modified' => '2006-11-30 18:38:10',
'mytime' => '22:57:17'
),
'Child' => array(
array(
'id' => 6,
'apple_id' => 4,
'color' => 'My new appleOrange',
'name' => 'My new apple',
'created' => '2006-12-25 05:29:39',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:29:39',
'mytime' => '22:57:17'
))),
'Sample' => array(
'id' => '',
'apple_id' => '',
'name' => ''
),
'Child' => array(
array(
'id' => 7,
'apple_id' => 6,
'color' => 'Some wierd color',
'name' => 'Some odd color',
'created' => '2006-12-25 05:34:21',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:34:21',
'mytime' => '22:57:17',
'Parent' => array(
'id' => 6,
'apple_id' => 4,
'color' => 'My new appleOrange',
'name' => 'My new apple',
'created' => '2006-12-25 05:29:39',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:29:39',
'mytime' => '22:57:17'
),
'Sample' => array()
))),
array(
'Apple' => array(
'id' => 7,
'apple_id' => 6,
'color' => 'Some wierd color',
'name' => 'Some odd color',
'created' => '2006-12-25 05:34:21',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:34:21',
'mytime' => '22:57:17'
),
'Parent' => array(
'id' => 6,
'apple_id' => 4,
'color' => 'My new appleOrange',
'name' => 'My new apple',
'created' => '2006-12-25 05:29:39',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:29:39',
'mytime' => '22:57:17',
'Parent' => array(
'id' => 4,
'apple_id' => 2,
'color' => 'Blue Green',
'name' => 'Test Name',
'created' => '2006-12-25 05:23:36',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:23:36',
'mytime' => '22:57:17'
),
'Child' => array(
array(
'id' => 7,
'apple_id' => 6,
'color' => 'Some wierd color',
'name' => 'Some odd color',
'created' => '2006-12-25 05:34:21',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:34:21',
'mytime' => '22:57:17'
))),
'Sample' => array(
'id' => '',
'apple_id' => '',
'name' => ''
),
'Child' => array()
));
$this->assertEqual($expected, $result);
$result = $TestModel->Parent->unbindModel(array('hasOne' => array('Sample')));
$this->assertTrue($result);
$result = $TestModel->unbindModel(array('hasMany' => array('Child')));
$this->assertTrue($result);
$result = $TestModel->find('all');
$expected = array(
array(
'Apple' => array (
'id' => 1,
'apple_id' => 2,
'color' => 'Red 1',
'name' => 'Red Apple 1',
'created' => '2006-11-22 10:38:58',
'date' => '1951-01-04',
'modified' => '2006-12-01 13:31:26',
'mytime' => '22:57:17'
),
'Parent' => array(
'id' => 2,
'apple_id' => 1,
'color' => 'Bright Red 1',
'name' => 'Bright Red Apple',
'created' => '2006-11-22 10:43:13',
'date' => '2014-01-01',
'modified' => '2006-11-30 18:38:10',
'mytime' => '22:57:17',
'Parent' => array(
'id' => 1,
'apple_id' => 2,
'color' => 'Red 1',
'name' => 'Red Apple 1',
'created' => '2006-11-22 10:38:58',
'date' => '1951-01-04',
'modified' => '2006-12-01 13:31:26',
'mytime' => '22:57:17'
),
'Child' => array(
array(
'id' => 1,
'apple_id' => 2,
'color' => 'Red 1',
'name' => 'Red Apple 1',
'created' => '2006-11-22 10:38:58',
'date' => '1951-01-04',
'modified' => '2006-12-01 13:31:26',
'mytime' => '22:57:17'
),
array(
'id' => 3,
'apple_id' => 2,
'color' => 'blue green',
'name' => 'green blue',
'created' => '2006-12-25 05:13:36',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:23:24',
'mytime' => '22:57:17'
),
array(
'id' => 4,
'apple_id' => 2,
'color' => 'Blue Green',
'name' => 'Test Name',
'created' => '2006-12-25 05:23:36',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:23:36',
'mytime' => '22:57:17'
))),
'Sample' => array(
'id' =>'',
'apple_id' => '',
'name' => ''
)),
array(
'Apple' => array(
'id' => 2,
'apple_id' => 1,
'color' => 'Bright Red 1',
'name' => 'Bright Red Apple',
'created' => '2006-11-22 10:43:13',
'date' => '2014-01-01',
'modified' => '2006-11-30 18:38:10',
'mytime' => '22:57:17'
),
'Parent' => array(
'id' => 1,
'apple_id' => 2,
'color' => 'Red 1',
'name' => 'Red Apple 1',
'created' => '2006-11-22 10:38:58',
'date' => '1951-01-04',
'modified' => '2006-12-01 13:31:26',
'mytime' => '22:57:17',
'Parent' => array(
'id' => 2,
'apple_id' => 1,
'color' => 'Bright Red 1',
'name' => 'Bright Red Apple',
'created' => '2006-11-22 10:43:13',
'date' => '2014-01-01',
'modified' => '2006-11-30 18:38:10',
'mytime' => '22:57:17'
),
'Child' => array(
array(
'id' => 2,
'apple_id' => 1,
'color' => 'Bright Red 1',
'name' => 'Bright Red Apple',
'created' => '2006-11-22 10:43:13',
'date' => '2014-01-01',
'modified' => '2006-11-30 18:38:10',
'mytime' => '22:57:17'
))),
'Sample' => array(
'id' => 2,
'apple_id' => 2,
'name' => 'sample2',
'Apple' => array(
'id' => 2,
'apple_id' => 1,
'color' => 'Bright Red 1',
'name' => 'Bright Red Apple',
'created' => '2006-11-22 10:43:13',
'date' => '2014-01-01',
'modified' => '2006-11-30 18:38:10',
'mytime' => '22:57:17'
))),
array(
'Apple' => array(
'id' => 3,
'apple_id' => 2,
'color' => 'blue green',
'name' => 'green blue',
'created' => '2006-12-25 05:13:36',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:23:24',
'mytime' => '22:57:17'
),
'Parent' => array(
'id' => 2,
'apple_id' => 1,
'color' => 'Bright Red 1',
'name' => 'Bright Red Apple',
'created' => '2006-11-22 10:43:13',
'date' => '2014-01-01',
'modified' => '2006-11-30 18:38:10',
'mytime' => '22:57:17',
'Parent' => array(
'id' => 1,
'apple_id' => 2,
'color' => 'Red 1',
'name' => 'Red Apple 1',
'created' => '2006-11-22 10:38:58',
'date' => '1951-01-04',
'modified' => '2006-12-01 13:31:26',
'mytime' => '22:57:17'
),
'Child' => array(
array(
'id' => 1,
'apple_id' => 2,
'color' => 'Red 1',
'name' => 'Red Apple 1',
'created' => '2006-11-22 10:38:58',
'date' => '1951-01-04',
'modified' => '2006-12-01 13:31:26',
'mytime' => '22:57:17'
),
array(
'id' => 3,
'apple_id' => 2,
'color' => 'blue green',
'name' => 'green blue',
'created' => '2006-12-25 05:13:36',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:23:24',
'mytime' => '22:57:17'
),
array(
'id' => 4,
'apple_id' => 2,
'color' => 'Blue Green',
'name' => 'Test Name',
'created' => '2006-12-25 05:23:36',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:23:36',
'mytime' => '22:57:17'
))),
'Sample' => array(
'id' => 1,
'apple_id' => 3,
'name' => 'sample1',
'Apple' => array(
'id' => 3,
'apple_id' => 2,
'color' => 'blue green',
'name' => 'green blue',
'created' => '2006-12-25 05:13:36',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:23:24',
'mytime' => '22:57:17'
))),
array(
'Apple' => array(
'id' => 4,
'apple_id' => 2,
'color' => 'Blue Green',
'name' => 'Test Name',
'created' => '2006-12-25 05:23:36',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:23:36',
'mytime' => '22:57:17'
),
'Parent' => array(
'id' => 2,
'apple_id' => 1,
'color' => 'Bright Red 1',
'name' => 'Bright Red Apple',
'created' => '2006-11-22 10:43:13',
'date' => '2014-01-01',
'modified' => '2006-11-30 18:38:10',
'mytime' => '22:57:17',
'Parent' => array(
'id' => 1,
'apple_id' => 2,
'color' => 'Red 1',
'name' => 'Red Apple 1',
'created' => '2006-11-22 10:38:58',
'date' => '1951-01-04',
'modified' => '2006-12-01 13:31:26',
'mytime' => '22:57:17'
),
'Child' => array(
array(
'id' => 1,
'apple_id' => 2,
'color' => 'Red 1',
'name' => 'Red Apple 1',
'created' => '2006-11-22 10:38:58',
'date' => '1951-01-04',
'modified' => '2006-12-01 13:31:26',
'mytime' => '22:57:17'
),
array(
'id' => 3,
'apple_id' => 2,
'color' => 'blue green',
'name' => 'green blue',
'created' => '2006-12-25 05:13:36',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:23:24',
'mytime' => '22:57:17'
),
array(
'id' => 4,
'apple_id' => 2,
'color' => 'Blue Green',
'name' => 'Test Name',
'created' => '2006-12-25 05:23:36',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:23:36',
'mytime' => '22:57:17'
))),
'Sample' => array(
'id' => 3,
'apple_id' => 4,
'name' => 'sample3',
'Apple' => array(
'id' => 4,
'apple_id' => 2,
'color' => 'Blue Green',
'name' => 'Test Name',
'created' => '2006-12-25 05:23:36',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:23:36',
'mytime' => '22:57:17'
))),
array(
'Apple' => array(
'id' => 5,
'apple_id' => 5,
'color' => 'Green',
'name' => 'Blue Green',
'created' => '2006-12-25 05:24:06',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:29:16',
'mytime' => '22:57:17'
),
'Parent' => array(
'id' => 5,
'apple_id' => 5,
'color' => 'Green',
'name' => 'Blue Green',
'created' => '2006-12-25 05:24:06',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:29:16',
'mytime' => '22:57:17',
'Parent' => array(
'id' => 5,
'apple_id' => 5,
'color' => 'Green',
'name' => 'Blue Green',
'created' => '2006-12-25 05:24:06',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:29:16',
'mytime' => '22:57:17'
),
'Child' => array(
array(
'id' => 5,
'apple_id' => 5,
'color' => 'Green',
'name' => 'Blue Green',
'created' => '2006-12-25 05:24:06',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:29:16',
'mytime' => '22:57:17'
))),
'Sample' => array(
'id' => 4,
'apple_id' => 5,
'name' => 'sample4',
'Apple' => array(
'id' => 5,
'apple_id' => 5,
'color' => 'Green',
'name' => 'Blue Green',
'created' => '2006-12-25 05:24:06',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:29:16',
'mytime' => '22:57:17'
))),
array(
'Apple' => array(
'id' => 6,
'apple_id' => 4,
'color' => 'My new appleOrange',
'name' => 'My new apple',
'created' => '2006-12-25 05:29:39',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:29:39',
'mytime' => '22:57:17'
),
'Parent' => array(
'id' => 4,
'apple_id' => 2,
'color' => 'Blue Green',
'name' => 'Test Name',
'created' => '2006-12-25 05:23:36',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:23:36',
'mytime' => '22:57:17',
'Parent' => array(
'id' => 2,
'apple_id' => 1,
'color' => 'Bright Red 1',
'name' => 'Bright Red Apple',
'created' => '2006-11-22 10:43:13',
'date' => '2014-01-01',
'modified' => '2006-11-30 18:38:10',
'mytime' => '22:57:17'
),
'Child' => array(
array(
'id' => 6,
'apple_id' => 4,
'color' => 'My new appleOrange',
'name' => 'My new apple',
'created' => '2006-12-25 05:29:39',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:29:39',
'mytime' => '22:57:17'
))),
'Sample' => array(
'id' => '',
'apple_id' => '',
'name' => ''
)),
array(
'Apple' => array(
'id' => 7,
'apple_id' => 6,
'color' => 'Some wierd color',
'name' => 'Some odd color',
'created' => '2006-12-25 05:34:21',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:34:21',
'mytime' => '22:57:17'
),
'Parent' => array(
'id' => 6,
'apple_id' => 4,
'color' => 'My new appleOrange',
'name' => 'My new apple',
'created' => '2006-12-25 05:29:39',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:29:39',
'mytime' => '22:57:17',
'Parent' => array(
'id' => 4,
'apple_id' => 2,
'color' => 'Blue Green',
'name' => 'Test Name',
'created' => '2006-12-25 05:23:36',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:23:36',
'mytime' => '22:57:17'
),
'Child' => array(
array(
'id' => 7,
'apple_id' => 6,
'color' => 'Some wierd color',
'name' => 'Some odd color',
'created' => '2006-12-25 05:34:21',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:34:21',
'mytime' => '22:57:17'
))),
'Sample' => array(
'id' => '',
'apple_id' => '',
'name' => ''
)));
$this->assertEqual($expected, $result);
$result = $TestModel->unbindModel(array('hasMany' => array('Child')));
$this->assertTrue($result);
$result = $TestModel->Sample->unbindModel(array('belongsTo' => array('Apple')));
$this->assertTrue($result);
$result = $TestModel->find('all');
$expected = array(
array(
'Apple' => array(
'id' => 1,
'apple_id' => 2,
'color' => 'Red 1',
'name' => 'Red Apple 1',
'created' => '2006-11-22 10:38:58',
'date' => '1951-01-04',
'modified' => '2006-12-01 13:31:26',
'mytime' => '22:57:17'
),
'Parent' => array(
'id' => 2,
'apple_id' => 1,
'color' => 'Bright Red 1',
'name' => 'Bright Red Apple',
'created' => '2006-11-22 10:43:13',
'date' => '2014-01-01',
'modified' => '2006-11-30 18:38:10',
'mytime' => '22:57:17',
'Parent' => array(
'id' => 1,
'apple_id' => 2,
'color' => 'Red 1',
'name' => 'Red Apple 1',
'created' => '2006-11-22 10:38:58',
'date' => '1951-01-04',
'modified' => '2006-12-01 13:31:26',
'mytime' => '22:57:17'
),
'Sample' => array(
'id' => 2,
'apple_id' => 2,
'name' => 'sample2'
),
'Child' => array(
array(
'id' => 1,
'apple_id' => 2,
'color' => 'Red 1',
'name' => 'Red Apple 1',
'created' => '2006-11-22 10:38:58',
'date' => '1951-01-04',
'modified' => '2006-12-01 13:31:26',
'mytime' => '22:57:17'
),
array(
'id' => 3,
'apple_id' => 2,
'color' => 'blue green',
'name' => 'green blue',
'created' => '2006-12-25 05:13:36',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:23:24',
'mytime' => '22:57:17'
),
array(
'id' => 4,
'apple_id' => 2,
'color' => 'Blue Green',
'name' => 'Test Name',
'created' => '2006-12-25 05:23:36',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:23:36',
'mytime' => '22:57:17'
))),
'Sample' => array(
'id' =>'',
'apple_id' => '',
'name' => ''
)),
array(
'Apple' => array(
'id' => 2,
'apple_id' => 1,
'color' => 'Bright Red 1',
'name' => 'Bright Red Apple',
'created' => '2006-11-22 10:43:13',
'date' => '2014-01-01',
'modified' => '2006-11-30 18:38:10',
'mytime' => '22:57:17'
),
'Parent' => array(
'id' => 1,
'apple_id' => 2,
'color' => 'Red 1',
'name' => 'Red Apple 1',
'created' => '2006-11-22 10:38:58',
'date' => '1951-01-04',
'modified' => '2006-12-01 13:31:26',
'mytime' => '22:57:17',
'Parent' => array(
'id' => 2,
'apple_id' => 1,
'color' => 'Bright Red 1',
'name' => 'Bright Red Apple',
'created' => '2006-11-22 10:43:13',
'date' => '2014-01-01',
'modified' => '2006-11-30 18:38:10',
'mytime' => '22:57:17'
),
'Sample' => array(),
'Child' => array(
array(
'id' => 2,
'apple_id' => 1,
'color' => 'Bright Red 1',
'name' => 'Bright Red Apple',
'created' => '2006-11-22 10:43:13',
'date' => '2014-01-01',
'modified' => '2006-11-30 18:38:10',
'mytime' => '22:57:17'
))),
'Sample' => array(
'id' => 2,
'apple_id' => 2,
'name' => 'sample2'
)),
array(
'Apple' => array(
'id' => 3,
'apple_id' => 2,
'color' => 'blue green',
'name' => 'green blue',
'created' => '2006-12-25 05:13:36',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:23:24',
'mytime' => '22:57:17'
),
'Parent' => array(
'id' => 2,
'apple_id' => 1,
'color' => 'Bright Red 1',
'name' => 'Bright Red Apple',
'created' => '2006-11-22 10:43:13',
'date' => '2014-01-01',
'modified' => '2006-11-30 18:38:10',
'mytime' => '22:57:17',
'Parent' => array(
'id' => 1,
'apple_id' => 2,
'color' => 'Red 1',
'name' => 'Red Apple 1',
'created' => '2006-11-22 10:38:58',
'date' => '1951-01-04',
'modified' => '2006-12-01 13:31:26',
'mytime' => '22:57:17'
),
'Sample' => array(
'id' => 2,
'apple_id' => 2,
'name' => 'sample2'
),
'Child' => array(
array(
'id' => 1,
'apple_id' => 2,
'color' => 'Red 1',
'name' => 'Red Apple 1',
'created' => '2006-11-22 10:38:58',
'date' => '1951-01-04',
'modified' => '2006-12-01 13:31:26',
'mytime' => '22:57:17'
),
array(
'id' => 3,
'apple_id' => 2,
'color' => 'blue green',
'name' => 'green blue',
'created' => '2006-12-25 05:13:36',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:23:24',
'mytime' => '22:57:17'
),
array(
'id' => 4,
'apple_id' => 2,
'color' => 'Blue Green',
'name' => 'Test Name',
'created' => '2006-12-25 05:23:36',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:23:36',
'mytime' => '22:57:17'
))),
'Sample' => array(
'id' => 1,
'apple_id' => 3,
'name' => 'sample1'
)),
array(
'Apple' => array(
'id' => 4,
'apple_id' => 2,
'color' => 'Blue Green',
'name' => 'Test Name',
'created' => '2006-12-25 05:23:36',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:23:36',
'mytime' => '22:57:17'
),
'Parent' => array(
'id' => 2,
'apple_id' => 1,
'color' => 'Bright Red 1',
'name' => 'Bright Red Apple',
'created' => '2006-11-22 10:43:13',
'date' => '2014-01-01',
'modified' => '2006-11-30 18:38:10',
'mytime' => '22:57:17',
'Parent' => array(
'id' => 1,
'apple_id' => 2,
'color' => 'Red 1',
'name' => 'Red Apple 1',
'created' => '2006-11-22 10:38:58',
'date' => '1951-01-04',
'modified' => '2006-12-01 13:31:26',
'mytime' => '22:57:17'
),
'Sample' => array(
'id' => 2,
'apple_id' => 2,
'name' => 'sample2'
),
'Child' => array(
array(
'id' => 1,
'apple_id' => 2,
'color' => 'Red 1',
'name' => 'Red Apple 1',
'created' => '2006-11-22 10:38:58',
'date' => '1951-01-04',
'modified' => '2006-12-01 13:31:26',
'mytime' => '22:57:17'
),
array(
'id' => 3,
'apple_id' => 2,
'color' => 'blue green',
'name' => 'green blue',
'created' => '2006-12-25 05:13:36',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:23:24',
'mytime' => '22:57:17'
),
array(
'id' => 4,
'apple_id' => 2,
'color' => 'Blue Green',
'name' => 'Test Name',
'created' => '2006-12-25 05:23:36',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:23:36',
'mytime' => '22:57:17'
))),
'Sample' => array(
'id' => 3,
'apple_id' => 4,
'name' => 'sample3'
)),
array(
'Apple' => array(
'id' => 5,
'apple_id' => 5,
'color' => 'Green',
'name' => 'Blue Green',
'created' => '2006-12-25 05:24:06',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:29:16',
'mytime' => '22:57:17'
),
'Parent' => array(
'id' => 5,
'apple_id' => 5,
'color' => 'Green',
'name' => 'Blue Green',
'created' => '2006-12-25 05:24:06',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:29:16',
'mytime' => '22:57:17',
'Parent' => array(
'id' => 5,
'apple_id' => 5,
'color' => 'Green',
'name' => 'Blue Green',
'created' => '2006-12-25 05:24:06',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:29:16',
'mytime' => '22:57:17'
),
'Sample' => array(
'id' => 4,
'apple_id' => 5,
'name' => 'sample4'
),
'Child' => array(
array(
'id' => 5,
'apple_id' => 5,
'color' => 'Green',
'name' => 'Blue Green',
'created' => '2006-12-25 05:24:06',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:29:16',
'mytime' => '22:57:17'
))),
'Sample' => array(
'id' => 4,
'apple_id' => 5,
'name' => 'sample4'
)),
array(
'Apple' => array(
'id' => 6,
'apple_id' => 4,
'color' => 'My new appleOrange',
'name' => 'My new apple',
'created' => '2006-12-25 05:29:39',
'date' => '2006-12-25',
'modified' => '2006-12-25 05:29:39',
'mytime' => '22:57:17'
),
'Parent' => array(
'id' => 4,
'apple_id' => 2,
'color' => 'Blue Green',
'name' => 'Test Name',