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

ScenarioTrait::registerScenario()   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 1
1
<?php
2
3
namespace Drupal\DrupalExtension;
4
5
use Behat\Behat\Hook\Scope\BeforeScenarioScope;
6
7
/**
8
 * A workaround to discover the current scenario.
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 ScenarioTrait
15
{
16
17
    /**
18
     * The registered scenario.
19
     *
20
     * @var \Behat\Gherkin\Node\ScenarioInterface
21
     */
22
    protected $currentScenario;
23
24
    /**
25
     * Register the scenario.
26
     *
27
     * @param \Behat\Behat\Hook\Scope\BeforeScenarioScope $scope
28
     *
29
     * @BeforeScenario
30
     */
31
    public function registerScenario(BeforeScenarioScope $scope)
32
    {
33
        $this->currentScenario = $scope->getScenario();
34
    }
35
36
    /**
37
     * @return \Behat\Gherkin\Node\ScenarioInterface
38
     */
39
    protected function getScenario()
40
    {
41
        return $this->currentScenario;
42
    }
43
}
44