Injected parameter test POC

This commit is contained in:
Bartosz Pietrzak
2019-01-09 16:09:20 +01:00
parent 9c41bdbcba
commit 742d3358b5
2 changed files with 86 additions and 0 deletions

View File

@@ -157,6 +157,48 @@ CON
);
}
/**
* @Given /^an application kernel injecting a parameter into the FeatureContext class$/
*/
public function thereIsKernelInjectingParameterIntoFeatureContextClass(): void
{
$this->thereIsFile('app/AppKernel.php', <<<'CON'
<?php
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Parameter;
class AppKernel extends Kernel
{
public function registerBundles()
{
return [
new \Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
new \FriendsOfBehat\SymfonyExtension\Bundle\FriendsOfBehatSymfonyExtensionBundle(),
];
}
public function registerContainerConfiguration(LoaderInterface $loader)
{
$loader->load(function (ContainerBuilder $container): void {
$container->loadFromExtension('framework', [
'test' => $this->getEnvironment() === 'test',
'secret' => 'Pigeon',
]);
$contextDefinition = new Definition(FeatureContext::class, [new Parameter('kernel.environment')]);
$contextDefinition->setAutoconfigured(true);
$container->setDefinition(FeatureContext::class, $contextDefinition);
});
}
}
CON
);
}
/**
* @Given /^a feature file containing(?: "([^"]+)"|:)$/
*/