1
1
<?php
2
2
namespace Codeception \PHPUnit ;
3
3
4
+ use Codeception \PHPUnit \DispatcherWrapper ;
4
5
use Codeception \Event \FailEvent ;
5
6
use Codeception \Event \SuiteEvent ;
6
7
use Codeception \Event \TestEvent ;
7
8
use Codeception \Events ;
8
9
use Codeception \TestInterface ;
9
- use Exception ;
10
- use PHPUnit \Framework \Test ;
11
10
use Symfony \Component \EventDispatcher \EventDispatcher ;
12
11
13
12
class Listener implements \PHPUnit \Framework \TestListener
14
13
{
14
+ use DispatcherWrapper;
15
+
15
16
/**
16
17
* @var \Symfony\Component\EventDispatcher\EventDispatcher
17
18
*/
@@ -34,7 +35,7 @@ public function __construct(EventDispatcher $dispatcher)
34
35
* @param float $time
35
36
* @since Method available since Release 4.0.0
36
37
*/
37
- public function addRiskyTest (\PHPUnit \Framework \Test $ test , Exception $ e , $ time )
38
+ public function addRiskyTest (\PHPUnit \Framework \Test $ test , \ Exception $ e , $ time )
38
39
{
39
40
}
40
41
@@ -79,17 +80,17 @@ public function addSkippedTest(\PHPUnit\Framework\Test $test, \Exception $e, $ti
79
80
80
81
public function startTestSuite (\PHPUnit \Framework \TestSuite $ suite )
81
82
{
82
- $ this ->dispatcher -> dispatch ('suite.start ' , new SuiteEvent ($ suite ));
83
+ $ this ->dispatch ($ this -> dispatcher , 'suite.start ' , new SuiteEvent ($ suite ));
83
84
}
84
85
85
86
public function endTestSuite (\PHPUnit \Framework \TestSuite $ suite )
86
87
{
87
- $ this ->dispatcher -> dispatch ('suite.end ' , new SuiteEvent ($ suite ));
88
+ $ this ->dispatch ($ this -> dispatcher , 'suite.end ' , new SuiteEvent ($ suite ));
88
89
}
89
90
90
91
public function startTest (\PHPUnit \Framework \Test $ test )
91
92
{
92
- $ this ->dispatcher -> dispatch (Events::TEST_START , new TestEvent ($ test ));
93
+ $ this ->dispatch ($ this -> dispatcher , Events::TEST_START , new TestEvent ($ test ));
93
94
if (!$ test instanceof TestInterface) {
94
95
return ;
95
96
}
@@ -119,17 +120,17 @@ public function endTest(\PHPUnit\Framework\Test $test, $time)
119
120
$ this ->fire (Events::TEST_AFTER , new TestEvent ($ test , $ time ));
120
121
}
121
122
122
- $ this ->dispatcher -> dispatch (Events::TEST_END , new TestEvent ($ test , $ time ));
123
+ $ this ->dispatch ($ this -> dispatcher , Events::TEST_END , new TestEvent ($ test , $ time ));
123
124
}
124
125
125
126
protected function fire ($ event , TestEvent $ eventType )
126
127
{
127
128
$ test = $ eventType ->getTest ();
128
129
if ($ test instanceof TestInterface) {
129
130
foreach ($ test ->getMetadata ()->getGroups () as $ group ) {
130
- $ this ->dispatcher -> dispatch ($ event . '. ' . $ group , $ eventType );
131
+ $ this ->dispatch ($ this -> dispatcher , $ event . '. ' . $ group , $ eventType );
131
132
}
132
133
}
133
- $ this ->dispatcher -> dispatch ($ event , $ eventType );
134
+ $ this ->dispatch ($ this -> dispatcher , $ event , $ eventType );
134
135
}
135
136
}
0 commit comments