MenuLinkTreeFixture.php 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. <?php
  2. /**
  3. * Tree behavior class.
  4. *
  5. * Enables a model object to act as a node-based tree.
  6. *
  7. * CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
  8. * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  9. *
  10. * Licensed under The MIT License
  11. * For full copyright and license information, please see the LICENSE.txt
  12. * Redistributions of files must retain the above copyright notice
  13. *
  14. * @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  15. * @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests
  16. * @since CakePHP(tm) v 1.2.0.5331
  17. * @license http://www.opensource.org/licenses/mit-license.php MIT License
  18. */
  19. namespace Cake\Test\Fixture;
  20. use Cake\TestSuite\Fixture\TestFixture;
  21. /**
  22. * Class NumberTreeFixture
  23. *
  24. * Generates a tree of data for use testing the tree behavior
  25. *
  26. */
  27. class MenuLinkTreeFixture extends TestFixture {
  28. /**
  29. * fields property
  30. *
  31. * @var array
  32. */
  33. public $fields = array(
  34. 'id' => ['type' => 'integer'],
  35. 'menu' => ['type' => 'string', 'null' => false],
  36. 'lft' => ['type' => 'integer', 'null' => false],
  37. 'rght' => ['type' => 'integer', 'null' => false],
  38. 'parent_id' => 'integer',
  39. 'url' => ['type' => 'string', 'null' => false],
  40. 'title' => ['type' => 'string', 'null' => false],
  41. '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]]
  42. );
  43. /**
  44. * Records
  45. *
  46. * # main-menu:
  47. *
  48. * - Link 1:1
  49. * - Link 2:2
  50. * - Link 3:3
  51. * - Link 4:4
  52. * - Link 5:5
  53. * - Link 6:6
  54. * - Link 7:7
  55. * - Link 8:8
  56. *
  57. * ***
  58. *
  59. * # categories:
  60. *
  61. * - electronics:9
  62. * - televisions:10
  63. * - tube:11
  64. * - lcd:12
  65. * - plasma:13
  66. * - portable:14
  67. * - mp3:15
  68. * - flash:16
  69. * - cd:17
  70. * - radios:18
  71. *
  72. * **Note:** title:id
  73. */
  74. public $records = array(
  75. array(
  76. 'id' => '1',
  77. 'menu' => 'main-menu',
  78. 'lft' => '1',
  79. 'rght' => '10',
  80. 'parent_id' => '0',
  81. 'url' => '/link1.html',
  82. 'title' => 'Link 1',
  83. ),
  84. array(
  85. 'id' => '2',
  86. 'menu' => 'main-menu',
  87. 'lft' => '2',
  88. 'rght' => '3',
  89. 'parent_id' => '1',
  90. 'url' => 'http://example.com',
  91. 'title' => 'Link 2',
  92. ),
  93. array(
  94. 'id' => '3',
  95. 'menu' => 'main-menu',
  96. 'lft' => '4',
  97. 'rght' => '9',
  98. 'parent_id' => '1',
  99. 'url' => '/what/even-more-links.html',
  100. 'title' => 'Link 3',
  101. ),
  102. array(
  103. 'id' => '4',
  104. 'menu' => 'main-menu',
  105. 'lft' => '5',
  106. 'rght' => '8',
  107. 'parent_id' => '3',
  108. 'url' => '/lorem/ipsum.html',
  109. 'title' => 'Link 4',
  110. ),
  111. array(
  112. 'id' => '5',
  113. 'menu' => 'main-menu',
  114. 'lft' => '6',
  115. 'rght' => '7',
  116. 'parent_id' => '4',
  117. 'url' => '/what/the.html',
  118. 'title' => 'Link 5',
  119. ),
  120. array(
  121. 'id' => '6',
  122. 'menu' => 'main-menu',
  123. 'lft' => '11',
  124. 'rght' => '14',
  125. 'parent_id' => '0',
  126. 'url' => '/yeah/another-link.html',
  127. 'title' => 'Link 6',
  128. ),
  129. array(
  130. 'id' => '7',
  131. 'menu' => 'main-menu',
  132. 'lft' => '12',
  133. 'rght' => '13',
  134. 'parent_id' => '6',
  135. 'url' => 'http://cakephp.org',
  136. 'title' => 'Link 7',
  137. ),
  138. array(
  139. 'id' => '8',
  140. 'menu' => 'main-menu',
  141. 'lft' => '15',
  142. 'rght' => '16',
  143. 'parent_id' => '0',
  144. 'url' => '/page/who-we-are.html',
  145. 'title' => 'Link 8',
  146. ),
  147. array(
  148. 'id' => '9',
  149. 'menu' => 'categories',
  150. 'lft' => '1',
  151. 'rght' => '10',
  152. 'parent_id' => '0',
  153. 'url' => '/cagetory/electronics.html',
  154. 'title' => 'electronics',
  155. ),
  156. array(
  157. 'id' => '10',
  158. 'menu' => 'categories',
  159. 'lft' => '2',
  160. 'rght' => '9',
  161. 'parent_id' => '9',
  162. 'url' => '/category/televisions.html',
  163. 'title' => 'televisions',
  164. ),
  165. array(
  166. 'id' => '11',
  167. 'menu' => 'categories',
  168. 'lft' => '3',
  169. 'rght' => '4',
  170. 'parent_id' => '10',
  171. 'url' => '/category/tube.html',
  172. 'title' => 'tube',
  173. ),
  174. array(
  175. 'id' => '12',
  176. 'menu' => 'categories',
  177. 'lft' => '5',
  178. 'rght' => '8',
  179. 'parent_id' => '10',
  180. 'url' => '/category/lcd.html',
  181. 'title' => 'lcd',
  182. ),
  183. array(
  184. 'id' => '13',
  185. 'menu' => 'categories',
  186. 'lft' => '6',
  187. 'rght' => '7',
  188. 'parent_id' => '12',
  189. 'url' => '/category/plasma.html',
  190. 'title' => 'plasma',
  191. ),
  192. array(
  193. 'id' => '14',
  194. 'menu' => 'categories',
  195. 'lft' => '11',
  196. 'rght' => '20',
  197. 'parent_id' => '0',
  198. 'url' => '/category/portable.html',
  199. 'title' => 'portable',
  200. ),
  201. array(
  202. 'id' => '15',
  203. 'menu' => 'categories',
  204. 'lft' => '12',
  205. 'rght' => '15',
  206. 'parent_id' => '14',
  207. 'url' => '/category/mp3.html',
  208. 'title' => 'mp3',
  209. ),
  210. array(
  211. 'id' => '16',
  212. 'menu' => 'categories',
  213. 'lft' => '13',
  214. 'rght' => '14',
  215. 'parent_id' => '15',
  216. 'url' => '/category/flash.html',
  217. 'title' => 'flash',
  218. ),
  219. array(
  220. 'id' => '17',
  221. 'menu' => 'categories',
  222. 'lft' => '16',
  223. 'rght' => '17',
  224. 'parent_id' => '14',
  225. 'url' => '/category/cd.html',
  226. 'title' => 'cd',
  227. ),
  228. array(
  229. 'id' => '18',
  230. 'menu' => 'categories',
  231. 'lft' => '18',
  232. 'rght' => '19',
  233. 'parent_id' => '14',
  234. 'url' => '/category/radios.html',
  235. 'title' => 'radios',
  236. ),
  237. );
  238. }