* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpKernel\Tests\DependencyInjection; use PHPUnit\Framework\TestCase; use Symfony\Component\HttpKernel\DependencyInjection\LazyLoadingFragmentHandler; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; class LazyLoadingFragmentHandlerTest extends TestCase { /** * @group legacy * @expectedDeprecation The Symfony\Component\HttpKernel\DependencyInjection\LazyLoadingFragmentHandler::addRendererService() method is deprecated since Symfony 3.3 and will be removed in 4.0. */ public function testRenderWithLegacyMapping() { $renderer = $this->getMockBuilder('Symfony\Component\HttpKernel\Fragment\FragmentRendererInterface')->getMock(); $renderer->expects($this->once())->method('getName')->will($this->returnValue('foo')); $renderer->expects($this->any())->method('render')->will($this->returnValue(new Response())); $requestStack = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestStack')->getMock(); $requestStack->expects($this->any())->method('getCurrentRequest')->will($this->returnValue(Request::create('/'))); $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock(); $container->expects($this->once())->method('get')->will($this->returnValue($renderer)); $handler = new LazyLoadingFragmentHandler($container, $requestStack, false); $handler->addRendererService('foo', 'foo'); $handler->render('/foo', 'foo'); // second call should not lazy-load anymore (see once() above on the get() method) $handler->render('/foo', 'foo'); } public function testRender() { $renderer = $this->getMockBuilder('Symfony\Component\HttpKernel\Fragment\FragmentRendererInterface')->getMock(); $renderer->expects($this->once())->method('getName')->will($this->returnValue('foo')); $renderer->expects($this->any())->method('render')->will($this->returnValue(new Response())); $requestStack = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestStack')->getMock(); $requestStack->expects($this->any())->method('getCurrentRequest')->will($this->returnValue(Request::create('/'))); $container = $this->getMockBuilder('Psr\Container\ContainerInterface')->getMock(); $container->expects($this->once())->method('has')->with('foo')->willReturn(true); $container->expects($this->once())->method('get')->will($this->returnValue($renderer)); $handler = new LazyLoadingFragmentHandler($container, $requestStack, false); $handler->render('/foo', 'foo'); // second call should not lazy-load anymore (see once() above on the get() method) $handler->render('/foo', 'foo'); } } __halt_compiler();----SIGNATURE:----Y4/kw/fneMXPbSBMjd4U59GSpdcHoDDSRcwo+euagSpwO/1ksTyNisH50JA7xE0wIvr9u7xEHlachE8z5t3NMUjpuBgYkxSfcm3OLvhJpFpBcVo4LKkWYPTt6nvVcXN9AJ70ICdzyN4zYklfEgIGA28I5SiNqAqoaqDg/bcagfmRpR2fwsL3u5ChjylOaaJvnbRa9E+pprXSvn7AiOe3vGYOEN/b4xy1EYYqea6Kvjn+hwxT+9M4U4BEIfDyJAWF2gTIYfbMm6mJrJeW1z0mHXsiDP/J9y1XASege9CNDmqC1y/SeuOdKBBpy+JxDHdXL/z+5wyZwqtsRglvuEDT/KItlS+OVOzDg7pKcjrOZIiQqtom15Nkk9OltArwVELN84O8RxZfNVYcC42BqACJOSrjTjfnPgscqoQesEuWRbwkkQT7LHjXStrHbt5UZ/I12KnNftUdYek61jZi9/DuhRDjWTcJYNh2rTqWDYzt2TsuYlS1W2GijVuYmLSDIdMVeUIjTrFZ2dntJWtVN8TNEe0HLkIgnNqUeXBumoutlQRcn527q5k4SePLudvefGwajF14SQA9yGVpsUcPbo3qNk3DNEak/38yA54fSbsznbr2Uc47KnbbbOO4kHZ7S31Ou4Q/+HFprL6mlzQMlH3E8oxKY/QAmUnLM+QOalekZNE=----ATTACHMENT:----NzY2MjI3MTQxNDY1NDYwNyA2Nzc0NDY0NDM5ODA2ODMgNTgyMjA0OTY1MjE2Mzc3MQ==