Last active
June 6, 2019 14:33
-
-
Save Zayon/c6a0fc10cc6e46d377458bcf97a307e8 to your computer and use it in GitHub Desktop.
FeatureContext - Step 1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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