File tree Expand file tree Collapse file tree 2 files changed +29
-6
lines changed Expand file tree Collapse file tree 2 files changed +29
-6
lines changed Original file line number Diff line number Diff line change @@ -23,8 +23,6 @@ class CommandForV5 extends \PHPUnit_TextUI_Command
2323 */
2424 protected function createRunner ()
2525 {
26- $ listener = new SymfonyTestsListenerForV5 ();
27-
2826 $ this ->arguments ['listeners ' ] = isset ($ this ->arguments ['listeners ' ]) ? $ this ->arguments ['listeners ' ] : array ();
2927
3028 $ registeredLocally = false ;
@@ -37,8 +35,21 @@ protected function createRunner()
3735 }
3836 }
3937
38+ if (isset ($ this ->arguments ['configuration ' ])) {
39+ $ configuration = $ this ->arguments ['configuration ' ];
40+ if (!$ configuration instanceof \PHPUnit_Util_Configuration) {
41+ $ configuration = \PHPUnit_Util_Configuration::getInstance ($ this ->arguments ['configuration ' ]);
42+ }
43+ foreach ($ configuration ->getListenerConfiguration () as $ registeredListener ) {
44+ if ('Symfony\Bridge\PhpUnit\SymfonyTestsListener ' === ltrim ($ registeredListener ['class ' ], '\\' )) {
45+ $ registeredLocally = true ;
46+ break ;
47+ }
48+ }
49+ }
50+
4051 if (!$ registeredLocally ) {
41- $ this ->arguments ['listeners ' ][] = $ listener ;
52+ $ this ->arguments ['listeners ' ][] = new SymfonyTestsListenerForV5 () ;
4253 }
4354
4455 return parent ::createRunner ();
Original file line number Diff line number Diff line change 1313
1414use PHPUnit \TextUI \Command as BaseCommand ;
1515use PHPUnit \TextUI \TestRunner as BaseRunner ;
16+ use PHPUnit \Util \Configuration ;
1617use Symfony \Bridge \PhpUnit \SymfonyTestsListener ;
1718
1819/**
@@ -27,8 +28,6 @@ class CommandForV6 extends BaseCommand
2728 */
2829 protected function createRunner (): BaseRunner
2930 {
30- $ listener = new SymfonyTestsListener ();
31-
3231 $ this ->arguments ['listeners ' ] = isset ($ this ->arguments ['listeners ' ]) ? $ this ->arguments ['listeners ' ] : [];
3332
3433 $ registeredLocally = false ;
@@ -41,8 +40,21 @@ protected function createRunner(): BaseRunner
4140 }
4241 }
4342
43+ if (isset ($ this ->arguments ['configuration ' ])) {
44+ $ configuration = $ this ->arguments ['configuration ' ];
45+ if (!$ configuration instanceof Configuration) {
46+ $ configuration = Configuration::getInstance ($ this ->arguments ['configuration ' ]);
47+ }
48+ foreach ($ configuration ->getListenerConfiguration () as $ registeredListener ) {
49+ if ('Symfony\Bridge\PhpUnit\SymfonyTestsListener ' === ltrim ($ registeredListener ['class ' ], '\\' )) {
50+ $ registeredLocally = true ;
51+ break ;
52+ }
53+ }
54+ }
55+
4456 if (!$ registeredLocally ) {
45- $ this ->arguments ['listeners ' ][] = $ listener ;
57+ $ this ->arguments ['listeners ' ][] = new SymfonyTestsListener () ;
4658 }
4759
4860 return parent ::createRunner ();
You can’t perform that action at this time.
0 commit comments