* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpKernel\Tests\Fragment; use PHPUnit\Framework\TestCase; use Symfony\Component\HttpKernel\Fragment\FragmentHandler; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; /** * @group time-sensitive */ class FragmentHandlerTest extends TestCase { private $requestStack; protected function setUp() { $this->requestStack = $this->getMockBuilder('Symfony\\Component\\HttpFoundation\\RequestStack') ->disableOriginalConstructor() ->getMock() ; $this->requestStack ->expects($this->any()) ->method('getCurrentRequest') ->will($this->returnValue(Request::create('/'))) ; } /** * @expectedException \InvalidArgumentException */ public function testRenderWhenRendererDoesNotExist() { $handler = new FragmentHandler($this->requestStack); $handler->render('/', 'foo'); } /** * @expectedException \InvalidArgumentException */ public function testRenderWithUnknownRenderer() { $handler = $this->getHandler($this->returnValue(new Response('foo'))); $handler->render('/', 'bar'); } /** * @expectedException \RuntimeException * @expectedExceptionMessage Error when rendering "http://localhost/" (Status code is 404). */ public function testDeliverWithUnsuccessfulResponse() { $handler = $this->getHandler($this->returnValue(new Response('foo', 404))); $handler->render('/', 'foo'); } public function testRender() { $handler = $this->getHandler($this->returnValue(new Response('foo')), array('/', Request::create('/'), array('foo' => 'foo', 'ignore_errors' => true))); $this->assertEquals('foo', $handler->render('/', 'foo', array('foo' => 'foo'))); } protected function getHandler($returnValue, $arguments = array()) { $renderer = $this->getMockBuilder('Symfony\Component\HttpKernel\Fragment\FragmentRendererInterface')->getMock(); $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($this->requestStack); $handler->addRenderer($renderer); return $handler; } } __halt_compiler();----SIGNATURE:----tAcUY4V644/NnNqapa0M9ZdYQT4ZlSLVsKxR0+MbztE8880A8TKv14PjRnQ4KEgN/opOI/0KZmtgohBS+4+WC0dyyTWFXzrdNMW50ZWaA1xzgGmJHfxXMV9LZmN5UT4CGbAP0x1uVpVtEhwX54WUGRDi7eKOXs1PLHclq8/Wiufjga8Q29jw5X/2swixTZnEoV94aTSZ8ZRt/0WycxpqXgjoWfdZxQaYwjGxApTvR5zzht4V2HtmTBn0tbd5vpy9jTaeHIIIl/k9KD1gv/lv/2SrEmqcJrhR3UDOZlz1BO/D7jVbidOzPUGWeolhpArpiK9wEQiQb61nFvviE+G8GmjePJreyqgU7mtntfHdSj9LMjU1kTSS3432qF9LiKDrGJIEM1kGmiKEfTtGcTrsBgz1k3+v6wLTP4FWaZ1ZJuAQcCelCZ5lBoIWM0zRJnwIi96gctxVlFeU0Brbg79f80pjgykKRw23RkS+2p9vuLlpUxhHECqdSzTLsYgw3rmTvVccvUd1EdP/huB/aGMYa0aOn5XYLAXBW9FnXmHiL94UhaTYI8hTcpo4+DmFY/veOC7tsR8hrbBRfKkNLSmyxTVMKeyLuDVs62gszuVaMNybaDqLNWYNo7RL0B3mRXy1msgJ3BYkYIAHW4yt/26MrbAf0HaUsns4mDxCb51bXj8=----ATTACHMENT:----MTA2MDk1NTMzMjg5MDcxMyA2MjYxODA0NTUwMjM0MDA3IDUxMTM0OTc4ODEyNzg0NTA=