diff --git a/resources/config/test.xml b/resources/config/test.xml
deleted file mode 100644
index 528d18b..0000000
--- a/resources/config/test.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
- %test.client.parameters%
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- test.private_services_locator
-
-
-
-
-
-
-
diff --git a/src/DependencyInjection/PsyshExtension.php b/src/DependencyInjection/PsyshExtension.php
index f61fe24..949b536 100644
--- a/src/DependencyInjection/PsyshExtension.php
+++ b/src/DependencyInjection/PsyshExtension.php
@@ -14,6 +14,7 @@
use Psy\Command\Command;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
+use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
use Symfony\Component\DependencyInjection\Loader;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\ExpressionLanguage\Expression;
@@ -27,8 +28,15 @@
*
* @author Théo FIDRY
*/
-final class PsyshExtension extends Extension
+final class PsyshExtension extends Extension implements PrependExtensionInterface
{
+ public function prepend(ContainerBuilder $container)
+ {
+ if (class_exists(TestContainer::class)) {
+ $container->prependExtensionConfig('framework', ['test' => true]);
+ }
+ }
+
/**
* {@inheritdoc}
*/
@@ -36,9 +44,6 @@ public function load(array $configs, ContainerBuilder $container)
{
$loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../../resources/config'));
$loader->load('services.xml');
- if (class_exists(TestContainer::class) && !$container->has('test.service_container')) {
- $loader->load('test.xml');
- }
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
@@ -47,7 +52,7 @@ public function load(array $configs, ContainerBuilder $container)
$value = new Reference(substr($value, 1));
}
}
- $containerId = $container->has('test.service_container') ? 'test.service_container' : 'service_container';
+ $containerId = class_exists(TestContainer::class) ? 'test.service_container' : 'service_container';
$container->findDefinition('psysh.shell')
->addMethodCall('setScopeVariables', [$config['variables'] + [
'container' => new Reference($containerId),
diff --git a/tests/Command/PsyshCommandIntegrationTest.php b/tests/Command/PsyshCommandIntegrationTest.php
index 0ed0ec9..d39dd53 100644
--- a/tests/Command/PsyshCommandIntegrationTest.php
+++ b/tests/Command/PsyshCommandIntegrationTest.php
@@ -63,7 +63,7 @@ public function testScopeVariables()
public function testContainerInstance()
{
$container = $this->shell->getScopeVariable('container');
- if (class_exists(TestContainer::class)) {
+ if (self::$kernel->getContainer()->has('test.service_container')) {
$this->assertInstanceOf(TestContainer::class, $container);
} else {
$this->assertInstanceOf(Container::class, $container);