34
34
use Behat \Gherkin \Node \FeatureNode ;
35
35
use Behat \Gherkin \Node \StepNode ;
36
36
use Behat \Testwork \Environment \Environment ;
37
+ use Behat \Testwork \EventDispatcher \TestworkEventDispatcher ;
37
38
use Symfony \Component \EventDispatcher \EventDispatcherInterface ;
38
39
39
40
/**
@@ -70,13 +71,25 @@ public function __construct(StepTester $baseTester, EventDispatcherInterface $ev
70
71
*/
71
72
public function setUp (Environment $ env , FeatureNode $ feature , StepNode $ step , $ skip ) {
72
73
$ event = new BeforeStepTested ($ env , $ feature , $ step );
73
- $ this ->eventDispatcher ->dispatch ($ event ::BEFORE , $ event );
74
+ if (TestworkEventDispatcher::DISPATCHER_VERSION === 2 ) {
75
+ // Symfony 4.3 and up.
76
+ $ this ->eventDispatcher ->dispatch ($ event , $ event ::BEFORE );
77
+ } else {
78
+ // TODO: Remove when our min supported version is >= 4.3.
79
+ $ this ->eventDispatcher ->dispatch ($ event ::BEFORE , $ event );
80
+ }
74
81
75
82
$ setup = $ this ->baseTester ->setUp ($ env , $ feature , $ step , $ skip );
76
83
$ this ->baseTester ->setEventDispatcher ($ this ->eventDispatcher );
77
84
78
85
$ event = new AfterStepSetup ($ env , $ feature , $ step , $ setup );
79
- $ this ->eventDispatcher ->dispatch ($ event ::AFTER_SETUP , $ event );
86
+ if (TestworkEventDispatcher::DISPATCHER_VERSION === 2 ) {
87
+ // Symfony 4.3 and up.
88
+ $ this ->eventDispatcher ->dispatch ($ event , $ event ::AFTER_SETUP );
89
+ } else {
90
+ // TODO: Remove when our min supported version is >= 4.3.
91
+ $ this ->eventDispatcher ->dispatch ($ event ::AFTER_SETUP , $ event );
92
+ }
80
93
81
94
return $ setup ;
82
95
}
@@ -93,12 +106,24 @@ public function test(Environment $env, FeatureNode $feature, StepNode $step, $sk
93
106
*/
94
107
public function tearDown (Environment $ env , FeatureNode $ feature , StepNode $ step , $ skip , StepResult $ result ) {
95
108
$ event = new BeforeStepTeardown ($ env , $ feature , $ step , $ result );
96
- $ this ->eventDispatcher ->dispatch ($ event ::BEFORE_TEARDOWN , $ event );
109
+ if (TestworkEventDispatcher::DISPATCHER_VERSION === 2 ) {
110
+ // Symfony 4.3 and up.
111
+ $ this ->eventDispatcher ->dispatch ($ event , $ event ::BEFORE_TEARDOWN );
112
+ } else {
113
+ // TODO: Remove when our min supported version is >= 4.3.
114
+ $ this ->eventDispatcher ->dispatch ($ event ::BEFORE_TEARDOWN , $ event );
115
+ }
97
116
98
117
$ teardown = $ this ->baseTester ->tearDown ($ env , $ feature , $ step , $ skip , $ result );
99
118
100
119
$ event = new AfterStepTested ($ env , $ feature , $ step , $ result , $ teardown );
101
- $ this ->eventDispatcher ->dispatch ($ event ::AFTER , $ event );
120
+ if (TestworkEventDispatcher::DISPATCHER_VERSION === 2 ) {
121
+ // Symfony 4.3 and up.
122
+ $ this ->eventDispatcher ->dispatch ($ event , $ event ::AFTER );
123
+ } else {
124
+ // TODO: Remove when our min supported version is >= 4.3.
125
+ $ this ->eventDispatcher ->dispatch ($ event ::AFTER , $ event );
126
+ }
102
127
103
128
return $ teardown ;
104
129
}
0 commit comments