示例#1
0
 public function testGetChildrenParentIdChildAlias()
 {
     $this->_structure->createElement('one', array());
     $this->_structure->createElement('two', array());
     $this->_structure->createElement('three', array());
     $this->_structure->setAsChild('two', 'one');
     $this->_structure->setAsChild('three', 'one', 'th');
     // getChildren()
     $this->assertSame(array('two' => 'two', 'three' => 'th'), $this->_structure->getChildren('one'));
     $this->assertSame(array(), $this->_structure->getChildren('three'));
     $this->assertSame(array(), $this->_structure->getChildren('nonexisting'));
     // getParentId()
     $this->assertEquals('one', $this->_structure->getParentId('two'));
     $this->assertFalse($this->_structure->getParentId('nonexistent'));
     // getChildAlias()
     $this->assertEquals('two', $this->_structure->getChildAlias('one', 'two'));
     $this->assertEquals('th', $this->_structure->getChildAlias('one', 'three'));
     $this->assertFalse($this->_structure->getChildAlias('nonexistent', 'child'));
     $this->assertFalse($this->_structure->getChildAlias('one', 'nonexistent'));
 }
示例#2
0
 /**
  * Get element alias by name
  *
  * @param string $name
  * @return bool|string
  */
 public function getElementAlias($name)
 {
     return $this->_structure->getChildAlias($this->_structure->getParentId($name), $name);
 }