*
* 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:----fjNzxZAoSE7I/WGUdBh0FtEGwhOTHCk9fvz1XPC5s5HCE4CjroYP9IGZbRBCMJ6F7j9a+JsS0jHTB6a/rnMFMvQZK87Ss+29/LOo2qMg9evrUXyr3hLhiHW0qFWNTZxnXg7jBmUdYoN50biQuhstlvnbs+nPTIea0MmbHeY9vSpkupFM5Or+KIe5KA0Gvs7SRTQUMNqf3gNwUmouvQQhfWXgkChDBCgp4lDjaGW3K3ieJsr0/BdB6STEtyT5zrc/D2GpSE8lgAzGPI0kJ7OswLcJpM0goH2iCOtFScCUk0qEZ9GIh46FgJb/f6uUa3WH/D1vS6apzsJxfUN9Zf5Yry+Txmx8F50M+FdQoAWQIQIeSmfHZc9fyrh7dv60vQvmEPXX7WiBwNYWrQ2jZ10cvKCliueWE+1qOmLhVr9avl1vDXZ9sGZJXY9c3wlaOITm+caOILyZ0KT0X7YYTZUwghx8W9ykon7EBA7YDkIG4VrE//xhXwgKtAFND2ADQrHHAK0QtTiuQNZe/XuHIFlXDqsvUv/Yg/QQGe61QoMlOSzALJAkuwaXOfw4jhJNF6hM7TbTE7WYhG6F/7bhHr7nItEoHAPF+juVxG0/rnSkGiVItGSs5yXVvNVAdgFSNoFe4uFNSuufD6zlT+zEfkRCETeCvf0dr9PAk7qmNCmRAyU=----ATTACHMENT:----Njk1MzI4MTQ5NTAxMTM3OCA3MTA4NTAyNTU0MTM2OTQ2IDc2MDQ3NDQwOTY2NDM3NzE=