Example #1
0
    public function testMoveSampleMenuToNewRoot()
    {
        $newRoot = new TestMenuItem("newRoot", $this->getMock('Knp\Menu\FactoryInterface'));
        $newRoot->addChild($this->menu);

        $this->assertEquals(1, $this->menu->getLevel());
        $this->assertEquals(2, $this->pt1->getLevel());

        $this->assertSame($newRoot, $this->menu->getRoot());
        $this->assertSame($newRoot, $this->pt1->getRoot());
        $this->assertFalse($this->menu->isRoot());
        $this->assertTrue($newRoot->isRoot());
        $this->assertSame($newRoot, $this->menu->getParent());
    }
Example #2
0
 private function active(\Knp\Menu\MenuItem $vm)
 {
     if (!$vm->isRoot()) {
         $vm->setExtra('active', true);
         $vm->setAttribute('class', 'active');
         $this->active($vm->getParent());
     }
 }