Fix a weird bug causing failures in Sylius
This commit is contained in:
22
src/Mink/Mink.php
Normal file
22
src/Mink/Mink.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FriendsOfBehat\SymfonyExtension\Mink;
|
||||
|
||||
use Behat\Mink\Mink as BaseMink;
|
||||
|
||||
class Mink extends BaseMink
|
||||
{
|
||||
/**
|
||||
* Very weird bug happens when Mink is exposed as a LAZY service in tested application.
|
||||
* In that case, the destructor might be called at any random time. If it is called
|
||||
* while we're in the middle of any Mink-related operation, it'll leave the used Mink session
|
||||
* in an invalid state. Therefore, not stopping all the sessions while destructing Mink
|
||||
* saves our sanity.
|
||||
*/
|
||||
public function __destruct()
|
||||
{
|
||||
// Intentionally left empty
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,7 @@ use Behat\Testwork\ServiceContainer\ExtensionManager;
|
||||
use FriendsOfBehat\SymfonyExtension\Context\Environment\Handler\ContextServiceEnvironmentHandler;
|
||||
use FriendsOfBehat\SymfonyExtension\Driver\Factory\SymfonyDriverFactory;
|
||||
use FriendsOfBehat\SymfonyExtension\Listener\KernelOrchestrator;
|
||||
use FriendsOfBehat\SymfonyExtension\Mink\Mink;
|
||||
use FriendsOfBehat\SymfonyExtension\Mink\MinkParameters;
|
||||
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
|
||||
use Symfony\Component\DependencyInjection\Alias;
|
||||
@@ -91,6 +92,10 @@ final class SymfonyExtension implements Extension
|
||||
public function process(ContainerBuilder $container): void
|
||||
{
|
||||
$this->processEnvironmentHandler($container);
|
||||
|
||||
if ($this->minkExtensionFound) {
|
||||
$container->getDefinition(MinkExtension::MINK_ID)->setClass(Mink::class);
|
||||
}
|
||||
}
|
||||
|
||||
private function registerMinkDriver(ExtensionManager $extensionManager): void
|
||||
|
||||
Reference in New Issue
Block a user