public function testRenderWithDefaultText() { $engine = $this->getMock('Symfony\\Component\\Templating\\EngineInterface'); $engine->expects($this->once())->method('exists')->with('default')->will($this->throwException(new \InvalidArgumentException())); // only default $strategy = new HIncludeFragmentRenderer($engine); $this->assertEquals('<hx:include src="/foo">default</hx:include>', $strategy->render('/foo', Request::create('/'), array('default' => 'default'))->getContent()); }
/** * {@inheritdoc} */ public function render($uri, Request $request, array $options = array()) { // setting the templating cannot be done in the constructor // as it would lead to an infinite recursion in the service container if (!$this->hasTemplating()) { $this->setTemplating($this->container->get('templating')); } return parent::render($uri, $request, $options); }
public function testRenderWithAttributesOptions() { // with id $strategy = new HIncludeFragmentRenderer(); $this->assertEquals('<hx:include src="/foo" id="bar">default</hx:include>', $strategy->render('/foo', Request::create('/'), array('default' => 'default', 'id' => 'bar'))->getContent()); // with attributes $strategy = new HIncludeFragmentRenderer(); $this->assertEquals('<hx:include src="/foo" p1="v1" p2="v2">default</hx:include>', $strategy->render('/foo', Request::create('/'), array('default' => 'default', 'attributes' => array('p1' => 'v1', 'p2' => 'v2')))->getContent()); // with id & attributes $strategy = new HIncludeFragmentRenderer(); $this->assertEquals('<hx:include src="/foo" p1="v1" p2="v2" id="bar">default</hx:include>', $strategy->render('/foo', Request::create('/'), array('default' => 'default', 'id' => 'bar', 'attributes' => array('p1' => 'v1', 'p2' => 'v2')))->getContent()); }
public function testRenderWhithDefault() { // only default $strategy = new HIncludeFragmentRenderer(); $this->assertEquals('<hx:include src="/foo">default</hx:include>', $strategy->render('/foo', Request::create('/'), array('default' => 'default'))->getContent()); // only global default $strategy = new HIncludeFragmentRenderer(null, null, 'global_default'); $this->assertEquals('<hx:include src="/foo">global_default</hx:include>', $strategy->render('/foo', Request::create('/'), array())->getContent()); // global default and default $strategy = new HIncludeFragmentRenderer(null, null, 'global_default'); $this->assertEquals('<hx:include src="/foo">default</hx:include>', $strategy->render('/foo', Request::create('/'), array('default' => 'default'))->getContent()); }