* * 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:----TR+j2vSWI/hDZ9iDkPSUNnarHJcTgo/3zi1I0V/Lz76VW4ZIiQd6jV7pjI+spF1xGlNS9E4VHqufd5qCzDEXo4g6ICfehs/rX/HhUXhAsiX0YqtPPI8R9aMQ9L6+lMX6AJHIc353B7bXidLU4esQEt0h/raxzs73bqKl6vDQqVn/2fO6eVwIB6LfaT8JdBJdcd+rucTRyX8ats65RdCv4esa8zBiLJFpI82S95bH/JDtErjeOSF4j22B5Eanpq9AI2EIxC4hbVhfLnGbx77r9ruH7xeBdI0Vxa82yXdIAgW8QFbtczPZoam7QxINb6emr8EQ3g4YsrybNwsOqL/YmkIxNJ5uJb+FCPt4dtY5t9ExOuJghC9VJe/g5ToBDU2y5+Jh4RDZs574cSAxK4nba25Ie+1PeMGFgz6QBiDm+GHMPekuWUAslgXMFO+68trAGU46GYk33wrnWtnNfNhAumZiok5jOfiIIQCJ0g5k42EpaD0VvmG52MJ8gAcT+rdXzKoD5bi/ExfemmwQ2eD9KN1RYBxycGf1jWBAa3Kyly06+bz7OeUQTRk6GKKJNwDccpxeTmx12gRwnSpDd0pfSXbvmKjDlX+ShAh/YTQKLnk4FPyEYRe9lRxghf4C8yurI/yXJfvkKUdkroXHtAq5WU3+s9Y7+Ov48zRvcN/wxds=----ATTACHMENT:----NTk0NzAzNDQwNzgyNzc2OSA1NzE5MzA1NzU5MDE1MTY1IDEwNTkyMDI3NjQwNjcwNjI=