Open MiroslavRusev opened 10 months ago
v 4.2.0 -
v5 -
I can't open a PR, but I think this should be the fix:
public function load(ContainerBuilder $container, array $config)
{
$loader = new YamlFileLoader($container, new FileLocator(__DIR__ . '/config'));
$loader->load('services.yml');
$container->setParameter('drupal.drupal.default_driver', $config['default_driver']);
$this->loadParameters($container, $config);
if (!isset($config['blackbox'])) {
// Workaround a bug in BrowserKitDriver that wrongly considers as text
// of the page, pieces of texts inside the <head> section.
// @see https://github.com/minkphp/MinkBrowserKitDriver/issues/153
// @see https://www.drupal.org/project/drupal/issues/3175718
$drupalFinder = new DrupalFinder();
if (!$drupalFinder->locateRoot(getcwd())) {
throw new \RuntimeException('Cannot locate Drupal');
}
$drupalRoot = $drupalFinder->getDrupalRoot();
require_once($drupalRoot . '/core/tests/Drupal/Tests/DocumentElement.php');
class_alias('\Drupal\Tests\DocumentElement', '\Behat\Mink\Element\DocumentElement', true);
}
// Setup any drivers if requested.
$this->loadBlackbox($loader, $config);
$this->loadDrupal($loader, $container, $config);
$this->loadDrush($loader, $container, $config);
}
https://github.com/jhedstrom/drupalextension/blob/22d69d8c6929e49c4736b147bf2f73e92e4fedb9/src/Drupal/DrupalExtension/ServiceContainer/DrupalExtension.php#L73
I am currently using the region map of the Drupal Extension in a behat, which is installed without Drupal. The behat.yml config looks like: Drupal\DrupalExtension: region_map: region1: ".clss"
I've tried adding blackbox:~ but it doesn't do anything and I think it's because of Line 86 in the same file (DrupalExtension.php). The problem is the exception is thrown before reading the configuration, so there is no way to start Behat with DrupalExtension if no drupal is installed on the same machine. This problem was not present in previous versions as there was no usage of DrupalFinder() in that file. https://github.com/jhedstrom/drupalextension/blob/4.2/src/Drupal/DrupalExtension/ServiceContainer/DrupalExtension.php#L64