*
* 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\HIncludeFragmentRenderer;
use Symfony\Component\HttpKernel\UriSigner;
use Symfony\Component\HttpFoundation\Request;
class HIncludeFragmentRendererTest extends TestCase
{
/**
* @expectedException \LogicException
*/
public function testRenderExceptionWhenControllerAndNoSigner()
{
$strategy = new HIncludeFragmentRenderer();
$strategy->render(new ControllerReference('main_controller', array(), array()), Request::create('/'));
}
public function testRenderWithControllerAndSigner()
{
$strategy = new HIncludeFragmentRenderer(null, new UriSigner('foo'));
$this->assertEquals('', $strategy->render(new ControllerReference('main_controller', array(), array()), Request::create('/'))->getContent());
}
public function testRenderWithUri()
{
$strategy = new HIncludeFragmentRenderer();
$this->assertEquals('', $strategy->render('/foo', Request::create('/'))->getContent());
$strategy = new HIncludeFragmentRenderer(null, new UriSigner('foo'));
$this->assertEquals('', $strategy->render('/foo', Request::create('/'))->getContent());
}
public function testRenderWithDefault()
{
// only default
$strategy = new HIncludeFragmentRenderer();
$this->assertEquals('default', $strategy->render('/foo', Request::create('/'), array('default' => 'default'))->getContent());
// only global default
$strategy = new HIncludeFragmentRenderer(null, null, 'global_default');
$this->assertEquals('global_default', $strategy->render('/foo', Request::create('/'), array())->getContent());
// global default and default
$strategy = new HIncludeFragmentRenderer(null, null, 'global_default');
$this->assertEquals('default', $strategy->render('/foo', Request::create('/'), array('default' => 'default'))->getContent());
}
public function testRenderWithAttributesOptions()
{
// with id
$strategy = new HIncludeFragmentRenderer();
$this->assertEquals('default', $strategy->render('/foo', Request::create('/'), array('default' => 'default', 'id' => 'bar'))->getContent());
// with attributes
$strategy = new HIncludeFragmentRenderer();
$this->assertEquals('default', $strategy->render('/foo', Request::create('/'), array('default' => 'default', 'attributes' => array('p1' => 'v1', 'p2' => 'v2')))->getContent());
// with id & attributes
$strategy = new HIncludeFragmentRenderer();
$this->assertEquals('default', $strategy->render('/foo', Request::create('/'), array('default' => 'default', 'id' => 'bar', 'attributes' => array('p1' => 'v1', 'p2' => 'v2')))->getContent());
}
public function testRenderWithDefaultText()
{
$engine = $this->getMockBuilder('Symfony\\Component\\Templating\\EngineInterface')->getMock();
$engine->expects($this->once())
->method('exists')
->with('default')
->will($this->throwException(new \InvalidArgumentException()));
// only default
$strategy = new HIncludeFragmentRenderer($engine);
$this->assertEquals('default', $strategy->render('/foo', Request::create('/'), array('default' => 'default'))->getContent());
}
}
__halt_compiler();----SIGNATURE:----fRvcbhXFIGvX0siYpiDeFen114NQXWE2QY1uyJzNhbiQFFFcJ7oALU1lk/K/OFxep9cNx6c1TvHboccdN074Ow58Shw7FOsr0u8ePZ8Wx2r2aS5FcL6lA0D09uA3bp2JvCtVPf9byZJRxMKuCTv4ONR0KrOBskArMJ8imjK7sLs6jQRkqn/wGvhHlsbk1OK+TvMYaQfHVN4hz9twEWq14qYPYe/oj9RqsPwfFFQJjqqy88xTM/DxIn/WtIuAKtELd2FzcTq+hupjVzRKvEjvDmdV9Uctvq5j+CqtqJ0fq5I1DUf/ELCKiwH+1UqcQhhUwv8IeqJLlOhTWo12iegAPj2JHkVevCxKcU4sbjbvUstKHkAP0pG8rtR73gBSAOYFqPMLCDp/yEBP8xlz8IDjRTSZXivl6l4uCOH64hip1VI7Ms2ftRV+2C+k8+qC8nk5/DQYaYUMi8W/bMQXy+nrMQfrYPg0tsxwgwEau7oOoFF6rb9CvRpJcCbK/8sDuoJ9MLicCwyGobGIR23QSbQvs48bzRdBVy78Xv4pY4ciJky7dIWCh1SiQ1d6AntJBLKcBlTip3xwiBaChe3oK+r53gJfu20A8fiCmbJPRJJztSLZizCFkxS9/O4ZOz0C1m6ZTtuC2lPPji7wksJIvPpounFZho1AUG1Al/hX4Z65vvE=----ATTACHMENT:----OTkxMzY3MzM1NDA0NjI3NCAxODU1MDU1NDg0Mjg5MDcyIDc2MjA1OTAxNDgxNzQwOTQ=