NumberTreeFixture.php 2.7 KB

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