for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace StefanoTreeTest\Unit;
use StefanoTree\NestedSet\Utilities;
use StefanoTreeTest\UnitTestCase;
class UtilitiesTest extends UnitTestCase
{
public function testFlatToNested()
$flatTree = [
[
'id' => '1',
'parent' => null,
'level' => 0,
],
'id' => '1.1',
'parent' => '1',
'level' => 1,
'id' => '1.2',
];
$result = Utilities::flatToNested($flatTree);
$this->assertEquals(
'_children' => [
'_children' => [],
], $result);
}
public function testFlatToNestedMultiRootNode()
'level' => 2,
'id' => '2',
'id' => '2.1',
'parent' => '2',
public function testFlatToNestedComplexTree()
'id' => '1.2.1',
'parent' => '1.2',
'level' => 3,
'id' => '1.2.1.1',
'parent' => '1.2.1',
'level' => 4,
'id' => '2.1.1',
'parent' => '2.1',
'id' => '2.1.2',
'id' => '2.1.3',
'id' => '2.2',
public function testFlatToNestedChangeLevelName()
'lvl' => 0,
'lvl' => 1,
$result = Utilities::flatToNested($flatTree, 'lvl');