|
17 | 17 | use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument;
|
18 | 18 | use Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument;
|
19 | 19 | use Symfony\Component\DependencyInjection\Argument\TaggedIteratorArgument;
|
| 20 | +use Symfony\Component\DependencyInjection\Compiler\AutowirePass; |
20 | 21 | use Symfony\Component\DependencyInjection\ContainerBuilder;
|
21 | 22 | use Symfony\Component\DependencyInjection\ContainerInterface;
|
22 | 23 | use Symfony\Component\DependencyInjection\Definition;
|
23 | 24 | use Symfony\Component\DependencyInjection\Dumper\YamlDumper;
|
24 | 25 | use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
|
25 | 26 | use Symfony\Component\DependencyInjection\Reference;
|
| 27 | +use Symfony\Component\DependencyInjection\Tests\Fixtures\FooClassWithDefaultArrayAttribute; |
| 28 | +use Symfony\Component\DependencyInjection\Tests\Fixtures\FooClassWithDefaultEnumAttribute; |
| 29 | +use Symfony\Component\DependencyInjection\Tests\Fixtures\FooClassWithDefaultObjectAttribute; |
26 | 30 | use Symfony\Component\DependencyInjection\Tests\Fixtures\FooClassWithEnumAttribute;
|
27 | 31 | use Symfony\Component\DependencyInjection\Tests\Fixtures\FooUnitEnum;
|
28 | 32 | use Symfony\Component\DependencyInjection\Tests\Fixtures\FooWithAbstractArgument;
|
@@ -153,6 +157,34 @@ public function testDumpHandlesEnumeration()
|
153 | 157 | $this->assertEquals(file_get_contents(self::$fixturesPath.'/yaml/services_with_enumeration.yml'), $dumper->dump());
|
154 | 158 | }
|
155 | 159 |
|
| 160 | + /** |
| 161 | + * @requires PHP 8.1 |
| 162 | + * |
| 163 | + * @dataProvider provideDefaultClasses |
| 164 | + */ |
| 165 | + public function testDumpHandlesDefaultAttribute($class, $expectedFile) |
| 166 | + { |
| 167 | + $container = new ContainerBuilder(); |
| 168 | + $container |
| 169 | + ->register('foo', $class) |
| 170 | + ->setPublic(true) |
| 171 | + ->setAutowired(true) |
| 172 | + ->setArguments([2 => true]); |
| 173 | + |
| 174 | + (new AutowirePass())->process($container); |
| 175 | + |
| 176 | + $dumper = new YamlDumper($container); |
| 177 | + |
| 178 | + $this->assertSame(file_get_contents(self::$fixturesPath.'/yaml/'.$expectedFile), $dumper->dump()); |
| 179 | + } |
| 180 | + |
| 181 | + public static function provideDefaultClasses() |
| 182 | + { |
| 183 | + yield [FooClassWithDefaultArrayAttribute::class, 'services_with_default_array.yml']; |
| 184 | + yield [FooClassWithDefaultObjectAttribute::class, 'services_with_default_object.yml']; |
| 185 | + yield [FooClassWithDefaultEnumAttribute::class, 'services_with_default_enumeration.yml']; |
| 186 | + } |
| 187 | + |
156 | 188 | public function testDumpServiceWithAbstractArgument()
|
157 | 189 | {
|
158 | 190 | $container = new ContainerBuilder();
|
|
0 commit comments