public function testRenameElement() { $oldName = 'old_name'; $newName = 'new_name'; $blockMock = $this->getMockBuilder('Magento\\Framework\\View\\Element\\AbstractBlock')->disableOriginalConstructor()->getMockForAbstractClass(); $this->structureMock->expects($this->once())->method('renameElement')->with($this->equalTo($oldName), $this->equalTo($newName))->will($this->returnSelf()); $this->assertSame($this->model, $this->model->setBlock($oldName, $blockMock)); $this->assertSame($this->model, $this->model->renameElement($oldName, $newName)); $this->assertSame([$newName => $blockMock], $this->model->getAllBlocks()); }
public function testRenameElement() { $blockName = 'block'; $expBlockName = 'block_renamed'; $containerName = 'container'; $expContainerName = 'container_renamed'; $block = $this->_layout->createBlock('Magento\\Framework\\View\\Element\\Text', $blockName); $this->_layout->addContainer($containerName, 'Container'); $this->assertEquals($block, $this->_layout->getBlock($blockName)); $this->_layout->renameElement($blockName, $expBlockName); $this->assertEquals($block, $this->_layout->getBlock($expBlockName)); $this->_layout->hasElement($containerName); $this->_layout->renameElement($containerName, $expContainerName); $this->_layout->hasElement($expContainerName); }
/** * {@inheritdoc} */ public function renameElement($oldName, $newName) { $pluginInfo = $this->pluginList->getNext($this->subjectType, 'renameElement'); if (!$pluginInfo) { return parent::renameElement($oldName, $newName); } else { return $this->___callPlugins('renameElement', func_get_args(), $pluginInfo); } }