/** * @return void */ 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\Framework\Data\Structure::PARENT)); $this->assertEquals('four.5', $this->_structure->getAttribute('three', \Magento\Framework\Data\Structure::PARENT)); // rename element and see how parent got updated $this->_structure->renameElement('three', 'three.5'); // first child $this->assertSame(['three.5' => 'th', 'two' => 'tw'], $this->_structure->getChildren('four.5')); $this->_structure->renameElement('two', 'two.5'); // second and last child $this->assertSame(['three.5' => 'th', 'two.5' => 'tw'], $this->_structure->getChildren('four.5')); }
/** * Checks if element with specified name is container * * @param string $name * @return bool */ public function isContainer($name) { if ($this->_structure->hasElement($name)) { return Element::TYPE_CONTAINER === $this->_structure->getAttribute($name, 'type'); } return false; }