minor #13402 [HttpKernel] fixed missing use cases (fabpot)
This PR was merged into the 2.7 branch.
Discussion
----------
[HttpKernel] fixed missing use cases
| Q | A
| ------------- | ---
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | n/a
| License | MIT
| Doc PR | n/a
Commits
-------
969c5d9
[HttpKernel] fixed missing use cases
This commit is contained in:
commit
98243180df
@ -60,13 +60,13 @@ class FragmentRendererPass implements CompilerPassInterface
|
||||
|
||||
foreach ($tags as $tag) {
|
||||
if (!isset($tag['alias'])) {
|
||||
trigger_error(sprintf('Service "%s" will have to define the "alias" attribute on the "%s" tag as of Symfony 3.0.', $id, $this->fragmentTag), E_USER_DEPRECATED);
|
||||
trigger_error(sprintf('Service "%s" will have to define the "alias" attribute on the "%s" tag as of Symfony 3.0.', $id, $this->rendererTag), E_USER_DEPRECATED);
|
||||
|
||||
// register the handler as a non-lazy-loaded one
|
||||
$definition->addMethodCall('addRenderer', array(new Reference($id)));
|
||||
} else {
|
||||
$definition->addMethodCall('addRendererService', array($tag['alias'], $id));
|
||||
}
|
||||
|
||||
$definition->addMethodCall('addRendererService', array($tag['alias'], $id));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,12 +11,60 @@
|
||||
|
||||
namespace Symfony\Component\HttpKernel\Tests\DependencyInjection;
|
||||
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpKernel\DependencyInjection\FragmentRendererPass;
|
||||
use Symfony\Component\HttpKernel\Fragment\FragmentRendererInterface;
|
||||
|
||||
class FragmentRendererPassTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testLegacyFragmentRedererWithoutAlias()
|
||||
{
|
||||
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
|
||||
|
||||
// no alias
|
||||
$services = array(
|
||||
'my_content_renderer' => array(array()),
|
||||
);
|
||||
|
||||
$renderer = $this->getMock('Symfony\Component\DependencyInjection\Definition');
|
||||
$renderer
|
||||
->expects($this->once())
|
||||
->method('addMethodCall')
|
||||
->with('addRenderer', array(new Reference('my_content_renderer')))
|
||||
;
|
||||
|
||||
$definition = $this->getMock('Symfony\Component\DependencyInjection\Definition');
|
||||
$definition->expects($this->atLeastOnce())
|
||||
->method('getClass')
|
||||
->will($this->returnValue('Symfony\Component\HttpKernel\Tests\DependencyInjection\RendererService'));
|
||||
$definition
|
||||
->expects($this->once())
|
||||
->method('isPublic')
|
||||
->will($this->returnValue(true))
|
||||
;
|
||||
|
||||
$builder = $this->getMock(
|
||||
'Symfony\Component\DependencyInjection\ContainerBuilder',
|
||||
array('hasDefinition', 'findTaggedServiceIds', 'getDefinition')
|
||||
);
|
||||
$builder->expects($this->any())
|
||||
->method('hasDefinition')
|
||||
->will($this->returnValue(true));
|
||||
|
||||
// We don't test kernel.fragment_renderer here
|
||||
$builder->expects($this->atLeastOnce())
|
||||
->method('findTaggedServiceIds')
|
||||
->will($this->returnValue($services));
|
||||
|
||||
$builder->expects($this->atLeastOnce())
|
||||
->method('getDefinition')
|
||||
->will($this->onConsecutiveCalls($renderer, $definition));
|
||||
|
||||
$pass = new FragmentRendererPass();
|
||||
$pass->process($builder);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that content rendering not implementing FragmentRendererInterface
|
||||
* trigger an exception.
|
||||
@ -27,7 +75,7 @@ class FragmentRendererPassTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
// one service, not implementing any interface
|
||||
$services = array(
|
||||
'my_content_renderer' => array('alias' => 'foo'),
|
||||
'my_content_renderer' => array(array('alias' => 'foo')),
|
||||
);
|
||||
|
||||
$definition = $this->getMock('Symfony\Component\DependencyInjection\Definition');
|
||||
|
Reference in New Issue
Block a user