public function testRenderByOtherRenderer() { $expected = 'some rendered string'; $view = new BlockView(); $otherRenderer = $this->getMock('Oro\\Component\\Layout\\LayoutRendererInterface'); $this->rendererRegistry->addRenderer('other', $otherRenderer); $otherRenderer->expects($this->once())->method('renderBlock')->with($this->identicalTo($view))->will($this->returnValue($expected)); $layout = new Layout($view, $this->rendererRegistry); $result = $layout->setRenderer('other')->render(); $this->assertEquals($expected, $result); }
protected function setUp() { $this->registry = $this->getMock('Oro\\Component\\Layout\\LayoutRegistryInterface'); $this->rawLayoutBuilder = $this->getMock('Oro\\Component\\Layout\\RawLayoutBuilderInterface'); $this->layoutManipulator = $this->getMock('Oro\\Component\\Layout\\DeferredLayoutManipulatorInterface'); $this->blockFactory = $this->getMock('Oro\\Component\\Layout\\BlockFactoryInterface'); $this->renderer = $this->getMock('Oro\\Component\\Layout\\LayoutRendererInterface'); $rendererRegistry = new LayoutRendererRegistry(); $rendererRegistry->addRenderer('test', $this->renderer); $rendererRegistry->setDefaultRenderer('test'); $this->layoutBuilder = $this->getMockBuilder('Oro\\Component\\Layout\\LayoutBuilder')->setConstructorArgs([$this->registry, $this->rawLayoutBuilder, $this->layoutManipulator, $this->blockFactory, $rendererRegistry])->setMethods(['createLayout'])->getMock(); }
public function testGetRenderer() { // prepare data $renderer1 = $this->getMock('Oro\\Component\\Layout\\LayoutRendererInterface'); $renderer2 = $this->getMock('Oro\\Component\\Layout\\LayoutRendererInterface'); $this->registry->addRenderer('test1', $renderer1); $this->registry->addRenderer('test2', $renderer2); $this->registry->setDefaultRenderer('test2'); // test hasRenderer $this->assertTrue($this->registry->hasRenderer('test1')); $this->assertTrue($this->registry->hasRenderer('test2')); $this->assertFalse($this->registry->hasRenderer('undefined')); // test getRenderer $this->assertSame($renderer2, $this->registry->getRenderer()); $this->assertSame($renderer1, $this->registry->getRenderer('test1')); $this->assertSame($renderer2, $this->registry->getRenderer('test2')); }
/** * {@inheritdoc} */ public function getLayoutFactory() { // initialize extension manager $registry = new LayoutRegistry(); foreach ($this->extensions as $extension) { $registry->addExtension($extension); } if (!empty($this->types) || !empty($this->typeExtensions) || !empty($this->layoutUpdates)) { $registry->addExtension(new PreloadedExtension($this->types, $this->typeExtensions, $this->layoutUpdates)); } // initialize renderer registry $rendererRegistry = new LayoutRendererRegistry(); $defaultRenderer = $this->defaultRenderer; foreach ($this->renderers as $name => $renderer) { $rendererRegistry->addRenderer($name, $renderer); if (!$defaultRenderer) { $defaultRenderer = $name; } } if ($defaultRenderer) { $rendererRegistry->setDefaultRenderer($defaultRenderer); } return new LayoutFactory($registry, $rendererRegistry); }