public function testRenderLink()
 {
     $blockHtml = 'test';
     $name = 'test_name';
     $this->context->getLayout()->expects($this->once())->method('renderElement')->with($name)->willReturn($blockHtml);
     /** @var \Magento\Framework\View\Element\AbstractBlock $link */
     $link = $this->getMockBuilder('Magento\\Framework\\View\\Element\\AbstractBlock')->disableOriginalConstructor()->getMock();
     $link->expects($this->once())->method('getNameInLayout')->willReturn($name);
     $this->assertEquals($blockHtml, $this->block->renderLink($link));
 }
Example #2
0
 public function testGetLayout()
 {
     $context = $this->getMock('Oro\\Component\\Layout\\ContextInterface');
     $rootId = 'test_id';
     $rawLayout = $this->getMockBuilder('Oro\\Component\\Layout\\RawLayout')->disableOriginalConstructor()->getMock();
     $rootView = $this->getMockBuilder('Oro\\Component\\Layout\\BlockView')->disableOriginalConstructor()->getMock();
     $layout = $this->getMockBuilder('Oro\\Component\\Layout\\Layout')->disableOriginalConstructor()->getMock();
     $context->expects($this->once())->method('isResolved')->will($this->returnValue(false));
     $context->expects($this->once())->method('resolve');
     $this->registry->expects($this->once())->method('configureContext')->with($this->identicalTo($context));
     $this->layoutManipulator->expects($this->at(0))->method('setBlockTheme')->with('RootTheme1', $this->identicalTo(null));
     $this->layoutManipulator->expects($this->at(1))->method('setBlockTheme')->with(['RootTheme2', 'RootTheme3'], $this->identicalTo(null));
     $this->layoutManipulator->expects($this->at(2))->method('setBlockTheme')->with(['TestTheme1', 'TestTheme2'], 'test_block');
     $this->layoutManipulator->expects($this->at(3))->method('setBlockTheme')->with('TestTheme3', 'test_block');
     $this->layoutManipulator->expects($this->once())->method('applyChanges')->with($this->identicalTo($context), false);
     $this->rawLayoutBuilder->expects($this->once())->method('getRawLayout')->will($this->returnValue($rawLayout));
     $this->blockFactory->expects($this->once())->method('createBlockView')->with($this->identicalTo($rawLayout), $this->identicalTo($context), $rootId)->will($this->returnValue($rootView));
     $this->layoutBuilder->expects($this->once())->method('createLayout')->with($this->identicalTo($rootView))->will($this->returnValue($layout));
     $rawLayout->expects($this->once())->method('getRootId')->will($this->returnValue($rootId));
     $rawLayout->expects($this->once())->method('getBlockThemes')->will($this->returnValue([$rootId => ['RootTheme1', 'RootTheme2', 'RootTheme3'], 'test_block' => ['TestTheme1', 'TestTheme2', 'TestTheme3']]));
     $layout->expects($this->at(0))->method('setBlockTheme')->with(['RootTheme1', 'RootTheme2', 'RootTheme3'], $this->identicalTo(null));
     $layout->expects($this->at(1))->method('setBlockTheme')->with(['TestTheme1', 'TestTheme2', 'TestTheme3'], 'test_block');
     $layout->expects($this->exactly(2))->method('setBlockTheme');
     $this->layoutBuilder->setBlockTheme('RootTheme1')->setBlockTheme(['RootTheme2', 'RootTheme3'])->setBlockTheme(['TestTheme1', 'TestTheme2'], 'test_block')->setBlockTheme('TestTheme3', 'test_block');
     $result = $this->layoutBuilder->getLayout($context, $rootId);
     $this->assertSame($layout, $result);
 }
Example #3
0
 /**
  * @magentoAppIsolation enabled
  */
 public function testAddActionLayoutHandles()
 {
     $this->_model->getRequest()->setRouteName('test')->setControllerName('controller')->setActionName('action');
     $this->_model->addActionLayoutHandles();
     $handles = $this->_model->getLayout()->getUpdate()->getHandles();
     $this->assertContains('test_controller_action', $handles);
 }
Example #4
0
 /**
  * @magentoAppIsolation enabled
  */
 public function testAddPageLayoutHandles()
 {
     $this->_model->getRequest()->setRouteName('test')->setControllerName('controller')->setActionName('action');
     //$this->_model->addPageLayoutHandles(array());
     $this->assertEmpty($this->_model->getLayout()->getUpdate()->getHandles());
     $this->_model->getRequest()->setRouteName('catalog')->setControllerName('product')->setActionName('view');
     $this->_model->addPageLayoutHandles(array('type' => 'simple'));
     $handles = $this->_model->getLayout()->getUpdate()->getHandles();
     $this->assertContains('default', $handles);
     $this->assertContains('catalog_product_view', $handles);
     $this->assertContains('catalog_product_view_type_simple', $handles);
 }
 /**
  * @covers \Magento\Framework\View\Result\Layout::getLayout()
  */
 public function testGetLayout()
 {
     $this->assertSame($this->layout, $this->resultLayout->getLayout());
 }
Example #6
0
 public function testSetGetLayout()
 {
     $this->assertNull($this->_helper->getLayout());
     $this->assertInstanceof(get_class($this->_helper), $this->_helper->setLayout(Mage::app()->getLayout()));
     $this->assertInstanceOf('Mage_Core_Model_Layout', $this->_helper->getLayout());
 }