/** * @return void */ public function testGetChildrenParentIdChildAlias() { $this->_structure->createElement('one', []); $this->_structure->createElement('two', []); $this->_structure->createElement('three', []); $this->_structure->setAsChild('two', 'one'); $this->_structure->setAsChild('three', 'one', 'th'); // getChildren() $this->assertSame(['two' => 'two', 'three' => 'th'], $this->_structure->getChildren('one')); $this->assertSame([], $this->_structure->getChildren('three')); $this->assertSame([], $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')); }
/** * Get element alias by name * * @param string $name * @return bool|string */ public function getElementAlias($name) { return $this->_structure->getChildAlias($this->_structure->getParentId($name), $name); }