Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
default:
extensions:
YourVendor\YourPackage\Behat\Extension\ClassLoaderExtension: ~
#
# some other extensions and setup
#
<?php
// YourVendor/YourPackage/Behat/Legacy/ClassLoader.php
declare(strict_types=1);
namespace YourVendor\YourPackage\Behat\Legacy;
use Symfony\Component\ClassLoader\ClassLoader as SymfonyClassLoader;
try {
require_once 'path/to/vendor/symfony/class-loader/ClassLoader.php';
} catch (\Throwable $exception) {
//
}
class ClassLoader extends SymfonyClassLoader
{
}
<?php
declare(strict_types=1);
namespace YourVendor\YourPackage\Behat\Extension;
use Behat\Testwork\ServiceContainer\Extension;
use Behat\Testwork\ServiceContainer\ExtensionManager;
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
use YourVendor\YourPackage\Behat\Legacy\ClassLoader;
final class ClassLoaderExtension implements Extension
{
public function process(ContainerBuilder $container)
{
}
public function getConfigKey()
{
return 'behat_workaround';
}
public function initialize(ExtensionManager $extensionManager)
{
}
public function configure(ArrayNodeDefinition $builder)
{
}
public function load(ContainerBuilder $container, array $config)
{
// Reset 'class_loader' definition to the class we created earlier.
$container->setDefinition('class_loader', new Definition(ClassLoader::class));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment