Skip to content

Instantly share code, notes, and snippets.

@franzose
Created March 16, 2018 09:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save franzose/9a80b7966505b090810f46f0e66a2bf5 to your computer and use it in GitHub Desktop.
Save franzose/9a80b7966505b090810f46f0e66a2bf5 to your computer and use it in GitHub Desktop.
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