NumberTreeFixture.php 2.6 KB

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