[DependencyInjection] fixed definition loosing property shared when decorated by a parent definition
This commit is contained in:
parent
e18a42af49
commit
d3a4a770a6
@ -211,6 +211,7 @@ class ResolveDefinitionTemplatesPass implements CompilerPassInterface
|
||||
// these attributes are always taken from the child
|
||||
$def->setAbstract($definition->isAbstract());
|
||||
$def->setScope($definition->getScope(false), false);
|
||||
$def->setShared($definition->isShared());
|
||||
$def->setTags($definition->getTags());
|
||||
|
||||
return $def;
|
||||
|
@ -101,6 +101,25 @@ class ResolveDefinitionTemplatesPassTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals(ContainerInterface::SCOPE_CONTAINER, $def->getScope());
|
||||
}
|
||||
|
||||
public function testProcessDoesNotCopyShared()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
|
||||
$container
|
||||
->register('parent')
|
||||
->setShared(false)
|
||||
;
|
||||
|
||||
$container
|
||||
->setDefinition('child', new DefinitionDecorator('parent'))
|
||||
;
|
||||
|
||||
$this->process($container);
|
||||
|
||||
$def = $container->getDefinition('child');
|
||||
$this->assertTrue($def->isShared());
|
||||
}
|
||||
|
||||
public function testProcessDoesNotCopyTags()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
@ -139,6 +158,25 @@ class ResolveDefinitionTemplatesPassTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertNull($def->getDecoratedService());
|
||||
}
|
||||
|
||||
public function testProcessDoesNotDropShared()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
|
||||
$container
|
||||
->register('parent')
|
||||
;
|
||||
|
||||
$container
|
||||
->setDefinition('child', new DefinitionDecorator('parent'))
|
||||
->setShared(false)
|
||||
;
|
||||
|
||||
$this->process($container);
|
||||
|
||||
$def = $container->getDefinition('child');
|
||||
$this->assertFalse($def->isShared());
|
||||
}
|
||||
|
||||
public function testProcessHandlesMultipleInheritance()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
|
Reference in New Issue
Block a user