Exemplo n.º 1
0
 public function testInterpret()
 {
     /** @var \Magento\Framework\View\Layout\Reader\Context $readerContext */
     $readerContext = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Framework\\View\\Layout\\Reader\\Context');
     $pageXml = new \Magento\Framework\View\Layout\Element(__DIR__ . '/_files/_layout_update.xml', 0, true);
     $parentElement = new \Magento\Framework\View\Layout\Element('<page></page>');
     $html = new Html();
     foreach ($pageXml->xpath('html') as $htmlElement) {
         $html->interpret($readerContext, $htmlElement, $parentElement);
     }
     $structure = $readerContext->getPageConfigStructure();
     $this->assertEquals(['html' => ['test-name' => 'test-value']], $structure->getElementAttributes());
 }
Exemplo n.º 2
0
 public function testInterpretReferenceBlockDirective()
 {
     $pageXml = new \Magento\Framework\View\Layout\Element(__DIR__ . '/_files/_layout_update_reference.xml', 0, true);
     $parentElement = new \Magento\Framework\View\Layout\Element('<page></page>');
     foreach ($pageXml->xpath('body/*') as $element) {
         $this->assertTrue(in_array($element->getName(), $this->block->getSupportedNodes()));
         $this->block->interpret($this->readerContext, $element, $parentElement);
     }
     $structure = $this->readerContext->getScheduledStructure();
     $this->assertArrayHasKey($this->blockName, $structure->getStructure());
     $this->assertEquals('block', $structure->getStructure()[$this->blockName][self::IDX_TYPE]);
     $resultElementData = $structure->getStructureElementData($this->blockName);
     $this->assertEquals(['test_arg' => 'test-argument-value'], $resultElementData['arguments']);
 }
Exemplo n.º 3
0
 /**
  * @dataProvider cacheableDataProvider
  */
 public function testIsCacheable($xml, $expected)
 {
     $model = new \Magento\Framework\View\Layout\Element($xml);
     $this->assertEquals($expected, $model->isCacheable());
 }