* * 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\Controller\ControllerReference; use Symfony\Component\HttpKernel\Fragment\EsiFragmentRenderer; use Symfony\Component\HttpKernel\HttpCache\Esi; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\UriSigner; class EsiFragmentRendererTest extends TestCase { public function testRenderFallbackToInlineStrategyIfEsiNotSupported() { $strategy = new EsiFragmentRenderer(new Esi(), $this->getInlineStrategy(true)); $strategy->render('/', Request::create('/')); } /** * @group legacy * @expectedDeprecation Passing non-scalar values as part of URI attributes to the ESI and SSI rendering strategies is deprecated %s. */ public function testRenderFallbackWithObjectAttributesIsDeprecated() { $strategy = new EsiFragmentRenderer(new Esi(), $this->getInlineStrategy(true), new UriSigner('foo')); $request = Request::create('/'); $reference = new ControllerReference('main_controller', array('foo' => new \stdClass()), array()); $strategy->render($reference, $request); } public function testRenderFallbackWithScalarIsNotDeprecated() { $strategy = new EsiFragmentRenderer(new Esi(), $this->getInlineStrategy(true), new UriSigner('foo')); $request = Request::create('/'); $reference = new ControllerReference('main_controller', array('foo' => array(true)), array()); $strategy->render($reference, $request); } public function testRender() { $strategy = new EsiFragmentRenderer(new Esi(), $this->getInlineStrategy()); $request = Request::create('/'); $request->setLocale('fr'); $request->headers->set('Surrogate-Capability', 'ESI/1.0'); $this->assertEquals('', $strategy->render('/', $request)->getContent()); $this->assertEquals("\n", $strategy->render('/', $request, array('comment' => 'This is a comment'))->getContent()); $this->assertEquals('', $strategy->render('/', $request, array('alt' => 'foo'))->getContent()); } public function testRenderControllerReference() { $signer = new UriSigner('foo'); $strategy = new EsiFragmentRenderer(new Esi(), $this->getInlineStrategy(), $signer); $request = Request::create('/'); $request->setLocale('fr'); $request->headers->set('Surrogate-Capability', 'ESI/1.0'); $reference = new ControllerReference('main_controller', array(), array()); $altReference = new ControllerReference('alt_controller', array(), array()); $this->assertEquals( '', $strategy->render($reference, $request, array('alt' => $altReference))->getContent() ); } /** * @expectedException \LogicException */ public function testRenderControllerReferenceWithoutSignerThrowsException() { $strategy = new EsiFragmentRenderer(new Esi(), $this->getInlineStrategy()); $request = Request::create('/'); $request->setLocale('fr'); $request->headers->set('Surrogate-Capability', 'ESI/1.0'); $strategy->render(new ControllerReference('main_controller'), $request); } /** * @expectedException \LogicException */ public function testRenderAltControllerReferenceWithoutSignerThrowsException() { $strategy = new EsiFragmentRenderer(new Esi(), $this->getInlineStrategy()); $request = Request::create('/'); $request->setLocale('fr'); $request->headers->set('Surrogate-Capability', 'ESI/1.0'); $strategy->render('/', $request, array('alt' => new ControllerReference('alt_controller'))); } private function getInlineStrategy($called = false) { $inline = $this->getMockBuilder('Symfony\Component\HttpKernel\Fragment\InlineFragmentRenderer')->disableOriginalConstructor()->getMock(); if ($called) { $inline->expects($this->once())->method('render'); } return $inline; } } __halt_compiler();----SIGNATURE:----bwIpTGm4VAb6nArRwcPIoYnLSRZpFwW1EzUiDOAJs3nHF1xeigwHsC0XCGUOTxkkBPtqSzOYhHwY6XRub4mKgPa3XrVR+/qv+vUzOh+iFW3JdFuflde6zSO2kzJD9rVfpIfaxz960Gh8syngGPgt07+lfdGpqtQ4pDPIYHR3srQMsN6OqdVpUdOr4Nxtm48e6K1YwYCBrRAaxS9U+bBMUrmMH4+SCl5TQN9hnyTDDVwBBw+M7A0k/O3+i0/IuDWG94BeM6mvHj+OjL7VnD2NKELyEEU7Rx4eykr+nN1sEsKrQ5j7i3LVx4OAbEyBWtOvHnvMY3eeZUg0+fCngMKLSOP0F1in5rOEW2qpnwOTg53fNDk6q42xjz7xwKJqu9E1D1hbNJV2WtEiPNoUCFzuLjPr1KEQzIpoTbFzZAFp2cr/aSwLBbMKSB0YEXUBSsAPm47bxo5ItFi5jF0GCmthmh44a3g/NLdpK9bIV/dv+cqELs46QxuiXx7hEUOXfO814NJB91vvqx5O3Zz5N36JL+DvV/Erm7nu9GQMPT1nCUNgtF1/dxZvKKZ+QrxvEJ7iJ45cYTRlaViBI2e5SZVoV7akB4xFreVSZLCsIwohgp+Imd3YVjklcAb0HtC1atfZxuuJhvv9TQ8+Lq40NUAVLdsdM3J1PAWiAaF3bPtvyYE=----ATTACHMENT:----Njc0ODEwODA0MjMzNjY4IDI1ODQ0OTkyMjYyMzI1NzAgMjMwMTI2NzM2NDc1MDAwNA==