/cake/tests/cases/libs/model/model_read.test.php
PHP | 7456 lines | 6784 code | 326 blank | 346 comment | 24 complexity | 2cd3a3cc5297beb0d6137e2610f2f396 MD5 | raw file
Large files files are truncated, but you can click here to view the full file
- <?php
- /**
- * ModelReadTest file
- *
- * PHP versions 4 and 5
- *
- * CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
- * Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
- *
- * Licensed under The Open Group Test Suite 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
- * @subpackage cake.tests.cases.libs.model
- * @since CakePHP(tm) v 1.2.0.4206
- * @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
- */
- require_once dirname(__FILE__) . DS . 'model.test.php';
- /**
- * ModelReadTest
- *
- * @package cake
- * @subpackage 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_suite');
- $isStrictGroupBy = in_array($db->config['driver'], array('postgres', 'oracle'));
- $message = '%s 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($result, $expected);
- $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($result, $expected);
- $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($result, $expected);
- $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($result, $expected);
- $result = $Thread->find('all', array(
- 'conditions' => array('Thread.project_id' => 1),
- 'group' => 'Thread.project_id, Project.id'
- ));
- $this->assertEqual($result, $expected);
- $result = $Thread->find('all', array(
- 'conditions' => array('Thread.project_id' => 1),
- 'group' => 'project_id'
- ));
- $this->assertEqual($result, $expected);
- $result = $Thread->find('all', array(
- 'conditions' => array('Thread.project_id' => 1),
- 'group' => array('project_id')
- ));
- $this->assertEqual($result, $expected);
- $result = $Thread->find('all', array(
- 'conditions' => array('Thread.project_id' => 1),
- 'group' => array('project_id', 'Project.id')
- ));
- $this->assertEqual($result, $expected);
- $result = $Thread->find('all', array(
- 'conditions' => array('Thread.project_id' => 1),
- 'group' => array('Thread.project_id', 'Project.id')
- ));
- $this->assertEqual($result, $expected);
- $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($result, $expected);
- $result = $Product->find('all', array(
- 'fields'=>array('Product.type', 'MIN(Product.price) as price'),
- 'group'=> array('Product.type'),
- 'order' => 'Product.type ASC'));
- $this->assertEqual($result, $expected);
- }
- /**
- * testOldQuery method
- *
- * @access public
- * @return void
- */
- function testOldQuery() {
- $this->loadFixtures('Article');
- $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->assertTrue(!isset($this->db->_queryCache[$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);
- $this->assertTrue(isset($this->db->_queryCache[$query]));
- $this->assertTrue(is_array($results));
- }
- /**
- * testPreparedQuery method
- *
- * @access public
- * @return void
- */
- function testPreparedQuery() {
- $this->loadFixtures('Article');
- $Article =& new Article();
- $this->db->_queryCache = array();
- $finalQuery = 'SELECT title, published FROM ';
- $finalQuery .= $this->db->fullTableName('articles');
- $finalQuery .= ' WHERE ' . $this->db->fullTableName('articles');
- $finalQuery .= '.id = ' . $this->db->value(1);
- $finalQuery .= ' AND ' . $this->db->fullTableName('articles');
- $finalQuery .= '.published = ' . $this->db->value('Y');
- $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($result, $expected);
- $this->assertTrue(isset($this->db->_queryCache[$finalQuery]));
- $finalQuery = 'SELECT id, created FROM ';
- $finalQuery .= $this->db->fullTableName('articles');
- $finalQuery .= ' WHERE ' . $this->db->fullTableName('articles');
- $finalQuery .= '.title = ' . $this->db->value('First Article');
- $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])
- );
- $this->assertFalse(isset($this->db->_queryCache[$finalQuery]));
- $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);
- $expected = 'SELECT title FROM ';
- $expected .= $this->db->fullTableName('articles');
- $expected .= " WHERE title = 'First? Article' AND published = 'Y'";
- $this->assertTrue(isset($this->db->_queryCache[$expected]));
- }
- /**
- * testParameterMismatch method
- *
- * @access public
- * @return void
- */
- function testParameterMismatch() {
- $this->loadFixtures('Article');
- $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 = "%s skipping SELECT * FROM ? WHERE ? = ? AND ? = ?; prepared query.";
- $message .= " MSSQL is incompatible with this test.";
- if ($this->skipIf($this->db->config['driver'] == 'mssql', $message)) {
- return;
- }
- $this->loadFixtures('Article');
- $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() {
- $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($result, $expected);
- $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($result, $expected);
- $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,
- …
Large files files are truncated, but you can click here to view the full file