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