@@ -130,11 +130,43 @@ public function testInitFormatter(): void
130130 $ optionsFormatJunit = new CliOptions ();
131131 $ optionsFormatJunit ->format = 'junit ' ;
132132 self ::assertInstanceOf (JunitFormatter::class, $ initializer ->initFormatter ($ optionsFormatJunit ));
133+ }
133134
134- self ::expectException (InvalidConfigException::class);
135- $ optionsFormatUnknown = new CliOptions ();
136- $ optionsFormatUnknown ->format = 'unknown ' ;
137- $ initializer ->initFormatter ($ optionsFormatUnknown );
135+ /**
136+ * @dataProvider provideInitFormatterFailures
137+ */
138+ public function testInitFormatterFailures (CliOptions $ options , string $ message ): void
139+ {
140+ $ printer = $ this ->createMock (Printer::class);
141+
142+ $ initializer = new Initializer (__DIR__ , $ printer , $ printer );
143+
144+ $ this ->expectException (InvalidConfigException::class);
145+ $ this ->expectExceptionMessage ($ message );
146+ $ initializer ->initFormatter ($ options );
147+ }
148+
149+ /**
150+ * @return iterable<string, array{CliOptions, string}>
151+ */
152+ public static function provideInitFormatterFailures (): iterable
153+ {
154+ $ junitWithDumpUsages = new CliOptions ();
155+ $ junitWithDumpUsages ->format = 'junit ' ;
156+ $ junitWithDumpUsages ->dumpUsages = 'symfony/* ' ;
157+
158+ $ unknownFormat = new CliOptions ();
159+ $ unknownFormat ->format = 'unknown ' ;
160+
161+ yield 'junit with dump-usages ' => [
162+ $ junitWithDumpUsages ,
163+ "Cannot use 'junit' format with '--dump-usages' option. " ,
164+ ];
165+
166+ yield 'unknown format ' => [
167+ $ unknownFormat ,
168+ "Invalid format option provided, allowed are 'console' or 'junit'. " ,
169+ ];
138170 }
139171
140172}
0 commit comments