|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Sylius\Bundle\ApiBundle\Behat\Tester; |
|
6
|
|
|
|
|
7
|
|
|
use Behat\Behat\Tester\ScenarioTester; |
|
8
|
|
|
use Behat\Gherkin\Node\FeatureNode; |
|
9
|
|
|
use Behat\Gherkin\Node\ScenarioInterface as Scenario; |
|
10
|
|
|
use Behat\Gherkin\Node\ScenarioNode; |
|
11
|
|
|
use Behat\Testwork\Environment\Environment; |
|
12
|
|
|
use Behat\Testwork\Suite\Exception\ParameterNotFoundException; |
|
13
|
|
|
use Behat\Testwork\Tester\Result\TestResult; |
|
14
|
|
|
use Behat\Testwork\Tester\Setup\Setup; |
|
15
|
|
|
use Behat\Testwork\Tester\Setup\Teardown; |
|
16
|
|
|
|
|
17
|
|
|
final class ApiScenarioEventDispatchingScenarioTester implements ScenarioTester |
|
18
|
|
|
{ |
|
19
|
|
|
/** @var ScenarioTester */ |
|
20
|
|
|
private $baseTester; |
|
21
|
|
|
|
|
22
|
|
|
public function __construct(ScenarioTester $baseTester) |
|
23
|
|
|
{ |
|
24
|
|
|
$this->baseTester = $baseTester; |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
public function setUp(Environment $env, FeatureNode $feature, Scenario $scenario, $skip): Setup |
|
28
|
|
|
{ |
|
29
|
|
|
try { |
|
30
|
|
|
if ($env->getSuite()->getSetting('javascript')) { |
|
31
|
|
|
return $this->baseTester->setUp($env, $feature, $scenario, $skip); |
|
32
|
|
|
} |
|
33
|
|
|
} catch (ParameterNotFoundException $exception) { |
|
34
|
|
|
return $this->baseTester->setUp($env, $feature, $scenario, $skip); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
$tags = $scenario->getTags(); |
|
38
|
|
|
if (($key = array_search('javascript', $tags)) !== false) { |
|
39
|
|
|
unset($tags[$key]); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
$scenario = new ScenarioNode( |
|
43
|
|
|
$scenario->getTitle(), |
|
44
|
|
|
$tags, |
|
45
|
|
|
$scenario->getSteps(), |
|
46
|
|
|
$scenario->getKeyword(), |
|
47
|
|
|
$scenario->getLine() |
|
48
|
|
|
); |
|
49
|
|
|
|
|
50
|
|
|
return $this->baseTester->setUp($env, $feature, $scenario, $skip); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
public function test(Environment $env, FeatureNode $feature, Scenario $scenario, $skip): TestResult |
|
54
|
|
|
{ |
|
55
|
|
|
return $this->baseTester->test($env, $feature, $scenario, $skip); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
public function tearDown(Environment $env, FeatureNode $feature, Scenario $scenario, $skip, TestResult $result): Teardown |
|
59
|
|
|
{ |
|
60
|
|
|
return $this->baseTester->tearDown($env, $feature, $scenario, $skip, $result); |
|
61
|
|
|
} |
|
62
|
|
|
} |
|
63
|
|
|
|