Пример #1
0
 public function testRenameElement()
 {
     $this->_populateSampleStructure();
     // rename element and see how children got updated
     $element = $this->_structure->getElement('four');
     $this->assertNotEmpty($element);
     $this->assertFalse($this->_structure->getElement('four.5'));
     $this->assertSame($this->_structure, $this->_structure->renameElement('four', 'four.5'));
     $this->assertSame($element, $this->_structure->getElement('four.5'));
     $this->assertEquals('four.5', $this->_structure->getAttribute('two', Magento_Data_Structure::PARENT));
     $this->assertEquals('four.5', $this->_structure->getAttribute('three', Magento_Data_Structure::PARENT));
     // rename element and see how parent got updated
     $this->_structure->renameElement('three', 'three.5');
     // first child
     $this->assertSame(array('three.5' => 'th', 'two' => 'tw'), $this->_structure->getChildren('four.5'));
     $this->_structure->renameElement('two', 'two.5');
     // second and last child
     $this->assertSame(array('three.5' => 'th', 'two.5' => 'tw'), $this->_structure->getChildren('four.5'));
 }
Пример #2
0
 /**
  * Checks if element with specified name is container
  *
  * @param string $name
  * @return bool
  */
 public function isContainer($name)
 {
     if ($this->_structure->hasElement($name)) {
         return self::TYPE_CONTAINER === $this->_structure->getAttribute($name, 'type');
     }
     return false;
 }