/**
  * @return void
  * @covers \Magento\Framework\Data\Structure::addToParentGroup
  * @covers \Magento\Framework\Data\Structure::getGroupChildNames
  */
 public function testGroups()
 {
     // non-existing element
     $this->assertFalse($this->_structure->addToParentGroup('non-existing', 'group1'));
     $this->assertSame([], $this->_structure->getGroupChildNames('non-existing', 'group1'));
     // not a child
     $this->_structure->createElement('one', []);
     $this->_structure->createElement('two', []);
     $this->assertFalse($this->_structure->addToParentGroup('two', 'group1'));
     $this->assertSame([], $this->_structure->getGroupChildNames('one', 'group1'));
     // child
     $this->_structure->setAsChild('two', 'one');
     $this->assertTrue($this->_structure->addToParentGroup('two', 'group1'));
     $this->assertTrue($this->_structure->addToParentGroup('two', 'group2'));
     // group getter
     $this->_structure->createElement('three', []);
     $this->_structure->createElement('four', []);
     $this->_structure->setAsChild('three', 'one', 'th');
     $this->_structure->setAsChild('four', 'one');
     $this->_structure->addToParentGroup('three', 'group1');
     $this->_structure->addToParentGroup('four', 'group2');
     $this->assertSame(['two', 'three'], $this->_structure->getGroupChildNames('one', 'group1'));
     $this->assertSame(['two', 'four'], $this->_structure->getGroupChildNames('one', 'group2'));
     // unset a child
     $this->_structure->unsetChild('one', 'two');
     $this->assertSame(['three'], $this->_structure->getGroupChildNames('one', 'group1'));
     $this->assertSame(['four'], $this->_structure->getGroupChildNames('one', 'group2'));
     // return child back
     $this->_structure->setAsChild('two', 'one');
     $this->assertSame(['two', 'three'], $this->_structure->getGroupChildNames('one', 'group1'));
     $this->assertSame(['two', 'four'], $this->_structure->getGroupChildNames('one', 'group2'));
 }
Example #2
0
 /**
  * Add element to parent group
  *
  * @param string $blockName
  * @param string $parentGroupName
  * @return bool
  */
 public function addToParentGroup($blockName, $parentGroupName)
 {
     return $this->_structure->addToParentGroup($blockName, $parentGroupName);
 }