MenuLinkTreeFixture.php 4.8 KB

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