PageRenderTime 53ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 1ms

/lib/Cake/Test/Case/Model/ModelReadTest.php

https://bitbucket.org/udeshika/fake_twitter
PHP | 7691 lines | 7005 code | 347 blank | 339 comment | 15 complexity | 699f144506177b0ef2a1165e161e160c MD5 | raw file

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. /**
  3. * ModelReadTest file
  4. *
  5. * PHP 5
  6. *
  7. * CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
  8. * Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
  9. *
  10. * Licensed under The MIT License
  11. * Redistributions of files must retain the above copyright notice
  12. *
  13. * @copyright Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
  14. * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
  15. * @package Cake.Test.Case.Model
  16. * @since CakePHP(tm) v 1.2.0.4206
  17. * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
  18. */
  19. require_once dirname(__FILE__) . DS . 'ModelTestBase.php';
  20. /**
  21. * ModelReadTest
  22. *
  23. * @package Cake.Test.Case.Model
  24. */
  25. class ModelReadTest extends BaseModelTest {
  26. /**
  27. * testFetchingNonUniqueFKJoinTableRecords()
  28. *
  29. * Tests if the results are properly returned in the case there are non-unique FK's
  30. * in the join table but another fields value is different. For example:
  31. * something_id | something_else_id | doomed = 1
  32. * something_id | something_else_id | doomed = 0
  33. * Should return both records and not just one.
  34. *
  35. * @return void
  36. */
  37. public function testFetchingNonUniqueFKJoinTableRecords() {
  38. $this->loadFixtures('Something', 'SomethingElse', 'JoinThing');
  39. $Something = new Something();
  40. $joinThingData = array(
  41. 'JoinThing' => array(
  42. 'something_id' => 1,
  43. 'something_else_id' => 2,
  44. 'doomed' => '0',
  45. 'created' => '2007-03-18 10:39:23',
  46. 'updated' => '2007-03-18 10:41:31'
  47. )
  48. );
  49. $Something->JoinThing->create($joinThingData);
  50. $Something->JoinThing->save();
  51. $result = $Something->JoinThing->find('all', array('conditions' => array('something_else_id' => 2)));
  52. $this->assertEquals($result[0]['JoinThing']['doomed'], true);
  53. $this->assertEquals($result[1]['JoinThing']['doomed'], false);
  54. $result = $Something->find('first');
  55. $this->assertEquals(count($result['SomethingElse']), 2);
  56. $doomed = Set::extract('/JoinThing/doomed', $result['SomethingElse']);
  57. $this->assertTrue(in_array(true, $doomed));
  58. $this->assertTrue(in_array(false, $doomed));
  59. }
  60. /**
  61. * testGroupBy method
  62. *
  63. * These tests will never pass with Postgres or Oracle as all fields in a select must be
  64. * part of an aggregate function or in the GROUP BY statement.
  65. *
  66. * @return void
  67. */
  68. public function testGroupBy() {
  69. $db = ConnectionManager::getDataSource('test');
  70. $isStrictGroupBy = $this->db instanceof Postgres || $this->db instanceof Sqlite || $this->db instanceof Oracle || $this->db instanceof Sqlserver;
  71. $message = 'Postgres, Oracle, SQLite and SQL Server have strict GROUP BY and are incompatible with this test.';
  72. $this->skipIf($isStrictGroupBy, $message);
  73. $this->loadFixtures('Project', 'Product', 'Thread', 'Message', 'Bid');
  74. $Thread = new Thread();
  75. $Product = new Product();
  76. $result = $Thread->find('all', array(
  77. 'group' => 'Thread.project_id',
  78. 'order' => 'Thread.id ASC'
  79. ));
  80. $expected = array(
  81. array(
  82. 'Thread' => array(
  83. 'id' => 1,
  84. 'project_id' => 1,
  85. 'name' => 'Project 1, Thread 1'
  86. ),
  87. 'Project' => array(
  88. 'id' => 1,
  89. 'name' => 'Project 1'
  90. ),
  91. 'Message' => array(
  92. array(
  93. 'id' => 1,
  94. 'thread_id' => 1,
  95. 'name' => 'Thread 1, Message 1'
  96. ))),
  97. array(
  98. 'Thread' => array(
  99. 'id' => 3,
  100. 'project_id' => 2,
  101. 'name' => 'Project 2, Thread 1'
  102. ),
  103. 'Project' => array(
  104. 'id' => 2,
  105. 'name' => 'Project 2'
  106. ),
  107. 'Message' => array(
  108. array(
  109. 'id' => 3,
  110. 'thread_id' => 3,
  111. 'name' => 'Thread 3, Message 1'
  112. ))));
  113. $this->assertEquals($expected, $result);
  114. $rows = $Thread->find('all', array(
  115. 'group' => 'Thread.project_id',
  116. 'fields' => array('Thread.project_id', 'COUNT(*) AS total')
  117. ));
  118. $result = array();
  119. foreach ($rows as $row) {
  120. $result[$row['Thread']['project_id']] = $row[0]['total'];
  121. }
  122. $expected = array(
  123. 1 => 2,
  124. 2 => 1
  125. );
  126. $this->assertEquals($expected, $result);
  127. $rows = $Thread->find('all', array(
  128. 'group' => 'Thread.project_id',
  129. 'fields' => array('Thread.project_id', 'COUNT(*) AS total'),
  130. 'order' => 'Thread.project_id'
  131. ));
  132. $result = array();
  133. foreach ($rows as $row) {
  134. $result[$row['Thread']['project_id']] = $row[0]['total'];
  135. }
  136. $expected = array(
  137. 1 => 2,
  138. 2 => 1
  139. );
  140. $this->assertEquals($expected, $result);
  141. $result = $Thread->find('all', array(
  142. 'conditions' => array('Thread.project_id' => 1),
  143. 'group' => 'Thread.project_id'
  144. ));
  145. $expected = array(
  146. array(
  147. 'Thread' => array(
  148. 'id' => 1,
  149. 'project_id' => 1,
  150. 'name' => 'Project 1, Thread 1'
  151. ),
  152. 'Project' => array(
  153. 'id' => 1,
  154. 'name' => 'Project 1'
  155. ),
  156. 'Message' => array(
  157. array(
  158. 'id' => 1,
  159. 'thread_id' => 1,
  160. 'name' => 'Thread 1, Message 1'
  161. ))));
  162. $this->assertEquals($expected, $result);
  163. $result = $Thread->find('all', array(
  164. 'conditions' => array('Thread.project_id' => 1),
  165. 'group' => 'Thread.project_id, Project.id'
  166. ));
  167. $this->assertEquals($expected, $result);
  168. $result = $Thread->find('all', array(
  169. 'conditions' => array('Thread.project_id' => 1),
  170. 'group' => 'project_id'
  171. ));
  172. $this->assertEquals($expected, $result);
  173. $result = $Thread->find('all', array(
  174. 'conditions' => array('Thread.project_id' => 1),
  175. 'group' => array('project_id')
  176. ));
  177. $this->assertEquals($expected, $result);
  178. $result = $Thread->find('all', array(
  179. 'conditions' => array('Thread.project_id' => 1),
  180. 'group' => array('project_id', 'Project.id')
  181. ));
  182. $this->assertEquals($expected, $result);
  183. $result = $Thread->find('all', array(
  184. 'conditions' => array('Thread.project_id' => 1),
  185. 'group' => array('Thread.project_id', 'Project.id')
  186. ));
  187. $this->assertEquals($expected, $result);
  188. $expected = array(
  189. array('Product' => array('type' => 'Clothing'), array('price' => 32)),
  190. array('Product' => array('type' => 'Food'), array('price' => 9)),
  191. array('Product' => array('type' => 'Music'), array('price' => 4)),
  192. array('Product' => array('type' => 'Toy'), array('price' => 3))
  193. );
  194. $result = $Product->find('all',array(
  195. 'fields' => array('Product.type', 'MIN(Product.price) as price'),
  196. 'group' => 'Product.type',
  197. 'order' => 'Product.type ASC'
  198. ));
  199. $this->assertEquals($expected, $result);
  200. $result = $Product->find('all', array(
  201. 'fields' => array('Product.type', 'MIN(Product.price) as price'),
  202. 'group' => array('Product.type'),
  203. 'order' => 'Product.type ASC'));
  204. $this->assertEquals($expected, $result);
  205. }
  206. /**
  207. * testOldQuery method
  208. *
  209. * @return void
  210. */
  211. public function testOldQuery() {
  212. $this->loadFixtures('Article', 'User', 'Tag', 'ArticlesTag', 'Comment', 'Attachment');
  213. $Article = new Article();
  214. $query = 'SELECT title FROM ';
  215. $query .= $this->db->fullTableName('articles');
  216. $query .= ' WHERE ' . $this->db->fullTableName('articles') . '.id IN (1,2)';
  217. $results = $Article->query($query);
  218. $this->assertTrue(is_array($results));
  219. $this->assertEquals(count($results), 2);
  220. $query = 'SELECT title, body FROM ';
  221. $query .= $this->db->fullTableName('articles');
  222. $query .= ' WHERE ' . $this->db->fullTableName('articles') . '.id = 1';
  223. $results = $Article->query($query, false);
  224. $this->assertFalse($this->db->getQueryCache($query));
  225. $this->assertTrue(is_array($results));
  226. $query = 'SELECT title, id FROM ';
  227. $query .= $this->db->fullTableName('articles');
  228. $query .= ' WHERE ' . $this->db->fullTableName('articles');
  229. $query .= '.published = ' . $this->db->value('Y');
  230. $results = $Article->query($query, true);
  231. $result = $this->db->getQueryCache($query);
  232. $this->assertFalse(empty($result));
  233. $this->assertTrue(is_array($results));
  234. }
  235. /**
  236. * testPreparedQuery method
  237. *
  238. * @return void
  239. */
  240. public function testPreparedQuery() {
  241. $this->loadFixtures('Article', 'User', 'Tag', 'ArticlesTag');
  242. $Article = new Article();
  243. $query = 'SELECT title, published FROM ';
  244. $query .= $this->db->fullTableName('articles');
  245. $query .= ' WHERE ' . $this->db->fullTableName('articles');
  246. $query .= '.id = ? AND ' . $this->db->fullTableName('articles') . '.published = ?';
  247. $params = array(1, 'Y');
  248. $result = $Article->query($query, $params);
  249. $expected = array(
  250. '0' => array(
  251. $this->db->fullTableName('articles', false) => array(
  252. 'title' => 'First Article', 'published' => 'Y')
  253. ));
  254. if (isset($result[0][0])) {
  255. $expected[0][0] = $expected[0][$this->db->fullTableName('articles', false)];
  256. unset($expected[0][$this->db->fullTableName('articles', false)]);
  257. }
  258. $this->assertEquals($expected, $result);
  259. $result = $this->db->getQueryCache($query, $params);
  260. $this->assertFalse(empty($result));
  261. $query = 'SELECT id, created FROM ';
  262. $query .= $this->db->fullTableName('articles');
  263. $query .= ' WHERE ' . $this->db->fullTableName('articles') . '.title = ?';
  264. $params = array('First Article');
  265. $result = $Article->query($query, $params, false);
  266. $this->assertTrue(is_array($result));
  267. $this->assertTrue(
  268. isset($result[0][$this->db->fullTableName('articles', false)])
  269. || isset($result[0][0])
  270. );
  271. $result = $this->db->getQueryCache($query, $params);
  272. $this->assertTrue(empty($result));
  273. $query = 'SELECT title FROM ';
  274. $query .= $this->db->fullTableName('articles');
  275. $query .= ' WHERE ' . $this->db->fullTableName('articles') . '.title LIKE ?';
  276. $params = array('%First%');
  277. $result = $Article->query($query, $params);
  278. $this->assertTrue(is_array($result));
  279. $this->assertTrue(
  280. isset($result[0][$this->db->fullTableName('articles', false)]['title'])
  281. || isset($result[0][0]['title'])
  282. );
  283. //related to ticket #5035
  284. $query = 'SELECT title FROM ';
  285. $query .= $this->db->fullTableName('articles') . ' WHERE title = ? AND published = ?';
  286. $params = array('First? Article', 'Y');
  287. $Article->query($query, $params);
  288. $result = $this->db->getQueryCache($query, $params);
  289. $this->assertFalse($result === false);
  290. }
  291. /**
  292. * testParameterMismatch method
  293. *
  294. * @expectedException PDOException
  295. * @return void
  296. */
  297. public function testParameterMismatch() {
  298. $this->skipIf($this->db instanceof Sqlite, 'Sqlite does not accept real prepared statements, no way to check this');
  299. $this->loadFixtures('Article', 'User', 'Tag', 'ArticlesTag');
  300. $Article = new Article();
  301. $query = 'SELECT * FROM ' . $this->db->fullTableName('articles');
  302. $query .= ' WHERE ' . $this->db->fullTableName('articles');
  303. $query .= '.published = ? AND ' . $this->db->fullTableName('articles') . '.user_id = ?';
  304. $params = array('Y');
  305. $result = $Article->query($query, $params);
  306. }
  307. /**
  308. * testVeryStrangeUseCase method
  309. *
  310. * @expectedException PDOException
  311. * @return void
  312. */
  313. public function testVeryStrangeUseCase() {
  314. $this->loadFixtures('Article', 'User', 'Tag', 'ArticlesTag');
  315. $Article = new Article();
  316. $query = 'SELECT * FROM ? WHERE ? = ? AND ? = ?';
  317. $param = array(
  318. $this->db->fullTableName('articles'),
  319. $this->db->fullTableName('articles') . '.user_id', '3',
  320. $this->db->fullTableName('articles') . '.published', 'Y'
  321. );
  322. $result = $Article->query($query, $param);
  323. }
  324. /**
  325. * testRecursiveUnbind method
  326. *
  327. * @return void
  328. */
  329. public function testRecursiveUnbind() {
  330. $this->skipIf($this->db instanceof Sqlserver, 'The test of testRecursiveUnbind test is not compatible with SQL Server, because it check for time columns.');
  331. $this->loadFixtures('Apple', 'Sample');
  332. $TestModel = new Apple();
  333. $TestModel->recursive = 2;
  334. $result = $TestModel->find('all');
  335. $expected = array(
  336. array(
  337. 'Apple' => array(
  338. 'id' => 1,
  339. 'apple_id' => 2,
  340. 'color' => 'Red 1',
  341. 'name' => 'Red Apple 1',
  342. 'created' => '2006-11-22 10:38:58',
  343. 'date' => '1951-01-04',
  344. 'modified' => '2006-12-01 13:31:26',
  345. 'mytime' => '22:57:17'
  346. ),
  347. 'Parent' => array(
  348. 'id' => 2,
  349. 'apple_id' => 1,
  350. 'color' => 'Bright Red 1',
  351. 'name' => 'Bright Red Apple',
  352. 'created' => '2006-11-22 10:43:13',
  353. 'date' => '2014-01-01',
  354. 'modified' => '2006-11-30 18:38:10',
  355. 'mytime' => '22:57:17',
  356. 'Parent' => array(
  357. 'id' => 1,
  358. 'apple_id' => 2,
  359. 'color' => 'Red 1',
  360. 'name' => 'Red Apple 1',
  361. 'created' => '2006-11-22 10:38:58',
  362. 'date' => '1951-01-04',
  363. 'modified' => '2006-12-01 13:31:26',
  364. 'mytime' => '22:57:17'
  365. ),
  366. 'Sample' => array(
  367. 'id' => 2,
  368. 'apple_id' => 2,
  369. 'name' => 'sample2'
  370. ),
  371. 'Child' => array(
  372. array(
  373. 'id' => 1,
  374. 'apple_id' => 2,
  375. 'color' => 'Red 1',
  376. 'name' => 'Red Apple 1',
  377. 'created' => '2006-11-22 10:38:58',
  378. 'date' => '1951-01-04',
  379. 'modified' => '2006-12-01 13:31:26',
  380. 'mytime' => '22:57:17'
  381. ),
  382. array(
  383. 'id' => 3,
  384. 'apple_id' => 2,
  385. 'color' => 'blue green',
  386. 'name' => 'green blue',
  387. 'created' => '2006-12-25 05:13:36',
  388. 'date' => '2006-12-25',
  389. 'modified' => '2006-12-25 05:23:24',
  390. 'mytime' => '22:57:17'
  391. ),
  392. array(
  393. 'id' => 4,
  394. 'apple_id' => 2,
  395. 'color' => 'Blue Green',
  396. 'name' => 'Test Name',
  397. 'created' => '2006-12-25 05:23:36',
  398. 'date' => '2006-12-25',
  399. 'modified' => '2006-12-25 05:23:36',
  400. 'mytime' => '22:57:17'
  401. ))),
  402. 'Sample' => array(
  403. 'id' => '',
  404. 'apple_id' => '',
  405. 'name' => ''
  406. ),
  407. 'Child' => array(
  408. array(
  409. 'id' => 2,
  410. 'apple_id' => 1,
  411. 'color' => 'Bright Red 1',
  412. 'name' => 'Bright Red Apple',
  413. 'created' => '2006-11-22 10:43:13',
  414. 'date' => '2014-01-01',
  415. 'modified' => '2006-11-30 18:38:10',
  416. 'mytime' => '22:57:17',
  417. 'Parent' => array(
  418. 'id' => 1,
  419. 'apple_id' => 2,
  420. 'color' => 'Red 1',
  421. 'name' => 'Red Apple 1',
  422. 'created' => '2006-11-22 10:38:58',
  423. 'date' => '1951-01-04',
  424. 'modified' => '2006-12-01 13:31:26',
  425. 'mytime' => '22:57:17'
  426. ),
  427. 'Sample' => array(
  428. 'id' => 2,
  429. 'apple_id' => 2,
  430. 'name' => 'sample2'
  431. ),
  432. 'Child' => array(
  433. array(
  434. 'id' => 1,
  435. 'apple_id' => 2,
  436. 'color' => 'Red 1',
  437. 'name' => 'Red Apple 1',
  438. 'created' => '2006-11-22 10:38:58',
  439. 'date' => '1951-01-04',
  440. 'modified' => '2006-12-01 13:31:26',
  441. 'mytime' => '22:57:17'
  442. ),
  443. array(
  444. 'id' => 3,
  445. 'apple_id' => 2,
  446. 'color' => 'blue green',
  447. 'name' => 'green blue',
  448. 'created' => '2006-12-25 05:13:36',
  449. 'date' => '2006-12-25',
  450. 'modified' => '2006-12-25 05:23:24',
  451. 'mytime' => '22:57:17'
  452. ),
  453. array(
  454. 'id' => 4,
  455. 'apple_id' => 2,
  456. 'color' => 'Blue Green',
  457. 'name' => 'Test Name',
  458. 'created' => '2006-12-25 05:23:36',
  459. 'date' => '2006-12-25',
  460. 'modified' => '2006-12-25 05:23:36',
  461. 'mytime' => '22:57:17'
  462. ))))),
  463. array(
  464. 'Apple' => array(
  465. 'id' => 2,
  466. 'apple_id' => 1,
  467. 'color' => 'Bright Red 1',
  468. 'name' => 'Bright Red Apple',
  469. 'created' => '2006-11-22 10:43:13',
  470. 'date' => '2014-01-01',
  471. 'modified' => '2006-11-30 18:38:10',
  472. 'mytime' => '22:57:17'
  473. ),
  474. 'Parent' => array(
  475. 'id' => 1,
  476. 'apple_id' => 2,
  477. 'color' => 'Red 1',
  478. 'name' => 'Red Apple 1',
  479. 'created' => '2006-11-22 10:38:58',
  480. 'date' => '1951-01-04',
  481. 'modified' => '2006-12-01 13:31:26',
  482. 'mytime' => '22:57:17',
  483. 'Parent' => array(
  484. 'id' => 2,
  485. 'apple_id' => 1,
  486. 'color' => 'Bright Red 1',
  487. 'name' => 'Bright Red Apple',
  488. 'created' => '2006-11-22 10:43:13',
  489. 'date' => '2014-01-01',
  490. 'modified' => '2006-11-30 18:38:10',
  491. 'mytime' => '22:57:17'
  492. ),
  493. 'Sample' => array(),
  494. 'Child' => array(
  495. array(
  496. 'id' => 2,
  497. 'apple_id' => 1,
  498. 'color' => 'Bright Red 1',
  499. 'name' => 'Bright Red Apple',
  500. 'created' => '2006-11-22 10:43:13',
  501. 'date' => '2014-01-01',
  502. 'modified' => '2006-11-30 18:38:10',
  503. 'mytime' => '22:57:17'
  504. ))),
  505. 'Sample' => array(
  506. 'id' => 2,
  507. 'apple_id' => 2,
  508. 'name' => 'sample2',
  509. 'Apple' => array(
  510. 'id' => 2,
  511. 'apple_id' => 1,
  512. 'color' => 'Bright Red 1',
  513. 'name' => 'Bright Red Apple',
  514. 'created' => '2006-11-22 10:43:13',
  515. 'date' => '2014-01-01',
  516. 'modified' => '2006-11-30 18:38:10',
  517. 'mytime' => '22:57:17'
  518. )),
  519. 'Child' => array(
  520. array(
  521. 'id' => 1,
  522. 'apple_id' => 2,
  523. 'color' => 'Red 1',
  524. 'name' => 'Red Apple 1',
  525. 'created' => '2006-11-22 10:38:58',
  526. 'date' => '1951-01-04',
  527. 'modified' => '2006-12-01 13:31:26',
  528. 'mytime' => '22:57:17',
  529. 'Parent' => array(
  530. 'id' => 2,
  531. 'apple_id' => 1,
  532. 'color' => 'Bright Red 1',
  533. 'name' => 'Bright Red Apple',
  534. 'created' => '2006-11-22 10:43:13',
  535. 'date' => '2014-01-01',
  536. 'modified' => '2006-11-30 18:38:10',
  537. 'mytime' => '22:57:17'
  538. ),
  539. 'Sample' => array(),
  540. 'Child' => array(
  541. array(
  542. 'id' => 2,
  543. 'apple_id' => 1,
  544. 'color' => 'Bright Red 1',
  545. 'name' => 'Bright Red Apple',
  546. 'created' => '2006-11-22 10:43:13',
  547. 'date' => '2014-01-01',
  548. 'modified' => '2006-11-30 18:38:10',
  549. 'mytime' => '22:57:17'
  550. ))),
  551. array(
  552. 'id' => 3,
  553. 'apple_id' => 2,
  554. 'color' => 'blue green',
  555. 'name' => 'green blue',
  556. 'created' => '2006-12-25 05:13:36',
  557. 'date' => '2006-12-25',
  558. 'modified' => '2006-12-25 05:23:24',
  559. 'mytime' => '22:57:17',
  560. 'Parent' => array(
  561. 'id' => 2,
  562. 'apple_id' => 1,
  563. 'color' => 'Bright Red 1',
  564. 'name' => 'Bright Red Apple',
  565. 'created' => '2006-11-22 10:43:13',
  566. 'date' => '2014-01-01',
  567. 'modified' => '2006-11-30 18:38:10',
  568. 'mytime' => '22:57:17'
  569. ),
  570. 'Sample' => array(
  571. 'id' => 1,
  572. 'apple_id' => 3,
  573. 'name' => 'sample1'
  574. )),
  575. array(
  576. 'id' => 4,
  577. 'apple_id' => 2,
  578. 'color' => 'Blue Green',
  579. 'name' => 'Test Name',
  580. 'created' => '2006-12-25 05:23:36',
  581. 'date' => '2006-12-25',
  582. 'modified' => '2006-12-25 05:23:36',
  583. 'mytime' => '22:57:17',
  584. 'Parent' => array(
  585. 'id' => 2,
  586. 'apple_id' => 1,
  587. 'color' => 'Bright Red 1',
  588. 'name' => 'Bright Red Apple',
  589. 'created' => '2006-11-22 10:43:13',
  590. 'date' => '2014-01-01',
  591. 'modified' => '2006-11-30 18:38:10',
  592. 'mytime' => '22:57:17'
  593. ),
  594. 'Sample' => array(
  595. 'id' => 3,
  596. 'apple_id' => 4,
  597. 'name' => 'sample3'
  598. ),
  599. 'Child' => array(
  600. array(
  601. 'id' => 6,
  602. 'apple_id' => 4,
  603. 'color' => 'My new appleOrange',
  604. 'name' => 'My new apple',
  605. 'created' => '2006-12-25 05:29:39',
  606. 'date' => '2006-12-25',
  607. 'modified' => '2006-12-25 05:29:39',
  608. 'mytime' => '22:57:17'
  609. ))))),
  610. array(
  611. 'Apple' => array(
  612. 'id' => 3,
  613. 'apple_id' => 2,
  614. 'color' => 'blue green',
  615. 'name' => 'green blue',
  616. 'created' => '2006-12-25 05:13:36',
  617. 'date' => '2006-12-25',
  618. 'modified' => '2006-12-25 05:23:24',
  619. 'mytime' => '22:57:17'
  620. ),
  621. 'Parent' => array(
  622. 'id' => 2,
  623. 'apple_id' => 1,
  624. 'color' => 'Bright Red 1',
  625. 'name' => 'Bright Red Apple',
  626. 'created' => '2006-11-22 10:43:13',
  627. 'date' => '2014-01-01',
  628. 'modified' => '2006-11-30 18:38:10',
  629. 'mytime' => '22:57:17',
  630. 'Parent' => array(
  631. 'id' => 1,
  632. 'apple_id' => 2,
  633. 'color' => 'Red 1',
  634. 'name' => 'Red Apple 1',
  635. 'created' => '2006-11-22 10:38:58',
  636. 'date' => '1951-01-04',
  637. 'modified' => '2006-12-01 13:31:26',
  638. 'mytime' => '22:57:17'
  639. ),
  640. 'Sample' => array(
  641. 'id' => 2,
  642. 'apple_id' => 2,
  643. 'name' => 'sample2'
  644. ),
  645. 'Child' => array(
  646. array(
  647. 'id' => 1,
  648. 'apple_id' => 2,
  649. 'color' => 'Red 1',
  650. 'name' => 'Red Apple 1',
  651. 'created' => '2006-11-22 10:38:58',
  652. 'date' => '1951-01-04',
  653. 'modified' => '2006-12-01 13:31:26',
  654. 'mytime' => '22:57:17'
  655. ),
  656. array(
  657. 'id' => 3,
  658. 'apple_id' => 2,
  659. 'color' => 'blue green',
  660. 'name' => 'green blue',
  661. 'created' => '2006-12-25 05:13:36',
  662. 'date' => '2006-12-25',
  663. 'modified' => '2006-12-25 05:23:24',
  664. 'mytime' => '22:57:17'
  665. ),
  666. array(
  667. 'id' => 4,
  668. 'apple_id' => 2,
  669. 'color' => 'Blue Green',
  670. 'name' => 'Test Name',
  671. 'created' => '2006-12-25 05:23:36',
  672. 'date' => '2006-12-25',
  673. 'modified' => '2006-12-25 05:23:36',
  674. 'mytime' => '22:57:17'
  675. ))),
  676. 'Sample' => array(
  677. 'id' => 1,
  678. 'apple_id' => 3,
  679. 'name' => 'sample1',
  680. 'Apple' => array(
  681. 'id' => 3,
  682. 'apple_id' => 2,
  683. 'color' => 'blue green',
  684. 'name' => 'green blue',
  685. 'created' => '2006-12-25 05:13:36',
  686. 'date' => '2006-12-25',
  687. 'modified' => '2006-12-25 05:23:24',
  688. 'mytime' => '22:57:17'
  689. )),
  690. 'Child' => array()
  691. ),
  692. array(
  693. 'Apple' => array(
  694. 'id' => 4,
  695. 'apple_id' => 2,
  696. 'color' => 'Blue Green',
  697. 'name' => 'Test Name',
  698. 'created' => '2006-12-25 05:23:36',
  699. 'date' => '2006-12-25',
  700. 'modified' => '2006-12-25 05:23:36',
  701. 'mytime' => '22:57:17'
  702. ),
  703. 'Parent' => array(
  704. 'id' => 2,
  705. 'apple_id' => 1,
  706. 'color' => 'Bright Red 1',
  707. 'name' => 'Bright Red Apple',
  708. 'created' => '2006-11-22 10:43:13',
  709. 'date' => '2014-01-01',
  710. 'modified' => '2006-11-30 18:38:10',
  711. 'mytime' => '22:57:17',
  712. 'Parent' => array(
  713. 'id' => 1,
  714. 'apple_id' => 2,
  715. 'color' => 'Red 1',
  716. 'name' => 'Red Apple 1',
  717. 'created' => '2006-11-22 10:38:58',
  718. 'date' => '1951-01-04',
  719. 'modified' => '2006-12-01 13:31:26', 'mytime' => '22:57:17'),
  720. 'Sample' => array('id' => 2, 'apple_id' => 2, 'name' => 'sample2'),
  721. 'Child' => array(
  722. array(
  723. 'id' => 1,
  724. 'apple_id' => 2,
  725. 'color' => 'Red 1',
  726. 'name' => 'Red Apple 1',
  727. 'created' => '2006-11-22 10:38:58',
  728. 'date' => '1951-01-04',
  729. 'modified' => '2006-12-01 13:31:26',
  730. 'mytime' => '22:57:17'
  731. ),
  732. array(
  733. 'id' => 3,
  734. 'apple_id' => 2,
  735. 'color' => 'blue green',
  736. 'name' => 'green blue',
  737. 'created' => '2006-12-25 05:13:36',
  738. 'date' => '2006-12-25',
  739. 'modified' => '2006-12-25 05:23:24',
  740. 'mytime' => '22:57:17'
  741. ),
  742. array(
  743. 'id' => 4,
  744. 'apple_id' => 2,
  745. 'color' => 'Blue Green',
  746. 'name' => 'Test Name',
  747. 'created' => '2006-12-25 05:23:36',
  748. 'date' => '2006-12-25',
  749. 'modified' => '2006-12-25 05:23:36',
  750. 'mytime' => '22:57:17'
  751. ))),
  752. 'Sample' => array(
  753. 'id' => 3,
  754. 'apple_id' => 4,
  755. 'name' => 'sample3',
  756. 'Apple' => array(
  757. 'id' => 4,
  758. 'apple_id' => 2,
  759. 'color' => 'Blue Green',
  760. 'name' => 'Test Name',
  761. 'created' => '2006-12-25 05:23:36',
  762. 'date' => '2006-12-25',
  763. 'modified' => '2006-12-25 05:23:36',
  764. 'mytime' => '22:57:17'
  765. )),
  766. 'Child' => array(
  767. array(
  768. 'id' => 6,
  769. 'apple_id' => 4,
  770. 'color' => 'My new appleOrange',
  771. 'name' => 'My new apple',
  772. 'created' => '2006-12-25 05:29:39',
  773. 'date' => '2006-12-25',
  774. 'modified' => '2006-12-25 05:29:39',
  775. 'mytime' => '22:57:17',
  776. 'Parent' => array(
  777. 'id' => 4,
  778. 'apple_id' => 2,
  779. 'color' => 'Blue Green',
  780. 'name' => 'Test Name',
  781. 'created' => '2006-12-25 05:23:36',
  782. 'date' => '2006-12-25',
  783. 'modified' => '2006-12-25 05:23:36',
  784. 'mytime' => '22:57:17'
  785. ),
  786. 'Sample' => array(),
  787. 'Child' => array(
  788. array(
  789. 'id' => 7,
  790. 'apple_id' => 6,
  791. 'color' => 'Some wierd color',
  792. 'name' => 'Some odd color',
  793. 'created' => '2006-12-25 05:34:21',
  794. 'date' => '2006-12-25',
  795. 'modified' => '2006-12-25 05:34:21',
  796. 'mytime' => '22:57:17'
  797. ))))),
  798. array(
  799. 'Apple' => array(
  800. 'id' => 5,
  801. 'apple_id' => 5,
  802. 'color' => 'Green',
  803. 'name' => 'Blue Green',
  804. 'created' => '2006-12-25 05:24:06',
  805. 'date' => '2006-12-25',
  806. 'modified' => '2006-12-25 05:29:16',
  807. 'mytime' => '22:57:17'
  808. ),
  809. 'Parent' => array(
  810. 'id' => 5,
  811. 'apple_id' => 5,
  812. 'color' => 'Green',
  813. 'name' => 'Blue Green',
  814. 'created' => '2006-12-25 05:24:06',
  815. 'date' => '2006-12-25',
  816. 'modified' => '2006-12-25 05:29:16',
  817. 'mytime' => '22:57:17',
  818. 'Parent' => array(
  819. 'id' => 5,
  820. 'apple_id' => 5,
  821. 'color' => 'Green',
  822. 'name' => 'Blue Green',
  823. 'created' => '2006-12-25 05:24:06',
  824. 'date' => '2006-12-25',
  825. 'modified' => '2006-12-25 05:29:16',
  826. 'mytime' => '22:57:17'
  827. ),
  828. 'Sample' => array(
  829. 'id' => 4,
  830. 'apple_id' => 5,
  831. 'name' => 'sample4'
  832. ),
  833. 'Child' => array(
  834. array(
  835. 'id' => 5,
  836. 'apple_id' => 5,
  837. 'color' => 'Green',
  838. 'name' => 'Blue Green',
  839. 'created' => '2006-12-25 05:24:06',
  840. 'date' => '2006-12-25',
  841. 'modified' => '2006-12-25 05:29:16',
  842. 'mytime' => '22:57:17'
  843. ))),
  844. 'Sample' => array(
  845. 'id' => 4,
  846. 'apple_id' => 5,
  847. 'name' => 'sample4',
  848. 'Apple' => array(
  849. 'id' => 5,
  850. 'apple_id' => 5,
  851. 'color' => 'Green',
  852. 'name' => 'Blue Green',
  853. 'created' => '2006-12-25 05:24:06',
  854. 'date' => '2006-12-25',
  855. 'modified' => '2006-12-25 05:29:16',
  856. 'mytime' => '22:57:17'
  857. )),
  858. 'Child' => array(
  859. array(
  860. 'id' => 5,
  861. 'apple_id' => 5,
  862. 'color' => 'Green',
  863. 'name' => 'Blue Green',
  864. 'created' => '2006-12-25 05:24:06',
  865. 'date' => '2006-12-25',
  866. 'modified' => '2006-12-25 05:29:16',
  867. 'mytime' => '22:57:17',
  868. 'Parent' => array(
  869. 'id' => 5,
  870. 'apple_id' => 5,
  871. 'color' => 'Green',
  872. 'name' => 'Blue Green',
  873. 'created' => '2006-12-25 05:24:06',
  874. 'date' => '2006-12-25',
  875. 'modified' => '2006-12-25 05:29:16',
  876. 'mytime' => '22:57:17'
  877. ),
  878. 'Sample' => array(
  879. 'id' => 4,
  880. 'apple_id' => 5,
  881. 'name' => 'sample4'
  882. ),
  883. 'Child' => array(
  884. array(
  885. 'id' => 5,
  886. 'apple_id' => 5,
  887. 'color' => 'Green',
  888. 'name' => 'Blue Green',
  889. 'created' => '2006-12-25 05:24:06',
  890. 'date' => '2006-12-25',
  891. 'modified' => '2006-12-25 05:29:16',
  892. 'mytime' => '22:57:17'
  893. ))))),
  894. array(
  895. 'Apple' => array(
  896. 'id' => 6,
  897. 'apple_id' => 4,
  898. 'color' => 'My new appleOrange',
  899. 'name' => 'My new apple',
  900. 'created' => '2006-12-25 05:29:39',
  901. 'date' => '2006-12-25',
  902. 'modified' => '2006-12-25 05:29:39',
  903. 'mytime' => '22:57:17'
  904. ),
  905. 'Parent' => array(
  906. 'id' => 4,
  907. 'apple_id' => 2,
  908. 'color' => 'Blue Green',
  909. 'name' => 'Test Name',
  910. 'created' => '2006-12-25 05:23:36',
  911. 'date' => '2006-12-25',
  912. 'modified' => '2006-12-25 05:23:36',
  913. 'mytime' => '22:57:17',
  914. 'Parent' => array(
  915. 'id' => 2,
  916. 'apple_id' => 1,
  917. 'color' => 'Bright Red 1',
  918. 'name' => 'Bright Red Apple',
  919. 'created' => '2006-11-22 10:43:13',
  920. 'date' => '2014-01-01',
  921. 'modified' => '2006-11-30 18:38:10',
  922. 'mytime' => '22:57:17'
  923. ),
  924. 'Sample' => array(
  925. 'id' => 3,
  926. 'apple_id' => 4,
  927. 'name' => 'sample3'
  928. ),
  929. 'Child' => array(
  930. array(
  931. 'id' => 6,
  932. 'apple_id' => 4,
  933. 'color' => 'My new appleOrange',
  934. 'name' => 'My new apple',
  935. 'created' => '2006-12-25 05:29:39',
  936. 'date' => '2006-12-25',
  937. 'modified' => '2006-12-25 05:29:39',
  938. 'mytime' => '22:57:17'
  939. ))),
  940. 'Sample' => array(
  941. 'id' => '',
  942. 'apple_id' => '',
  943. 'name' => ''
  944. ),
  945. 'Child' => array(
  946. array(
  947. 'id' => 7,
  948. 'apple_id' => 6,
  949. 'color' => 'Some wierd color',
  950. 'name' => 'Some odd color',
  951. 'created' => '2006-12-25 05:34:21',
  952. 'date' => '2006-12-25',
  953. 'modified' => '2006-12-25 05:34:21',
  954. 'mytime' => '22:57:17',
  955. 'Parent' => array(
  956. 'id' => 6,
  957. 'apple_id' => 4,
  958. 'color' => 'My new appleOrange',
  959. 'name' => 'My new apple',
  960. 'created' => '2006-12-25 05:29:39',
  961. 'date' => '2006-12-25',
  962. 'modified' => '2006-12-25 05:29:39',
  963. 'mytime' => '22:57:17'
  964. ),
  965. 'Sample' => array()
  966. ))),
  967. array(
  968. 'Apple' => array(
  969. 'id' => 7,
  970. 'apple_id' => 6,
  971. 'color' =>
  972. 'Some wierd color',
  973. 'name' => 'Some odd color',
  974. 'created' => '2006-12-25 05:34:21',
  975. 'date' => '2006-12-25',
  976. 'modified' => '2006-12-25 05:34:21',
  977. 'mytime' => '22:57:17'
  978. ),
  979. 'Parent' => array(
  980. 'id' => 6,
  981. 'apple_id' => 4,
  982. 'color' => 'My new appleOrange',
  983. 'name' => 'My new apple',
  984. 'created' => '2006-12-25 05:29:39',
  985. 'date' => '2006-12-25',
  986. 'modified' => '2006-12-25 05:29:39',
  987. 'mytime' => '22:57:17',
  988. 'Parent' => array(
  989. 'id' => 4,
  990. 'apple_id' => 2,
  991. 'color' => 'Blue Green',
  992. 'name' => 'Test Name',
  993. 'created' => '2006-12-25 05:23:36',
  994. 'date' => '2006-12-25',
  995. 'modified' => '2006-12-25 05:23:36',
  996. 'mytime' => '22:57:17'
  997. ),
  998. 'Sample' => array(),
  999. 'Child' => array(
  1000. array(
  1001. 'id' => 7,
  1002. 'apple_id' => 6,
  1003. 'color' => 'Some wierd color',
  1004. 'name' => 'Some odd color',
  1005. 'created' => '2006-12-25 05:34:21',
  1006. 'date' => '2006-12-25',
  1007. 'modified' => '2006-12-25 05:34:21',
  1008. 'mytime' => '22:57:17'
  1009. ))),
  1010. 'Sample' => array(
  1011. 'id' => '',
  1012. 'apple_id' => '',
  1013. 'name' => ''
  1014. ),
  1015. 'Child' => array()));
  1016. $this->assertEquals($expected, $result);
  1017. $result = $TestModel->Parent->unbindModel(array('hasOne' => array('Sample')));
  1018. $this->assertTrue($result);
  1019. $result = $TestModel->find('all');
  1020. $expected = array(
  1021. array(
  1022. 'Apple' => array(
  1023. 'id' => 1,
  1024. 'apple_id' => 2,
  1025. 'color' => 'Red 1',
  1026. 'name' => 'Red Apple 1',
  1027. 'created' => '2006-11-22 10:38:58',
  1028. 'date' => '1951-01-04',
  1029. 'modified' => '2006-12-01 13:31:26',
  1030. 'mytime' => '22:57:17'),
  1031. 'Parent' => array(
  1032. 'id' => 2,
  1033. 'apple_id' => 1,
  1034. 'color' => 'Bright Red 1',
  1035. 'name' => 'Bright Red Apple',
  1036. 'created' => '2006-11-22 10:43:13',
  1037. 'date' => '2014-01-01',
  1038. 'modified' => '2006-11-30 18:38:10',
  1039. 'mytime' => '22:57:17',
  1040. 'Parent' => array(
  1041. 'id' => 1,
  1042. 'apple_id' => 2,
  1043. 'color' => 'Red 1',
  1044. 'name' => 'Red Apple 1',
  1045. 'created' => '2006-11-22 10:38:58',
  1046. 'date' => '1951-01-04',
  1047. 'modified' => '2006-12-01 13:31:26',
  1048. 'mytime' => '22:57:17'
  1049. ),
  1050. 'Child' => array(
  1051. array(
  1052. 'id' => 1,
  1053. 'apple_id' => 2,
  1054. 'color' => 'Red 1',
  1055. 'name' => 'Red Apple 1',
  1056. 'created' => '2006-11-22 10:38:58',
  1057. 'date' => '1951-01-04',
  1058. 'modified' => '2006-12-01 13:31:26',
  1059. 'mytime' => '22:57:17'
  1060. ),
  1061. array(
  1062. 'id' => 3,
  1063. 'apple_id' => 2,
  1064. 'color' => 'blue green',
  1065. 'name' => 'green blue',
  1066. 'created' => '2006-12-25 05:13:36',
  1067. 'date' => '2006-12-25',
  1068. 'modified' => '2006-12-25 05:23:24',
  1069. 'mytime' => '22:57:17'
  1070. ),
  1071. array(
  1072. 'id' => 4,
  1073. 'apple_id' => 2,
  1074. 'color' => 'Blue Green',
  1075. 'name' => 'Test Name',
  1076. 'created' => '2006-12-25 05:23:36',
  1077. 'date' => '2006-12-25',
  1078. 'modified' => '2006-12-25 05:23:36',
  1079. 'mytime' => '22:57:17'
  1080. ))),
  1081. 'Sample' => array(
  1082. 'id' => '',
  1083. 'apple_id' => '',
  1084. 'name' => ''
  1085. ),
  1086. 'Child' => array(
  1087. array(
  1088. 'id' => 2,
  1089. 'apple_id' => 1,
  1090. 'color' => 'Bright Red 1',
  1091. 'name' => 'Bright Red Apple',
  1092. 'created' => '2006-11-22 10:43:13',
  1093. 'date' => '2014-01-01',
  1094. 'modified' => '2006-11-30 18:38:10',
  1095. 'mytime' => '22:57:17',
  1096. 'Parent' => array(
  1097. 'id' => 1,
  1098. 'apple_id' => 2,
  1099. 'color' => 'Red 1',
  1100. 'name' => 'Red Apple 1',
  1101. 'created' => '2006-11-22 10:38:58',
  1102. 'date' => '1951-01-04',
  1103. 'modified' => '2006-12-01 13:31:26',
  1104. 'mytime' => '22:57:17'
  1105. ),
  1106. 'Sample' => array(
  1107. 'id' => 2,
  1108. 'apple_id' => 2,
  1109. 'name' => 'sample2'
  1110. ),
  1111. 'Child' => array(
  1112. array(
  1113. 'id' => 1,
  1114. 'apple_id' => 2,
  1115. 'color' => 'Red 1',
  1116. 'name' => 'Red Apple 1',
  1117. 'created' => '2006-11-22 10:38:58',
  1118. 'date' => '1951-01-04',
  1119. 'modified' => '2006-12-01 13:31:26',
  1120. 'mytime' => '22:57:17'
  1121. ),
  1122. array(
  1123. 'id' => 3,
  1124. 'apple_id' => 2,
  1125. 'color' => 'blue green',
  1126. 'name' => 'green blue',
  1127. 'created' => '2006-12-25 05:13:36',
  1128. 'date' => '2006-12-25',
  1129. 'modified' => '2006-12-25 05:23:24',
  1130. 'mytime' => '22:57:17'
  1131. ),
  1132. array(
  1133. 'id' => 4,
  1134. 'apple_id' => 2,
  1135. 'color' => 'Blue Green',
  1136. 'name' => 'Test Name',
  1137. 'created' => '2006-12-25 05:23:36',
  1138. 'date' => '2006-12-25',
  1139. 'modified' => '2006-12-25 05:23:36',
  1140. 'mytime' => '22:57:17'
  1141. ))))),
  1142. array(
  1143. 'Apple' => array(
  1144. 'id' => 2,
  1145. 'apple_id' => 1,
  1146. 'color' => 'Bright Red 1',
  1147. 'name' => 'Bright Red Apple',
  1148. 'created' => '2006-11-22 10:43:13',
  1149. 'date' => '2014-01-01',
  1150. 'modified' => '2006-11-30 18:38:10',
  1151. 'mytime' => '22:57:17'
  1152. ),
  1153. 'Parent' => array(
  1154. 'id' => 1,
  1155. 'apple_id' => 2,
  1156. 'color' => 'Red 1',
  1157. 'name' => 'Red Apple 1',
  1158. 'created' => '2006-11-22 10:38:58',
  1159. 'date' => '1951-01-04',
  1160. 'modified' => '2006-12-01 13:31:26',
  1161. 'mytime' => '22:57:17',
  1162. 'Parent' => array(
  1163. 'id' => 2,
  1164. 'apple_id' => 1,
  1165. 'color' => 'Bright Red 1',
  1166. 'name' => 'Bright Red Apple',
  1167. 'created' => '2006-11-22 10:43:13',
  1168. 'date' => '2014-01-01',
  1169. 'modified' => '2006-11-30 18:38:10',
  1170. 'mytime' => '22:57:17'
  1171. ),
  1172. 'Child' => array(
  1173. array(
  1174. 'id' => 2,
  1175. 'apple_id' => 1,
  1176. 'color' => 'Bright Red 1',
  1177. 'name' => 'Bright Red Apple',
  1178. 'created' => '2006-11-22 10:43:13',
  1179. 'date' => '2014-01-01',
  1180. 'modified' => '2006-11-30 18:38:10',
  1181. 'mytime' => '22:57:17'
  1182. ))),
  1183. 'Sample' => array(
  1184. 'id' => 2,
  1185. 'apple_id' => 2,
  1186. 'name' => 'sample2',
  1187. 'Apple' => array(
  1188. 'id' => 2,
  1189. 'apple_id' => 1,
  1190. 'color' => 'Bright Red 1',
  1191. 'name' => 'Bright Red Apple',
  1192. 'created' => '2006-11-22 10:43:13',
  1193. 'date' => '2014-01-01',
  1194. 'modified' => '2006-11-30 18:38:10',
  1195. 'mytime' => '22:57:17'
  1196. )),
  1197. 'Child' => array(
  1198. array(
  1199. 'id' => 1,
  1200. 'apple_id' => 2,
  1201. 'color' => 'Red 1',
  1202. 'name' => 'Red Apple 1',
  1203. 'created' => '2006-11-22 10:38:58',
  1204. 'date' => '1951-01-04',
  1205. 'modified' => '2006-12-01 13:31:26',
  1206. 'mytime' => '22:57:17',
  1207. 'Parent' => array(
  1208. 'id' => 2,
  1209. 'apple_id' => 1,
  1210. 'color' => 'Bright Red 1',
  1211. 'name' => 'Bright Red Apple',
  1212. 'created' => '2006-11-22 10:43:13',
  1213. 'date' => '2014-01-01',
  1214. 'modified' => '2006-11-30 18:38:10',
  1215. 'mytime' => '22:57:17'
  1216. ),
  1217. 'Sample' => array(),
  1218. 'Child' => array(
  1219. array(
  1220. 'id' => 2,
  1221. 'apple_id' => 1,
  1222. 'color' => 'Bright Red 1',
  1223. 'name' => 'Bright Red Apple',
  1224. 'created' => '2006-11-22 10:43:13',
  1225. 'date' => '2014-01-01', 'modified' =>
  1226. '2006-11-30 18:38:10',
  1227. 'mytime' => '22:57:17'
  1228. ))),
  1229. array(
  1230. 'id' => 3,
  1231. 'apple_id' => 2,
  1232. 'color' => 'blue green',
  1233. 'name' => 'green blue',
  1234. 'created' => '2006-12-25 05:13:36',
  1235. 'date' => '2006-12-25',
  1236. 'modified' => '2006-12-25 05:23:24',
  1237. 'mytime' => '22:57:17',
  1238. 'Parent' => array(
  1239. 'id' => 2,
  1240. 'apple_id' => 1,
  1241. 'color' => 'Bright Red 1',
  1242. 'name' => 'Bright Red Apple',
  1243. 'created' => '2006-11-22 10:43:13',
  1244. 'date' => '2014-01-01',
  1245. 'modified' => '2006-11-30 18:38:10',
  1246. 'mytime' => '22:57:17'
  1247. ),
  1248. 'Sample' => array(
  1249. 'id' => 1,
  1250. 'apple_id' => 3,
  1251. 'name' => 'sample1'
  1252. )),
  1253. array(
  1254. 'id' => 4,
  1255. 'apple_id' => 2,
  1256. 'color' => 'Blue Green',
  1257. 'name' => 'Test Name',
  1258. 'created' => '2006-12-25 05:23:36',
  1259. 'date' => '2006-12-25',
  1260. 'modified' => '2006-12-25 05:23:36',
  1261. 'mytime' => '22:57:17',
  1262. 'Parent' => array(
  1263. 'id' => 2,
  1264. 'apple_id' => 1,
  1265. 'color' => 'Bright Red 1',
  1266. 'name' => 'Bright Red Apple',
  1267. 'created' => '2006-11-22 10:43:13',
  1268. 'date' => '2014-01-01',
  1269. 'modified' => '2006-11-30 18:38:10',
  1270. 'mytime' => '22:57:17'
  1271. ),
  1272. 'Sample' => array(
  1273. 'id' => 3,
  1274. 'apple_id' => 4,
  1275. 'name' => 'sample3'
  1276. ),
  1277. 'Child' => array(
  1278. array(
  1279. 'id' => 6,
  1280. 'apple_id' => 4,
  1281. 'color' => 'My new appleOrange',
  1282. 'name' => 'My new apple',
  1283. 'created' => '2006-12-25 05:29:39',
  1284. 'date' => '2006-12-25',
  1285. 'modified' => '2006-12-25 05:29:39',
  1286. 'mytime' => '22:57:17'
  1287. ))))),
  1288. array(
  1289. 'Apple' => array(
  1290. 'id' => 3,
  1291. 'apple_id' => 2,
  1292. 'color' => 'blue green',
  1293. 'name' => 'green blue',
  1294. 'created' => '2006-12-25 05:13:36',
  1295. 'date' => '2006-12-25',
  1296. 'modified' => '2006-12-25 05:23:24',
  1297. 'mytime' => '22:57:17'
  1298. ),
  1299. 'Parent' => array(
  1300. 'id' => 2,
  1301. 'apple_id' => 1,
  1302. 'color' => 'Bright Red 1',
  1303. 'name' => 'Bright Red Apple',
  1304. 'created' => '2006-11-22 10:43:13',
  1305. 'date' => '2014-01-01',
  1306. 'modified' => '2006-11-30 18:38:10',
  1307. 'mytime' => '22:57:17',
  1308. 'Parent' => array(
  1309. 'id' => 1,
  1310. 'apple_id' => 2,
  1311. 'color' => 'Red 1',
  1312. 'name' => 'Red Apple 1',
  1313. 'created' => '2006-11-22 10:38:58',
  1314. 'date' => '1951-01-04',
  1315. 'modified' => '2006-12-01 13:31:26',
  1316. 'mytime' => '22:57:17'
  1317. ),
  1318. 'Child' => array(
  1319. array(
  1320. 'id' => 1,
  1321. 'apple_id' => 2,
  1322. 'color' => 'Red 1',
  1323. 'name' => 'Red Apple 1',
  1324. 'created' => '2006-11-22 10:38:58',
  1325. 'date' => '1951-01-04',
  1326. 'modified' => '2006-12-01 13:31:26',
  1327. 'mytime' => '22:57:17'
  1328. ),
  1329. array(
  1330. 'id' => 3,
  1331. 'apple_id' => 2,
  1332. 'color' => 'blue green',
  1333. 'name' => 'green blue',
  1334. 'created' => '2006-12-25 05:13:36',
  1335. 'date' => '2006-12-25',
  1336. 'modified' => '2006-12-25 05:23:24',
  1337. 'mytime' => '22:57:17'
  1338. ),
  1339. array(
  1340. 'id' => 4,
  1341. 'apple_id' => 2,
  1342. 'color' => 'Blue Green',
  1343. 'name' => 'Test Name',
  1344. 'created' => '2006-12-25 05:23:36',
  1345. 'date' => '2006-12-25',
  1346. 'modified' => '2006-12-25 05:23:36',
  1347. 'mytime' => '22:57:17'
  1348. ))),
  1349. 'Sample' => array(
  1350. 'id' => 1,
  1351. 'apple_id' => 3,
  1352. 'name' => 'sample1',
  1353. 'Apple' => array(
  1354. 'id' => 3,
  1355. 'apple_id' => 2,
  1356. 'color' => 'blue green',
  1357. 'name' => 'green blue',
  1358. 'created' => '2006-12-25 05:13:36',
  1359. 'date' => '2006-12-25',
  1360. 'modified' => '2006-12-25 05:23:24',
  1361. 'mytime' => '22:57:17'
  1362. )),
  1363. 'Child' => array()
  1364. ),
  1365. array(
  1366. 'Apple' => array(
  1367. 'id' => 4,
  1368. 'apple_id' => 2,
  1369. 'color' => 'Blue Green',
  1370. 'name' => 'Test Name',
  1371. 'created' => '2006-12-25 05:23:36',
  1372. 'date' => '2006-12-25',
  1373. 'modified' => '2006-12-25 05:23:36',
  1374. 'mytime' => '22:57:17'
  1375. ),
  1376. 'Parent' => array(
  1377. 'id' => 2,
  1378. 'apple_id' => 1,
  1379. 'color' => 'Bright Red 1',
  1380. 'name' => 'Bright Red Apple',
  1381. 'created' => '2006-11-22 10:43:13',
  1382. 'date' => '2014-01-01',
  1383. 'modified' => '2006-11-30 18:38:10',
  1384. 'mytime' => '22:57:17',
  1385. 'Parent' => array(
  1386. 'id' => 1,
  1387. 'apple_id' => 2,
  1388. 'color' => 'Red 1',
  1389. 'name' => 'Red Apple 1',
  1390. 'created' => '2006-11-22 10:38:58',
  1391. 'date' => '1951-01-04',
  1392. 'modified' => '2006-12-01 13:31:26',
  1393. 'mytime' => '22:57:17'
  1394. ),
  1395. 'Child' => array(
  1396. array(
  1397. 'id' => 1,
  1398. 'apple_id' => 2,
  1399. 'color' => 'Red 1',
  1400. 'name' => 'Red Apple 1',
  1401. 'created' => '2006-11-22 10:38:58',
  1402. 'date' => '1951-01-04',
  1403. 'modified' => '2006-12-01 13:31:26',
  1404. 'mytime' => '22:57:17'
  1405. ),
  1406. array(
  1407. 'id' => 3,
  1408. 'apple_id' => 2,
  1409. 'color' => 'blue green',
  1410. 'name' => 'green blue',
  1411. 'created' => '2006-12-25 05:13:36',
  1412. 'date' => '2006-12-25',
  1413. 'modified' => '2006-12-25 05:23:24',
  1414. 'mytime' => '22:57:17'
  1415. ),
  1416. array(
  1417. 'id' => 4,
  1418. 'apple_id' => 2,
  1419. 'color' => 'Blue Green',
  1420. 'name' => 'Test Name',
  1421. 'created' => '2006-12-25 05:23:36',
  1422. 'date' => '2006-12-25',
  1423. 'modified' => '2006-12-25 05:23:36',
  1424. 'mytime' => '22:57:17'
  1425. ))),
  1426. 'Sample' => array(
  1427. 'id' => 3,
  1428. 'apple_id' => 4,
  1429. 'name' => 'sample3',
  1430. 'Apple' => array(
  1431. 'id' => 4,
  1432. 'apple_id' => 2,
  1433. 'color' => 'Blue Green',
  1434. 'name' => 'Test Name',
  1435. 'created' => '2006-12-25 05:23:36',
  1436. 'date' => '2006-12-25',
  1437. 'modified' => '2006-12-25 05:23:36',
  1438. 'mytime' => '22:57:17'
  1439. )),
  1440. 'Child' => array(
  1441. array(
  1442. 'id' => 6,
  1443. 'apple_id' => 4,
  1444. 'color' => 'My new appleOrange',
  1445. 'name' => 'My new apple',
  1446. 'created' => '2006-12-25 05:29:39',
  1447. 'date' => '2006-12-25',
  1448. 'modified' => '2006-12-25 05:29:39',
  1449. 'mytime' => '22:57:17',
  1450. 'Parent' => array(
  1451. 'id' => 4,
  1452. 'apple_id' => 2,
  1453. 'color' => 'Blue Green',
  1454. 'name' => 'Test Name',
  1455. 'created' => '2006-12-25 05:23:36',
  1456. 'date' => '2006-12-25',
  1457. 'modified' => '2006-12-25 05:23:36',
  1458. 'mytime' => '22:57:17'
  1459. ),
  1460. 'Sample' => array(),
  1461. 'Child' => array(
  1462. array(
  1463. 'id' => 7,
  1464. 'apple_id' => 6,
  1465. 'color' => 'Some wierd color',
  1466. 'name' => 'Some odd color',
  1467. 'created' => '2006-12-25 05:34:21',
  1468. 'date' => '2006-12-25',
  1469. 'modified' => '2006-12-25 05:34:21',
  1470. 'mytime' => '22:57:17'
  1471. ))))),
  1472. array(
  1473. 'Apple' => array(
  1474. 'id' => 5,
  1475. 'apple_id' => 5,
  1476. 'color' => 'Green',
  1477. 'name' => 'Blue Green',
  1478. 'created' => '2006-12-25 05:24:06',
  1479. 'date' => '2006-12-25',
  1480. 'modified' => '2006-12-25 05:29:16',
  1481. 'mytime' => '22:57:17'
  1482. ),
  1483. 'Parent' => array(
  1484. 'id' => 5,
  1485. 'apple_id' => 5,
  1486. 'color' => 'Green',
  1487. 'name' => 'Blue Green',
  1488. 'created' => '2006-12-25 05:24:06',
  1489. 'date' => '2006-12-25',
  1490. 'modified' => '2006-12-25 05:29:16',
  1491. 'mytime' => '22:57:17',
  1492. 'Parent' => array(
  1493. 'id' => 5,
  1494. 'apple_id' => 5,
  1495. 'color' => 'Green',
  1496. 'name' => 'Blue Green',
  1497. 'created' => '2006-12-25 05:24:06',
  1498. 'date' => '2006-12-25',
  1499. 'modified' => '2006-12-25 05:29:16',
  1500. 'mytime' => '22:57:17'
  1501. ),
  1502. 'Child' => array(
  1503. array(
  1504. 'id' => 5,
  1505. 'apple_id' => 5,
  1506. 'color' => 'Green',
  1507. 'name' => 'Blue Green',
  1508. 'created' => '2006-12-25 05:24:06',
  1509. 'date' => '2006-12-25',
  1510. 'modified' => '2006-12-25 05:29:16',
  1511. 'mytime' => '22:57:17'
  1512. ))),
  1513. 'Sample' => array(
  1514. 'id' => 4,
  1515. 'apple_id' => 5,
  1516. 'name' => 'sample4',
  1517. 'Apple' => array(
  1518. 'id' => 5,
  1519. 'apple_id' => 5,
  1520. 'color' => 'Green',
  1521. 'name' => 'Blue Green',
  1522. 'created' => '2006-12-25 05:24:06',
  1523. 'date' => '2006-12-25',
  1524. 'modified' => '2006-12-25 05:29:16',
  1525. 'mytime' => '22:57:17'
  1526. )),
  1527. 'Child' => array(
  1528. array(
  1529. 'id' => 5,
  1530. 'apple_id' => 5,
  1531. 'color' => 'Green',
  1532. 'name' => 'Blue Green',
  1533. 'created' => '2006-12-25 05:24:06',
  1534. 'date' => '2006-12-25',
  1535. 'modified' => '2006-12-25 05:29:16',
  1536. 'mytime' => '22:57:17',
  1537. 'Parent' => array(
  1538. 'id' => 5,
  1539. 'apple_id' => 5,
  1540. 'color' => 'Green',
  1541. 'name' => 'Blue Green',
  1542. 'created' => '2006-12-25 05:24:06',
  1543. 'date' => '2006-12-25',
  1544. 'modified' => '2006-12-25 05:29:16',
  1545. 'mytime' => '22:57:17'
  1546. ),
  1547. 'Sample' => array(
  1548. 'id' => 4,
  1549. 'apple_id' => 5,
  1550. 'name' => 'sample4'
  1551. ),
  1552. 'Child' => array(
  1553. array(
  1554. 'id' => 5,
  1555. 'apple_id' => 5,
  1556. 'color' => 'Green',
  1557. 'name' => 'Blue Green',
  1558. 'created' => '2006-12-25 05:24:06',
  1559. 'date' => '2006-12-25',
  1560. 'modified' => '2006-12-25 05:29:16',
  1561. 'mytime' => '22:57:17'
  1562. ))))),
  1563. array(
  1564. 'Apple' => array(
  1565. 'id' => 6,
  1566. 'apple_id' => 4,
  1567. 'color' => 'My new appleOrange',
  1568. 'name' => 'My new apple',
  1569. 'created' => '2006-12-25 05:29:39',
  1570. 'date' => '2006-12-25',
  1571. 'modified' => '2006-12-25 05:29:39',
  1572. 'mytime' => '22:57:17'
  1573. ),
  1574. 'Parent' => array(
  1575. 'id' => 4,
  1576. 'apple_id' => 2,
  1577. 'color' => 'Blue Green',
  1578. 'name' => 'Test Name',
  1579. 'created' => '2006-12-25 05:23:36',
  1580. 'date' => '2006-12-25',
  1581. 'modified' => '2006-12-25 05:23:36',
  1582. 'mytime' => '22:57:17',
  1583. 'Parent' => array(
  1584. 'id' => 2,
  1585. 'apple_id' => 1,
  1586. 'color' => 'Bright Red 1',
  1587. 'name' => 'Bright Red Apple',
  1588. 'created' => '2006-11-22 10:43:13',
  1589. 'date' => '2014-01-01',
  1590. 'modified' => '2006-11-30 18:38:10',
  1591. 'mytime' => '22:57:17'
  1592. ),
  1593. 'Child' => array(
  1594. array(
  1595. 'id' => 6,
  1596. 'apple_id' => 4,
  1597. 'color' => 'My new appleOrange',
  1598. 'name' => 'My new apple',
  1599. 'created' => '2006-12-25 05:29:39',
  1600. 'date' => '2006-12-25',
  1601. 'modified' => '2006-12-25 05:29:39',
  1602. 'mytime' => '22:57:17'
  1603. ))),
  1604. 'Sample' => array(
  1605. 'id' => '',
  1606. 'apple_id' => '',
  1607. 'name' => ''
  1608. ),
  1609. 'Child' => array(
  1610. array(
  1611. 'id' => 7,
  1612. 'apple_id' => 6,
  1613. 'color' => 'Some wierd color',
  1614. 'name' => 'Some odd color',
  1615. 'created' => '2006-12-25 05:34:21',
  1616. 'date' => '2006-12-25',
  1617. 'modified' => '2006-12-25 05:34:21',
  1618. 'mytime' => '22:57:17',
  1619. 'Parent' => array(
  1620. 'id' => 6,
  1621. 'apple_id' => 4,
  1622. 'color' => 'My new appleOrange',
  1623. 'name' => 'My new apple',
  1624. 'created' => '2006-12-25 05:29:39',
  1625. 'date' => '2006-12-25',
  1626. 'modified' => '2006-12-25 05:29:39',
  1627. 'mytime' => '22:57:17'
  1628. ),
  1629. 'Sample' => array()
  1630. ))),
  1631. array(
  1632. 'Apple' => array(
  1633. 'id' => 7,
  1634. 'apple_id' => 6,
  1635. 'color' => 'Some wierd color',
  1636. 'name' => 'Some odd color',
  1637. 'created' => '2006-12-25 05:34:21',
  1638. 'date' => '2006-12-25',
  1639. 'modified' => '2006-12-25 05:34:21',
  1640. 'mytime' => '22:57:17'
  1641. ),
  1642. 'Parent' => array(
  1643. 'id' => 6,
  1644. 'apple_id' => 4,
  1645. 'color' => 'My new appleOrange',
  1646. 'name' => 'My new apple',
  1647. 'created' => '2006-12-25 05:29:39',
  1648. 'date' => '2006-12-25',
  1649. 'modified' => '2006-12-25 05:29:39',
  1650. 'mytime' => '22:57:17',
  1651. 'Parent' => array(
  1652. 'id' => 4,
  1653. 'apple_id' => 2,
  1654. 'color' => 'Blue Green',
  1655. 'name' => 'Test Name',
  1656. 'created' => '2006-12-25 05:23:36',
  1657. 'date' => '2006-12-25',
  1658. 'modified' => '2006-12-25 05:23:36',
  1659. 'mytime' => '22:57:17'
  1660. ),
  1661. 'Child' => array(
  1662. array(
  1663. 'id' => 7,
  1664. 'apple_id' => 6,
  1665. 'color' => 'Some wierd color',
  1666. 'name' => 'Some odd color',
  1667. 'created' => '2006-12-25 05:34:21',
  1668. 'date' => '2006-12-25',
  1669. 'modified' => '2006-12-25 05:34:21',
  1670. 'mytime' => '22:57:17'
  1671. ))),
  1672. 'Sample' => array(
  1673. 'id' => '',
  1674. 'apple_id' => '',
  1675. 'name' => ''
  1676. ),
  1677. 'Child' => array()
  1678. ));
  1679. $this->assertEquals($expected, $result);
  1680. $result = $TestModel->Parent->unbindModel(array('hasOne' => array('Sample')));
  1681. $this->assertTrue($result);
  1682. $result = $TestModel->unbindModel(array('hasMany' => array('Child')));
  1683. $this->assertTrue($result);
  1684. $result = $TestModel->find('all');
  1685. $expected = array(
  1686. array(
  1687. 'Apple' => array(
  1688. 'id' => 1,
  1689. 'apple_id' => 2,
  1690. 'color' => 'Red 1',
  1691. 'name' => 'Red Apple 1',
  1692. 'created' => '2006-11-22 10:38:58',
  1693. 'date' => '1951-01-04',
  1694. 'modified' => '2006-12-01 13:31:26',
  1695. 'mytime' => '22:57:17'
  1696. ),
  1697. 'Parent' => array(
  1698. 'id' => 2,
  1699. 'apple_id' => 1,
  1700. 'color' => 'Bright Red 1',
  1701. 'name' => 'Bright Red Apple',
  1702. 'created' => '2006-11-22 10:43:13',
  1703. 'date' => '2014-01-01',
  1704. 'modified' => '2006-11-30 18:38:10',
  1705. 'mytime' => '22:57:17',
  1706. 'Parent' => array(
  1707. 'id' => 1,
  1708. 'apple_id' => 2,
  1709. 'color' => 'Red 1',
  1710. 'name' => 'Red Apple 1',
  1711. 'created' => '2006-11-22 10:38:58',
  1712. 'date' => '1951-01-04',
  1713. 'modified' => '2006-12-01 13:31:26',
  1714. 'mytime' => '22:57:17'
  1715. ),
  1716. 'Child' => array(
  1717. array(
  1718. 'id' => 1,
  1719. 'apple_id' => 2,
  1720. 'color' => 'Red 1',
  1721. 'name' => 'Red Apple 1',
  1722. 'created' => '2006-11-22 10:38:58',
  1723. 'date' => '1951-01-04',
  1724. 'modified' => '2006-12-01 13:31:26',
  1725. 'mytime' => '22:57:17'
  1726. ),
  1727. array(
  1728. 'id' => 3,
  1729. 'apple_id' => 2,
  1730. 'color' => 'blue green',
  1731. 'name' => 'green blue',
  1732. 'created' => '2006-12-25 05:1…

Large files files are truncated, but you can click here to view the full file