File tree Expand file tree Collapse file tree 2 files changed +8
-7
lines changed Expand file tree Collapse file tree 2 files changed +8
-7
lines changed Original file line number Diff line number Diff line change 14
14
use PHPUnit \Framework \Exception ;
15
15
use PHPUnit \Framework \TestListener ;
16
16
use PHPUnit \Runner \Hook ;
17
+ use PHPUnit \TextUI \TestRunner ;
17
18
use PHPUnit \TextUI \XmlConfiguration \Extension ;
18
19
use ReflectionClass ;
19
20
use ReflectionException ;
23
24
*/
24
25
final class ExtensionHandler
25
26
{
26
- public function createInstance (Extension $ extension ): Hook
27
+ public function registerExtension (Extension $ extension, TestRunner $ runner ): void
27
28
{
28
- $ object = $ this ->doCreateInstance ($ extension );
29
+ $ object = $ this ->createInstance ($ extension );
29
30
30
31
if (!$ object instanceof Hook) {
31
32
throw new Exception (
@@ -36,15 +37,15 @@ public function createInstance(Extension $extension): Hook
36
37
);
37
38
}
38
39
39
- return $ object ;
40
+ $ runner -> addExtension ( $ object) ;
40
41
}
41
42
42
43
/**
43
44
* @deprecated
44
45
*/
45
46
public function createTestListenerInstance (Extension $ extension ): TestListener
46
47
{
47
- $ object = $ this ->doCreateInstance ($ extension );
48
+ $ object = $ this ->createInstance ($ extension );
48
49
49
50
if (!$ object instanceof TestListener) {
50
51
throw new Exception (
@@ -58,7 +59,7 @@ public function createTestListenerInstance(Extension $extension): TestListener
58
59
return $ object ;
59
60
}
60
61
61
- private function doCreateInstance (Extension $ extension ): object
62
+ private function createInstance (Extension $ extension ): object
62
63
{
63
64
$ this ->ensureClassExists ($ extension );
64
65
Original file line number Diff line number Diff line change @@ -1021,7 +1021,7 @@ private function handleConfiguration(array &$arguments): void
1021
1021
$ extensionHandler = new ExtensionHandler ;
1022
1022
1023
1023
foreach ($ arguments ['configurationObject ' ]->extensions () as $ extension ) {
1024
- $ this -> addExtension ( $ extensionHandler ->createInstance ($ extension) );
1024
+ $ extensionHandler ->registerExtension ($ extension, $ this );
1025
1025
}
1026
1026
1027
1027
foreach ($ arguments ['configurationObject ' ]->listeners () as $ listener ) {
@@ -1082,7 +1082,7 @@ private function handleConfiguration(array &$arguments): void
1082
1082
$ extensionHandler = new ExtensionHandler ;
1083
1083
1084
1084
foreach ($ arguments ['extensions ' ] as $ extension ) {
1085
- $ this -> addExtension ( $ extensionHandler ->createInstance ($ extension) );
1085
+ $ extensionHandler ->registerExtension ($ extension, $ this );
1086
1086
}
1087
1087
1088
1088
unset($ extensionHandler );
You can’t perform that action at this time.
0 commit comments