diff --git a/src/Behat/Symfony2Extension/Driver/KernelDriver.php b/src/Behat/Symfony2Extension/Driver/KernelDriver.php index a79fa4c..1bc57b7 100644 --- a/src/Behat/Symfony2Extension/Driver/KernelDriver.php +++ b/src/Behat/Symfony2Extension/Driver/KernelDriver.php @@ -12,6 +12,7 @@ namespace Behat\Symfony2Extension\Driver; use Behat\Mink\Driver\BrowserKitDriver; +use Symfony\Component\HttpKernel\Client; use Symfony\Component\HttpKernel\KernelInterface; /** @@ -21,8 +22,9 @@ */ class KernelDriver extends BrowserKitDriver { - public function __construct(KernelInterface $kernel, $baseUrl = null) + public function __construct(KernelInterface $kernel, $baseUrl = null, $shared = false) { - parent::__construct($kernel->getContainer()->get('test.client'), $baseUrl); + $client = $shared === true ? new Client($kernel) : $kernel->getContainer()->get('test.client'); + parent::__construct($client, $baseUrl); } } diff --git a/src/Behat/Symfony2Extension/ServiceContainer/Driver/SymfonyFactory.php b/src/Behat/Symfony2Extension/ServiceContainer/Driver/SymfonyFactory.php index 3485044..259f30e 100644 --- a/src/Behat/Symfony2Extension/ServiceContainer/Driver/SymfonyFactory.php +++ b/src/Behat/Symfony2Extension/ServiceContainer/Driver/SymfonyFactory.php @@ -59,6 +59,7 @@ public function buildDriver(array $config) return new Definition('Behat\Symfony2Extension\Driver\KernelDriver', array( new Reference(Symfony2Extension::KERNEL_ID), '%mink.base_url%', + '%symfony2_extension.kernel.shared%' )); } } diff --git a/src/Behat/Symfony2Extension/ServiceContainer/Symfony2Extension.php b/src/Behat/Symfony2Extension/ServiceContainer/Symfony2Extension.php index 273ddb6..c93bd31 100644 --- a/src/Behat/Symfony2Extension/ServiceContainer/Symfony2Extension.php +++ b/src/Behat/Symfony2Extension/ServiceContainer/Symfony2Extension.php @@ -81,6 +81,12 @@ public function configure(ArrayNodeDefinition $builder) ->end() ->defaultTrue() ->end() + ->booleanNode('shared') + ->beforeNormalization() + ->ifString()->then($boolFilter) + ->end() + ->defaultFalse() + ->end() ->end() ->end() ->arrayNode('context') @@ -181,6 +187,7 @@ private function loadKernel(ContainerBuilder $container, array $config) $container->setDefinition(self::KERNEL_ID, $definition); $container->setParameter(self::KERNEL_ID . '.path', $config['path']); $container->setParameter(self::KERNEL_ID . '.bootstrap', $config['bootstrap']); + $container->setParameter(self::KERNEL_ID . '.shared', $config['shared']); } private function loadSuiteGenerator(ContainerBuilder $container, array $config)