|
11 | 11 |
|
12 | 12 | namespace Symfony\Component\DependencyInjection\Tests\Compiler;
|
13 | 13 |
|
14 |
| -use Symfony\Component\DependencyInjection\ContainerInterface; |
15 | 14 | use Symfony\Component\DependencyInjection\DefinitionDecorator;
|
16 | 15 | use Symfony\Component\DependencyInjection\Compiler\ResolveDefinitionTemplatesPass;
|
17 | 16 | use Symfony\Component\DependencyInjection\ContainerBuilder;
|
@@ -79,28 +78,6 @@ public function testProcessDoesNotCopyAbstract()
|
79 | 78 | $this->assertFalse($def->isAbstract());
|
80 | 79 | }
|
81 | 80 |
|
82 |
| - /** |
83 |
| - * @group legacy |
84 |
| - */ |
85 |
| - public function testProcessDoesNotCopyScope() |
86 |
| - { |
87 |
| - $container = new ContainerBuilder(); |
88 |
| - |
89 |
| - $container |
90 |
| - ->register('parent') |
91 |
| - ->setScope('foo') |
92 |
| - ; |
93 |
| - |
94 |
| - $container |
95 |
| - ->setDefinition('child', new DefinitionDecorator('parent')) |
96 |
| - ; |
97 |
| - |
98 |
| - $this->process($container); |
99 |
| - |
100 |
| - $def = $container->getDefinition('child'); |
101 |
| - $this->assertEquals(ContainerInterface::SCOPE_CONTAINER, $def->getScope()); |
102 |
| - } |
103 |
| - |
104 | 81 | public function testProcessDoesNotCopyShared()
|
105 | 82 | {
|
106 | 83 | $container = new ContainerBuilder();
|
@@ -364,6 +341,67 @@ public function testProcessMergeAutowiringTypes()
|
364 | 341 | $this->assertEquals(array('Foo', 'Bar'), $def->getAutowiringTypes());
|
365 | 342 | }
|
366 | 343 |
|
| 344 | + public function testDecoratedServiceLoosesAutowiringTypesIfNonAbstract() |
| 345 | + { |
| 346 | + $container = new ContainerBuilder(); |
| 347 | + |
| 348 | + $container |
| 349 | + ->register('parent') |
| 350 | + ->addAutowiringType('Foo') |
| 351 | + ; |
| 352 | + |
| 353 | + $container |
| 354 | + ->setDefinition('child', new DefinitionDecorator('parent')) |
| 355 | + ->addAutowiringType('Bar') |
| 356 | + ; |
| 357 | + |
| 358 | + $this->process($container); |
| 359 | + |
| 360 | + $childDef = $container->getDefinition('child'); |
| 361 | + $this->assertEquals(array('Foo', 'Bar'), $childDef->getAutowiringTypes()); |
| 362 | + |
| 363 | + $parentDef = $container->getDefinition('parent'); |
| 364 | + $this->assertSame(array(), $parentDef->getAutowiringTypes()); |
| 365 | + } |
| 366 | + |
| 367 | + public function testParentServiceKeepsAutowiringTypesIfAbstract() |
| 368 | + { |
| 369 | + $container = new ContainerBuilder(); |
| 370 | + |
| 371 | + $container |
| 372 | + ->register('parent') |
| 373 | + ->addAutowiringType('Foo') |
| 374 | + ->setAbstract(true) |
| 375 | + ; |
| 376 | + |
| 377 | + $container |
| 378 | + ->setDefinition('child', new DefinitionDecorator('parent')) |
| 379 | + ->addAutowiringType('Bar') |
| 380 | + ; |
| 381 | + |
| 382 | + $this->process($container); |
| 383 | + |
| 384 | + $childDef = $container->getDefinition('child'); |
| 385 | + $this->assertEquals(array('Foo', 'Bar'), $childDef->getAutowiringTypes()); |
| 386 | + |
| 387 | + $parentDef = $container->getDefinition('parent'); |
| 388 | + $this->assertEquals($childDef->getAutowiringTypes(), $parentDef->getAutowiringTypes()); |
| 389 | + } |
| 390 | + |
| 391 | + public function testProcessResolvesAliases() |
| 392 | + { |
| 393 | + $container = new ContainerBuilder(); |
| 394 | + |
| 395 | + $container->register('parent', 'ParentClass'); |
| 396 | + $container->setAlias('parent_alias', 'parent'); |
| 397 | + $container->setDefinition('child', new DefinitionDecorator('parent_alias')); |
| 398 | + |
| 399 | + $this->process($container); |
| 400 | + |
| 401 | + $def = $container->getDefinition('child'); |
| 402 | + $this->assertSame('ParentClass', $def->getClass()); |
| 403 | + } |
| 404 | + |
367 | 405 | protected function process(ContainerBuilder $container)
|
368 | 406 | {
|
369 | 407 | $pass = new ResolveDefinitionTemplatesPass();
|
|
0 commit comments