11<?php
22namespace Codeception \PHPUnit ;
33
4+ use Codeception \PHPUnit \DispatcherWrapper ;
45use Codeception \Event \FailEvent ;
56use Codeception \Event \SuiteEvent ;
67use Codeception \Event \TestEvent ;
78use Codeception \Events ;
89use Codeception \TestInterface ;
9- use Exception ;
10- use PHPUnit \Framework \Test ;
1110use Symfony \Component \EventDispatcher \EventDispatcher ;
1211
1312class Listener implements \PHPUnit \Framework \TestListener
1413{
14+ use DispatcherWrapper;
15+
1516 /**
1617 * @var \Symfony\Component\EventDispatcher\EventDispatcher
1718 */
@@ -34,7 +35,7 @@ public function __construct(EventDispatcher $dispatcher)
3435 * @param float $time
3536 * @since Method available since Release 4.0.0
3637 */
37- public function addRiskyTest (\PHPUnit \Framework \Test $ test , Exception $ e , $ time )
38+ public function addRiskyTest (\PHPUnit \Framework \Test $ test , \ Exception $ e , $ time )
3839 {
3940 }
4041
@@ -79,17 +80,17 @@ public function addSkippedTest(\PHPUnit\Framework\Test $test, \Exception $e, $ti
7980
8081 public function startTestSuite (\PHPUnit \Framework \TestSuite $ suite )
8182 {
82- $ this ->dispatcher -> dispatch ('suite.start ' , new SuiteEvent ($ suite ));
83+ $ this ->dispatch ($ this -> dispatcher , 'suite.start ' , new SuiteEvent ($ suite ));
8384 }
8485
8586 public function endTestSuite (\PHPUnit \Framework \TestSuite $ suite )
8687 {
87- $ this ->dispatcher -> dispatch ('suite.end ' , new SuiteEvent ($ suite ));
88+ $ this ->dispatch ($ this -> dispatcher , 'suite.end ' , new SuiteEvent ($ suite ));
8889 }
8990
9091 public function startTest (\PHPUnit \Framework \Test $ test )
9192 {
92- $ this ->dispatcher -> dispatch (Events::TEST_START , new TestEvent ($ test ));
93+ $ this ->dispatch ($ this -> dispatcher , Events::TEST_START , new TestEvent ($ test ));
9394 if (!$ test instanceof TestInterface) {
9495 return ;
9596 }
@@ -119,17 +120,17 @@ public function endTest(\PHPUnit\Framework\Test $test, $time)
119120 $ this ->fire (Events::TEST_AFTER , new TestEvent ($ test , $ time ));
120121 }
121122
122- $ this ->dispatcher -> dispatch (Events::TEST_END , new TestEvent ($ test , $ time ));
123+ $ this ->dispatch ($ this -> dispatcher , Events::TEST_END , new TestEvent ($ test , $ time ));
123124 }
124125
125126 protected function fire ($ event , TestEvent $ eventType )
126127 {
127128 $ test = $ eventType ->getTest ();
128129 if ($ test instanceof TestInterface) {
129130 foreach ($ test ->getMetadata ()->getGroups () as $ group ) {
130- $ this ->dispatcher -> dispatch ($ event . '. ' . $ group , $ eventType );
131+ $ this ->dispatch ($ this -> dispatcher , $ event . '. ' . $ group , $ eventType );
131132 }
132133 }
133- $ this ->dispatcher -> dispatch ($ event , $ eventType );
134+ $ this ->dispatch ($ this -> dispatcher , $ event , $ eventType );
134135 }
135136}
0 commit comments