Conditions | 1 |
Paths | 1 |
Total Lines | 44 |
Code Lines | 32 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
15 | public function testFlatToNested() |
||
16 | { |
||
17 | $flatTree = array( |
||
18 | array( |
||
19 | 'id' => '1', |
||
20 | 'parent' => null, |
||
21 | 'level' => 0, |
||
22 | ), |
||
23 | array( |
||
24 | 'id' => '1.1', |
||
25 | 'parent' => '1', |
||
26 | 'level' => 1, |
||
27 | ), |
||
28 | array( |
||
29 | 'id' => '1.2', |
||
30 | 'parent' => '1', |
||
31 | 'level' => 1, |
||
32 | ), |
||
33 | ); |
||
34 | $result = Utilities::flatToNested($flatTree); |
||
35 | |||
36 | $this->assertEquals( |
||
37 | array( |
||
38 | array( |
||
39 | 'id' => '1', |
||
40 | 'parent' => null, |
||
41 | 'level' => 0, |
||
42 | '_children' => array( |
||
43 | array( |
||
44 | 'id' => '1.1', |
||
45 | 'parent' => '1', |
||
46 | 'level' => 1, |
||
47 | '_children' => array(), |
||
48 | ), |
||
49 | array( |
||
50 | 'id' => '1.2', |
||
51 | 'parent' => '1', |
||
52 | 'level' => 1, |
||
53 | '_children' => array(), |
||
54 | ), |
||
55 | ), |
||
56 | ), |
||
57 | ), |
||
58 | $result |
||
59 | ); |
||
319 |