You can use service container as you use it in your controllers or service. You can also use EntityManager and repositories.


FeatureContext.php


namespace Application\BackendBundle\Features\Context;

use Behat\MinkExtension\Context\MinkContext;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;

class FeatureContext extends MinkContext implements ContainerAwareInterface
{
private $container;

public function setContainer(ContainerInterface $container = null)
{
$this->container = $container;
}

public function getParameter()
{
$myParameter = $this->container->getParameter('name_of_the_param');
}

public function getService()
{
$myService = $this->container->get('name_of_the_service');
}

public function runDbQuery($ame)
{
$em = $this->container->get('doctrine')->getManager();
$repo = $em->getRepository('FootballTeamBundle:Country');
$country = $repo->findOneBy(array('name' => $name));
}
}