bug #119 Fix a weird bug causing failures in Sylius (pamil)

This PR was merged into the 2.1-dev branch.

Discussion
----------

Related to https://github.com/Sylius/Sylius/pull/11029. Damn, this was really hard to fix.

Commits
-------

9609cc1171 Fix a weird bug causing failures in Sylius
This commit is contained in:
Kamil Kokot
2020-04-04 18:30:28 +02:00
committed by GitHub
2 changed files with 27 additions and 0 deletions

22
src/Mink/Mink.php Normal file
View 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
}
}

View File

@@ -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