Пример #1
0
 /**
  * @covers Magento_Data_Structure::addToParentGroup
  * @covers Magento_Data_Structure::getGroupChildNames
  */
 public function testGroups()
 {
     // non-existing element
     $this->assertFalse($this->_structure->addToParentGroup('non-existing', 'group1'));
     $this->assertSame(array(), $this->_structure->getGroupChildNames('non-existing', 'group1'));
     // not a child
     $this->_structure->createElement('one', array());
     $this->_structure->createElement('two', array());
     $this->assertFalse($this->_structure->addToParentGroup('two', 'group1'));
     $this->assertSame(array(), $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', array());
     $this->_structure->createElement('four', array());
     $this->_structure->setAsChild('three', 'one', 'th');
     $this->_structure->setAsChild('four', 'one');
     $this->_structure->addToParentGroup('three', 'group1');
     $this->_structure->addToParentGroup('four', 'group2');
     $this->assertSame(array('two', 'three'), $this->_structure->getGroupChildNames('one', 'group1'));
     $this->assertSame(array('two', 'four'), $this->_structure->getGroupChildNames('one', 'group2'));
     // unset a child
     $this->_structure->unsetChild('one', 'two');
     $this->assertSame(array('three'), $this->_structure->getGroupChildNames('one', 'group1'));
     $this->assertSame(array('four'), $this->_structure->getGroupChildNames('one', 'group2'));
     // return child back
     $this->_structure->setAsChild('two', 'one');
     $this->assertSame(array('two', 'three'), $this->_structure->getGroupChildNames('one', 'group1'));
     $this->assertSame(array('two', 'four'), $this->_structure->getGroupChildNames('one', 'group2'));
 }
Пример #2
0
 public function testConstructorStructure()
 {
     $structure = new Magento_Data_Structure();
     $structure->createElement('test.container', array());
     $layout = new Mage_Core_Model_Layout(array('structure' => $structure));
     $this->assertTrue($layout->hasElement('test.container'));
 }
Пример #3
0
 /**
  * Register an element in structure
  *
  * Will assign an "anonymous" name to the element, if provided with an empty name
  *
  * @param string $name
  * @param string $type
  * @return string
  */
 protected function _createStructuralElement($name, $type, $class)
 {
     if (empty($name)) {
         $name = $this->_generateAnonymousName($class);
     }
     $this->_structure->createElement($name, array('type' => $type));
     return $name;
 }