NumberTreesFixture.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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 1.2.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 NumberTreesFixture extends TestFixture
  24. {
  25. /**
  26. * fields property
  27. *
  28. * @var array
  29. */
  30. public $fields = [
  31. 'id' => ['type' => 'integer'],
  32. 'name' => ['type' => 'string', 'null' => false],
  33. 'parent_id' => 'integer',
  34. 'lft' => ['type' => 'integer'],
  35. 'rght' => ['type' => 'integer'],
  36. 'depth' => ['type' => 'integer'],
  37. '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]]
  38. ];
  39. /**
  40. * Records
  41. *
  42. * - electronics:1
  43. * - televisions:2
  44. * - tube:3
  45. * - lcd:4
  46. * - plasma:5
  47. * - portable:6
  48. * - mp3:7
  49. * - flash:8
  50. * - cd:9
  51. * - radios:10
  52. * - alien ware: 11
  53. *
  54. * @var array
  55. */
  56. public $records = [
  57. [
  58. 'name' => 'electronics',
  59. 'parent_id' => null,
  60. 'lft' => '1',
  61. 'rght' => '20',
  62. 'depth' => 0
  63. ],
  64. [
  65. 'name' => 'televisions',
  66. 'parent_id' => '1',
  67. 'lft' => '2',
  68. 'rght' => '9',
  69. 'depth' => 1
  70. ],
  71. [
  72. 'name' => 'tube',
  73. 'parent_id' => '2',
  74. 'lft' => '3',
  75. 'rght' => '4',
  76. 'depth' => 2
  77. ],
  78. [
  79. 'name' => 'lcd',
  80. 'parent_id' => '2',
  81. 'lft' => '5',
  82. 'rght' => '6',
  83. 'depth' => 2
  84. ],
  85. [
  86. 'name' => 'plasma',
  87. 'parent_id' => '2',
  88. 'lft' => '7',
  89. 'rght' => '8',
  90. 'depth' => 2
  91. ],
  92. [
  93. 'name' => 'portable',
  94. 'parent_id' => '1',
  95. 'lft' => '10',
  96. 'rght' => '19',
  97. 'depth' => 1
  98. ],
  99. [
  100. 'name' => 'mp3',
  101. 'parent_id' => '6',
  102. 'lft' => '11',
  103. 'rght' => '14',
  104. 'depth' => 2
  105. ],
  106. [
  107. 'name' => 'flash',
  108. 'parent_id' => '7',
  109. 'lft' => '12',
  110. 'rght' => '13',
  111. 'depth' => 3
  112. ],
  113. [
  114. 'name' => 'cd',
  115. 'parent_id' => '6',
  116. 'lft' => '15',
  117. 'rght' => '16',
  118. 'depth' => 2
  119. ],
  120. [
  121. 'name' => 'radios',
  122. 'parent_id' => '6',
  123. 'lft' => '17',
  124. 'rght' => '18',
  125. 'depth' => 2
  126. ],
  127. [
  128. 'name' => 'alien hardware',
  129. 'parent_id' => null,
  130. 'lft' => '21',
  131. 'rght' => '22',
  132. 'depth' => 0
  133. ]
  134. ];
  135. }