Completed
Push — master ( e553d9...156fb9 )
by Jonathan
41:51
created

FeatureTrait::getFeature()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Drupal\DrupalExtension;
4
5
use Behat\Behat\Hook\Scope\BeforeStepScope;
6
7
/**
8
 * A workaround to discover the current feature.
9
 *
10
 * @see https://github.com/Behat/Behat/issues/653
11
 * @see https://github.com/Behat/Behat/issues/650
12
 * The solution is documented in this issue: https://github.com/Behat/Behat/issues/703#issuecomment-86687563
13
 */
14
trait FeatureTrait
15
{
16
17
    /**
18
     * The registered feature.
19
     *
20
     * @var \Behat\Gherkin\Node\FeatureNode
21
     */
22
    protected $currentFeature;
23
24
    /**
25
     * Register the feature.
26
     *
27
     * This fires on a BeforeStep rather than a BeforeFeature since the latter
28
     * can only be called statically.
29
     *
30
     * @param \Behat\Behat\Hook\Scope\BeforeStepScope $scope
31
     *
32
     * @BeforeStep
33
     */
34
    public function registerFeature(BeforeStepScope $scope)
35
    {
36
        $this->currentFeature = $scope->getFeature();
37
    }
38
39
    /**
40
     * @return \Behat\Gherkin\Node\FeatureNode
41
     */
42
    protected function getFeature()
43
    {
44
        return $this->currentFeature;
45
    }
46
}
47