protected function getFragmentHandler($return) { $strategy = $this->getMock('Symfony\\Component\\HttpKernel\\Fragment\\FragmentRendererInterface'); $strategy->expects($this->once())->method('getName')->will($this->returnValue('inline')); $strategy->expects($this->once())->method('render')->will($return); // simulate a master request $event = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\Event\\GetResponseEvent')->disableOriginalConstructor()->getMock(); $event->expects($this->once())->method('getRequest')->will($this->returnValue(Request::create('/'))); $renderer = new FragmentHandler(array($strategy)); $renderer->onKernelRequest($event); return $renderer; }
protected function getHandler($returnValue, $arguments = array()) { $renderer = $this->getMock('Symfony\\Component\\HttpKernel\\Fragment\\FragmentRendererInterface'); $renderer->expects($this->any())->method('getName')->will($this->returnValue('foo')); $e = $renderer->expects($this->any())->method('render')->will($returnValue); if ($arguments) { call_user_func_array(array($e, 'with'), $arguments); } $handler = new FragmentHandler(); $handler->addRenderer($renderer); $event = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\Event\\GetResponseEvent')->disableOriginalConstructor()->getMock(); $event->expects($this->once())->method('getRequest')->will($this->returnValue(Request::create('/'))); $handler->onKernelRequest($event); return $handler; }