Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
66 lines (57 sloc) 1.37 KB
<?php namespace Pavlakis\Slim\Behat\Context;
use Behat\Behat\Context\Context;
use Behat\Behat\Context\Initializer\ContextInitializer;
use Behat\Behat\EventDispatcher\Event\ScenarioTested;
use Pavlakis\Slim\Behat\ServiceContainer\SlimBooter;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\HttpKernelInterface;
class KernelAwareInitializer implements ContextInitializer
{
/**
* The app kernel.
*
* @var HttpKernelInterface
*/
private $kernel;
/**
* The Behat context.
*
* @var Context
*/
private $context;
/**
* Construct the initializer.
*
* @param \Slim\App $kernel
*/
public function __construct(\Slim\App $kernel)
{
$this->kernel = $kernel;
}
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents()
{
return [
ScenarioTested::AFTER => ['rebootKernel', -15]
];
}
/**
* {@inheritdoc}
*/
public function initializeContext(Context $context)
{
$this->context = $context;
$this->setAppOnContext();
}
/**
* Set the app kernel to the feature context.
*/
private function setAppOnContext()
{
if ($this->context instanceof KernelAwareContext) {
$this->context->setApp($this->kernel);
}
}
}