/**
  * @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'));
 }
Example #2
0
 /**
  * Get list of child blocks
  *
  * Returns associative array of <alias> => <block instance>
  *
  * @param string $parentName
  * @return array
  */
 public function getChildBlocks($parentName)
 {
     $blocks = array();
     foreach ($this->_structure->getChildren($parentName) as $childName => $alias) {
         $block = $this->getBlock($childName);
         if ($block) {
             $blocks[$alias] = $block;
         }
     }
     return $blocks;
 }