|
45 | 45 | use Symfony\Component\DependencyInjection\Tests\Fixtures\FooWithAbstractArgument;
|
46 | 46 | use Symfony\Component\DependencyInjection\Tests\Fixtures\NamedArgumentsDummy;
|
47 | 47 | use Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype;
|
| 48 | +use Symfony\Component\DependencyInjection\Tests\Fixtures\RemoteCaller; |
| 49 | +use Symfony\Component\DependencyInjection\Tests\Fixtures\RemoteCallerHttp; |
| 50 | +use Symfony\Component\DependencyInjection\Tests\Fixtures\RemoteCallerSocket; |
48 | 51 | use Symfony\Component\ExpressionLanguage\Expression;
|
49 | 52 |
|
50 | 53 | class XmlFileLoaderTest extends TestCase
|
@@ -1277,7 +1280,7 @@ public function testStaticConstructor()
|
1277 | 1280 | public function testStaticConstructorWithFactoryThrows()
|
1278 | 1281 | {
|
1279 | 1282 | $container = new ContainerBuilder();
|
1280 |
| - $loader = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml')); |
| 1283 | + $loader = new XmlFileLoader($container, new FileLocator(self::$fixturesPath . '/xml')); |
1281 | 1284 |
|
1282 | 1285 | $this->expectException(LogicException::class);
|
1283 | 1286 | $this->expectExceptionMessage('The "static_constructor" service cannot declare a factory as well as a constructor.');
|
@@ -1338,10 +1341,25 @@ public function testUnknownConstantAsKey()
|
1338 | 1341 | public function testDeprecatedTagged()
|
1339 | 1342 | {
|
1340 | 1343 | $container = new ContainerBuilder();
|
1341 |
| - $loader = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml')); |
| 1344 | + $loader = new XmlFileLoader($container, new FileLocator(self::$fixturesPath . '/xml')); |
1342 | 1345 |
|
1343 | 1346 | $this->expectUserDeprecationMessage(\sprintf('Since symfony/dependency-injection 7.2: Type "tagged" is deprecated for tag <argument>, use "tagged_iterator" instead in "%s/xml%sservices_with_deprecated_tagged.xml".', self::$fixturesPath, \DIRECTORY_SEPARATOR));
|
1344 | 1347 |
|
1345 | 1348 | $loader->load('services_with_deprecated_tagged.xml');
|
1346 | 1349 | }
|
| 1350 | + |
| 1351 | + public function testLoadServicesWithEnvironment() |
| 1352 | + { |
| 1353 | + $container = new ContainerBuilder(); |
| 1354 | + |
| 1355 | + $loader = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml'), 'prod'); |
| 1356 | + $loader->load('when-env-services.xml'); |
| 1357 | + |
| 1358 | + self::assertInstanceOf(RemoteCallerHttp::class, $container->get(RemoteCaller::class)); |
| 1359 | + |
| 1360 | + $loader = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml'), 'dev'); |
| 1361 | + $loader->load('when-env-services.xml'); |
| 1362 | + |
| 1363 | + self::assertInstanceOf(RemoteCallerSocket::class, $container->get(RemoteCaller::class)); |
| 1364 | + } |
1347 | 1365 | }
|
0 commit comments