|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Bex\Behat\SkipTestsExtension\Decorator; |
|
4
|
|
|
|
|
5
|
|
|
use Behat\Gherkin\Node\FeatureNode; |
|
6
|
|
|
use Behat\Testwork\Environment\Environment; |
|
7
|
|
|
use Behat\Testwork\Tester\Result\IntegerTestResult; |
|
8
|
|
|
use Behat\Testwork\Tester\Result\TestResult; |
|
9
|
|
|
use Behat\Testwork\Tester\Result\TestResults; |
|
10
|
|
|
use Behat\Testwork\Tester\Setup\Setup; |
|
11
|
|
|
use Behat\Testwork\Tester\Setup\Teardown; |
|
12
|
|
|
use Behat\Testwork\Tester\SpecificationTester; |
|
13
|
|
|
use Bex\Behat\SkipTestsExtension\ServiceContainer\Config; |
|
14
|
|
|
|
|
15
|
|
|
class FeatureTesterDecorator implements SpecificationTester |
|
16
|
|
|
{ |
|
17
|
|
|
/** |
|
18
|
|
|
* @var ScenarioTester |
|
19
|
|
|
*/ |
|
20
|
|
|
private $featureTester; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* @var Config |
|
24
|
|
|
*/ |
|
25
|
|
|
private $config; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* @param SpecificationTester $featureTester |
|
29
|
|
|
* @param Config $config |
|
30
|
|
|
*/ |
|
31
|
|
|
public function __construct(SpecificationTester $featureTester, Config $config) |
|
32
|
|
|
{ |
|
33
|
|
|
$this->featureTester = $featureTester; |
|
|
|
|
|
|
34
|
|
|
$this->config = $config; |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* Sets up specification for a test. |
|
39
|
|
|
* |
|
40
|
|
|
* @param Environment $env |
|
41
|
|
|
* @param mixed $spec |
|
42
|
|
|
* @param Boolean $skip |
|
43
|
|
|
* |
|
44
|
|
|
* @return Setup |
|
45
|
|
|
*/ |
|
46
|
|
|
public function setUp(Environment $env, $spec, $skip) |
|
47
|
|
|
{ |
|
48
|
|
|
return $this->featureTester->setUp($env, $spec, $skip); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* Tests provided specification. |
|
53
|
|
|
* |
|
54
|
|
|
* @param Environment $env |
|
55
|
|
|
* @param mixed $spec |
|
56
|
|
|
* @param Boolean $skip |
|
57
|
|
|
* |
|
58
|
|
|
* @return TestResult |
|
59
|
|
|
*/ |
|
60
|
|
|
public function test(Environment $env, $spec, $skip) |
|
61
|
|
|
{ |
|
62
|
|
|
if ($spec instanceof FeatureNode && $this->shouldSkipFeature($spec)) { |
|
63
|
|
|
$skip = true; |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
return $this->featureTester->test($env, $spec, $skip); |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* Tears down specification after a test. |
|
71
|
|
|
* |
|
72
|
|
|
* @param Environment $env |
|
73
|
|
|
* @param mixed $spec |
|
74
|
|
|
* @param Boolean $skip |
|
75
|
|
|
* @param TestResult $result |
|
76
|
|
|
* |
|
77
|
|
|
* @return Teardown |
|
78
|
|
|
*/ |
|
79
|
|
|
public function tearDown(Environment $env, $spec, $skip, TestResult $result) |
|
80
|
|
|
{ |
|
81
|
|
|
return $this->featureTester->tearDown($env, $spec, $skip, $result); |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
/** |
|
85
|
|
|
* @param FeatureNode $feature |
|
86
|
|
|
* |
|
87
|
|
|
* @return bool |
|
88
|
|
|
*/ |
|
89
|
|
|
private function shouldSkipFeature(FeatureNode $feature) |
|
90
|
|
|
{ |
|
91
|
|
|
$matchingSkipTags = array_intersect($feature->getTags(), $this->config->getSkipTags()); |
|
92
|
|
|
|
|
93
|
|
|
return $this->config->shouldSkipFeatures() && !empty($matchingSkipTags); |
|
94
|
|
|
} |
|
95
|
|
|
} |
|
96
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..