/** * @magentoAppIsolation enabled */ public function testProcessWithExceptions() { \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\\Framework\\App\\State')->setMode(State::MODE_DEFAULT); $this->layout->generateElements(); $this->layout->addOutputElement('block.with.broken.constructor'); $this->layout->addOutputElement('block.with.broken.layout'); $this->layout->addOutputElement('block.with.broken.action'); $this->assertEmpty($this->layout->getOutput()); }
public function testGenerateElementsWithCache() { $layoutCacheId = 'layout_cache_id'; /** @var \Magento\Framework\View\Layout\Element $xml */ $xml = simplexml_load_string('<layout/>', 'Magento\Framework\View\Layout\Element'); $this->model->setXml($xml); $themeMock = $this->getMockForAbstractClass('Magento\Framework\View\Design\ThemeInterface'); $this->themeResolverMock->expects($this->once()) ->method('get') ->willReturn($themeMock); $this->processorFactoryMock->expects($this->once()) ->method('create') ->with(['theme' => $themeMock]) ->willReturn($this->processorMock); $this->processorMock->expects($this->once()) ->method('getCacheId') ->willReturn($layoutCacheId); $readerContextMock = $this->getMockBuilder('Magento\Framework\View\Layout\Reader\Context') ->disableOriginalConstructor() ->getMock(); $this->cacheMock->expects($this->once()) ->method('load') ->with('structure_' . $layoutCacheId) ->willReturn(serialize($readerContextMock)); $this->readerPoolMock->expects($this->never()) ->method('interpret'); $this->cacheMock->expects($this->never()) ->method('save'); $generatorContextMock = $this->getMockBuilder('Magento\Framework\View\Layout\Generator\Context') ->disableOriginalConstructor() ->getMock(); $this->generatorContextFactoryMock->expects($this->once()) ->method('create') ->with(['structure' => $this->structureMock, 'layout' => $this->model]) ->willReturn($generatorContextMock); $this->generatorPoolMock->expects($this->once()) ->method('process') ->with($readerContextMock, $generatorContextMock) ->willReturn(true); $elements = [ 'name_1' => ['type' => '', 'parent' => null], 'name_2' => ['type' => \Magento\Framework\View\Layout\Element::TYPE_CONTAINER, 'parent' => null], 'name_3' => ['type' => '', 'parent' => 'parent'], 'name_4' => ['type' => \Magento\Framework\View\Layout\Element::TYPE_CONTAINER, 'parent' => 'parent'], ]; $this->structureMock->expects($this->once()) ->method('exportElements') ->willReturn($elements); $this->model->generateElements(); }
/** * {@inheritdoc} */ public function generateElements() { $pluginInfo = $this->pluginList->getNext($this->subjectType, 'generateElements'); if (!$pluginInfo) { return parent::generateElements(); } else { return $this->___callPlugins('generateElements', func_get_args(), $pluginInfo); } }
public function testIsNonCacheable() { $this->_layout->setXml(simplexml_load_file(__DIR__ . '/_files/layout/non_cacheable.xml', 'Magento\\Framework\\View\\Layout\\Element')); $this->_layout->generateElements(); $this->assertFalse($this->_layout->isCacheable()); }