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

ScenarioTrait   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 1
dl 0
loc 30
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A registerScenario() 0 4 1
A getScenario() 0 4 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