public function testMakeLastChildOfSwappingRootsWithSubtrees()
 {
     $newRoot = Cluster::create(array('name' => 'Root 3'));
     $this->clusters('Root 1')->makeLastChildOf($newRoot);
     $this->assertTrue(Cluster::isValidNestedSet());
     $this->assertEquals($newRoot->getKey(), $this->clusters('Root 1')->getParentId());
     $this->assertEquals(4, $this->clusters('Root 1')->getLeft());
     $this->assertEquals(13, $this->clusters('Root 1')->getRight());
     $this->assertEquals(8, $this->clusters('Child 2.1')->getLeft());
     $this->assertEquals(9, $this->clusters('Child 2.1')->getRight());
 }
 public function testToHierarchyNestsCorrectlyNotSequential()
 {
     $parent = $this->clusters('Child 1');
     $parent->children()->create(array('name' => 'Child 1.1'));
     $parent->children()->create(array('name' => 'Child 1.2'));
     $this->assertTrue(Cluster::isValidNestedSet());
     $expected = array('Child 1' => array('Child 1.1' => null, 'Child 1.2' => null));
     $parent->reload();
     $this->assertArraysAreEqual($expected, hmap($parent->getDescendantsAndSelf()->toHierarchy()->toArray()));
 }