MenuLinkTreesFixture.php 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  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 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 MenuLinkTreesFixture extends TestFixture
  24. {
  25. /**
  26. * fields property
  27. *
  28. * @var array
  29. */
  30. public $fields = [
  31. 'id' => ['type' => 'integer'],
  32. 'menu' => ['type' => 'string', 'null' => false],
  33. 'lft' => ['type' => 'integer'],
  34. 'rght' => ['type' => 'integer'],
  35. 'parent_id' => 'integer',
  36. 'url' => ['type' => 'string', 'null' => false],
  37. 'title' => ['type' => 'string', 'null' => false],
  38. '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]]
  39. ];
  40. /**
  41. * Records
  42. *
  43. * # main-menu:
  44. *
  45. * - Link 1:1
  46. * - Link 2:2
  47. * - Link 3:3
  48. * - Link 4:4
  49. * - Link 5:5
  50. * - Link 6:6
  51. * - Link 7:7
  52. * - Link 8:8
  53. *
  54. * ***
  55. *
  56. * # categories:
  57. *
  58. * - electronics:9
  59. * - televisions:10
  60. * - tube:11
  61. * - lcd:12
  62. * - plasma:13
  63. * - portable:14
  64. * - mp3:15
  65. * - flash:16
  66. * - cd:17
  67. * - radios:18
  68. *
  69. * **Note:** title:id
  70. */
  71. public $records = [
  72. [
  73. 'menu' => 'main-menu',
  74. 'lft' => '1',
  75. 'rght' => '10',
  76. 'parent_id' => null,
  77. 'url' => '/link1.html',
  78. 'title' => 'Link 1',
  79. ],
  80. [
  81. 'menu' => 'main-menu',
  82. 'lft' => '2',
  83. 'rght' => '3',
  84. 'parent_id' => '1',
  85. 'url' => 'http://example.com',
  86. 'title' => 'Link 2',
  87. ],
  88. [
  89. 'menu' => 'main-menu',
  90. 'lft' => '4',
  91. 'rght' => '9',
  92. 'parent_id' => '1',
  93. 'url' => '/what/even-more-links.html',
  94. 'title' => 'Link 3',
  95. ],
  96. [
  97. 'menu' => 'main-menu',
  98. 'lft' => '5',
  99. 'rght' => '8',
  100. 'parent_id' => '3',
  101. 'url' => '/lorem/ipsum.html',
  102. 'title' => 'Link 4',
  103. ],
  104. [
  105. 'menu' => 'main-menu',
  106. 'lft' => '6',
  107. 'rght' => '7',
  108. 'parent_id' => '4',
  109. 'url' => '/what/the.html',
  110. 'title' => 'Link 5',
  111. ],
  112. [
  113. 'menu' => 'main-menu',
  114. 'lft' => '11',
  115. 'rght' => '14',
  116. 'parent_id' => null,
  117. 'url' => '/yeah/another-link.html',
  118. 'title' => 'Link 6',
  119. ],
  120. [
  121. 'menu' => 'main-menu',
  122. 'lft' => '12',
  123. 'rght' => '13',
  124. 'parent_id' => '6',
  125. 'url' => 'http://cakephp.org',
  126. 'title' => 'Link 7',
  127. ],
  128. [
  129. 'menu' => 'main-menu',
  130. 'lft' => '15',
  131. 'rght' => '16',
  132. 'parent_id' => null,
  133. 'url' => '/page/who-we-are.html',
  134. 'title' => 'Link 8',
  135. ],
  136. [
  137. 'menu' => 'categories',
  138. 'lft' => '1',
  139. 'rght' => '10',
  140. 'parent_id' => null,
  141. 'url' => '/cagetory/electronics.html',
  142. 'title' => 'electronics',
  143. ],
  144. [
  145. 'menu' => 'categories',
  146. 'lft' => '2',
  147. 'rght' => '9',
  148. 'parent_id' => '9',
  149. 'url' => '/category/televisions.html',
  150. 'title' => 'televisions',
  151. ],
  152. [
  153. 'menu' => 'categories',
  154. 'lft' => '3',
  155. 'rght' => '4',
  156. 'parent_id' => '10',
  157. 'url' => '/category/tube.html',
  158. 'title' => 'tube',
  159. ],
  160. [
  161. 'menu' => 'categories',
  162. 'lft' => '5',
  163. 'rght' => '8',
  164. 'parent_id' => '10',
  165. 'url' => '/category/lcd.html',
  166. 'title' => 'lcd',
  167. ],
  168. [
  169. 'menu' => 'categories',
  170. 'lft' => '6',
  171. 'rght' => '7',
  172. 'parent_id' => '12',
  173. 'url' => '/category/plasma.html',
  174. 'title' => 'plasma',
  175. ],
  176. [
  177. 'menu' => 'categories',
  178. 'lft' => '11',
  179. 'rght' => '20',
  180. 'parent_id' => null,
  181. 'url' => '/category/portable.html',
  182. 'title' => 'portable',
  183. ],
  184. [
  185. 'menu' => 'categories',
  186. 'lft' => '12',
  187. 'rght' => '15',
  188. 'parent_id' => '14',
  189. 'url' => '/category/mp3.html',
  190. 'title' => 'mp3',
  191. ],
  192. [
  193. 'menu' => 'categories',
  194. 'lft' => '13',
  195. 'rght' => '14',
  196. 'parent_id' => '15',
  197. 'url' => '/category/flash.html',
  198. 'title' => 'flash',
  199. ],
  200. [
  201. 'menu' => 'categories',
  202. 'lft' => '16',
  203. 'rght' => '17',
  204. 'parent_id' => '14',
  205. 'url' => '/category/cd.html',
  206. 'title' => 'cd',
  207. ],
  208. [
  209. 'menu' => 'categories',
  210. 'lft' => '18',
  211. 'rght' => '19',
  212. 'parent_id' => '14',
  213. 'url' => '/category/radios.html',
  214. 'title' => 'radios',
  215. ],
  216. ];
  217. }