NumberTreeFixture.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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', 'null' => false],
  38. 'rght' => ['type' => 'integer', 'null' => false],
  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. *
  55. * @var array
  56. */
  57. public $records = array(
  58. array(
  59. 'id' => '1',
  60. 'name' => 'electronics',
  61. 'parent_id' => null,
  62. 'lft' => '1',
  63. 'rght' => '20'
  64. ),
  65. array(
  66. 'id' => '2',
  67. 'name' => 'televisions',
  68. 'parent_id' => '1',
  69. 'lft' => '2',
  70. 'rght' => '9'
  71. ),
  72. array(
  73. 'id' => '3',
  74. 'name' => 'tube',
  75. 'parent_id' => '2',
  76. 'lft' => '3',
  77. 'rght' => '4'
  78. ),
  79. array(
  80. 'id' => '4',
  81. 'name' => 'lcd',
  82. 'parent_id' => '2',
  83. 'lft' => '5',
  84. 'rght' => '6'
  85. ),
  86. array(
  87. 'id' => '5',
  88. 'name' => 'plasma',
  89. 'parent_id' => '2',
  90. 'lft' => '7',
  91. 'rght' => '8'
  92. ),
  93. array(
  94. 'id' => '6',
  95. 'name' => 'portable',
  96. 'parent_id' => '1',
  97. 'lft' => '10',
  98. 'rght' => '19'
  99. ),
  100. array(
  101. 'id' => '7',
  102. 'name' => 'mp3',
  103. 'parent_id' => '6',
  104. 'lft' => '11',
  105. 'rght' => '14'
  106. ),
  107. array(
  108. 'id' => '8',
  109. 'name' => 'flash',
  110. 'parent_id' => '7',
  111. 'lft' => '12',
  112. 'rght' => '13'
  113. ),
  114. array(
  115. 'id' => '9',
  116. 'name' => 'cd',
  117. 'parent_id' => '6',
  118. 'lft' => '15',
  119. 'rght' => '16'
  120. ),
  121. array(
  122. 'id' => '10',
  123. 'name' => 'radios',
  124. 'parent_id' => '6',
  125. 'lft' => '17',
  126. 'rght' => '18'
  127. ),
  128. array(
  129. 'id' => '11',
  130. 'name' => 'alien hardware',
  131. 'parent_id' => null,
  132. 'lft' => '21',
  133. 'rght' => '21'
  134. )
  135. );
  136. }