Skip to content

Instantly share code, notes, and snippets.

@Zayon
Last active June 6, 2019 14:33
Show Gist options
  • Save Zayon/c6a0fc10cc6e46d377458bcf97a307e8 to your computer and use it in GitHub Desktop.
Save Zayon/c6a0fc10cc6e46d377458bcf97a307e8 to your computer and use it in GitHub Desktop.
FeatureContext - Step 1
<?php
declare(strict_types=1);
use Behat\Behat\Context\Context;
use Behat\Symfony2Extension\Context\KernelAwareContext;
use Symfony\Component\HttpKernel\KernelInterface;
use Symfony\Component\PropertyAccess\PropertyAccessorInterface;
class FeatureContext implements Context, KernelAwareContext
{
use SharedContextTrait;
/** @var PropertyAccessorInterface */
private $propertyAccessor;
public function setKernel(KernelInterface $kernel): void
{
$this->propertyAccessor = $kernel->getContainer()
->get('test.service_container')
->get('property_accessor');
}
/**
* @Given I store the :property property of :fixtureReference as :key
*/
public function iStoreThePropertyOfAs($property, $fixtureReference, $key): void
{
$fixture = $this->sharingContext[$fixtureReference];
$this->sharingContext[$key] = $this->propertyAccessor->getValue($fixture, $property);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment