Skip to content

Instantly share code, notes, and snippets.

@takeit
Created July 5, 2018 06:32
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 takeit/2e8fae6715a16e7ec996607d0f7d29bb to your computer and use it in GitHub Desktop.
Save takeit/2e8fae6715a16e7ec996607d0f7d29bb to your computer and use it in GitHub Desktop.
<?php
use Behat\Behat\Context\Context;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\KernelInterface;
/**
* This context class contains the definitions of the steps used by the demo
* feature file. Learn how to get started with Behat and BDD on Behat's website.
*
* @see http://behat.org/en/latest/quick_start.html
*/
class FeatureContext implements Context
{
/**
* @var KernelInterface
*/
private $kernel;
/**
* @var Response|null
*/
private $response;
public function __construct(KernelInterface $kernel)
{
$this->kernel = $kernel;
}
/**
* @When a demo scenario sends a request to :path
*/
public function aDemoScenarioSendsARequestTo(string $path)
{
$this->response = $this->kernel->handle(Request::create($path, 'GET'));
}
/**
* @Then the response should be received
*/
public function theResponseShouldBeReceived()
{
if ($this->response === null) {
throw new \RuntimeException('No response received');
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment