/
NumberTreeFixture.php
142 lines (137 loc) · 2.69 KB
/
NumberTreeFixture.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
<?php
/**
* Tree behavior class.
*
* Enables a model object to act as a node-based tree.
*
* CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests
* @since 1.2.0
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
namespace Cake\Test\Fixture;
use Cake\TestSuite\Fixture\TestFixture;
/**
* Class NumberTreeFixture
*
* Generates a tree of data for use testing the tree behavior
*
*/
class NumberTreeFixture extends TestFixture {
/**
* fields property
*
* @var array
*/
public $fields = array(
'id' => ['type' => 'integer'],
'name' => ['type' => 'string', 'null' => false],
'parent_id' => 'integer',
'lft' => ['type' => 'integer'],
'rght' => ['type' => 'integer'],
'_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]]
);
/**
* Records
*
* - electronics:1
* - televisions:2
* - tube:3
* - lcd:4
* - plasma:5
* - portable:6
* - mp3:7
* - flash:8
* - cd:9
* - radios:10
* - alien ware: 11
*
* @var array
*/
public $records = array(
array(
'id' => '1',
'name' => 'electronics',
'parent_id' => null,
'lft' => '1',
'rght' => '20'
),
array(
'id' => '2',
'name' => 'televisions',
'parent_id' => '1',
'lft' => '2',
'rght' => '9'
),
array(
'id' => '3',
'name' => 'tube',
'parent_id' => '2',
'lft' => '3',
'rght' => '4'
),
array(
'id' => '4',
'name' => 'lcd',
'parent_id' => '2',
'lft' => '5',
'rght' => '6'
),
array(
'id' => '5',
'name' => 'plasma',
'parent_id' => '2',
'lft' => '7',
'rght' => '8'
),
array(
'id' => '6',
'name' => 'portable',
'parent_id' => '1',
'lft' => '10',
'rght' => '19'
),
array(
'id' => '7',
'name' => 'mp3',
'parent_id' => '6',
'lft' => '11',
'rght' => '14'
),
array(
'id' => '8',
'name' => 'flash',
'parent_id' => '7',
'lft' => '12',
'rght' => '13'
),
array(
'id' => '9',
'name' => 'cd',
'parent_id' => '6',
'lft' => '15',
'rght' => '16'
),
array(
'id' => '10',
'name' => 'radios',
'parent_id' => '6',
'lft' => '17',
'rght' => '18'
),
array(
'id' => '11',
'name' => 'alien hardware',
'parent_id' => null,
'lft' => '21',
'rght' => '22'
)
);
}