@@ -228,47 +228,34 @@ public function testFormatToStringObject()
228
228
);
229
229
}
230
230
231
- public function testNotDecoratedFormatter ()
231
+ public function testFormatterHasStyles ()
232
232
{
233
233
$ formatter = new OutputFormatter (false );
234
234
235
235
$ this ->assertTrue ($ formatter ->hasStyle ('error ' ));
236
236
$ this ->assertTrue ($ formatter ->hasStyle ('info ' ));
237
237
$ this ->assertTrue ($ formatter ->hasStyle ('comment ' ));
238
238
$ this ->assertTrue ($ formatter ->hasStyle ('question ' ));
239
+ }
239
240
240
- $ this ->assertEquals (
241
- 'some error ' , $ formatter ->format ('<error>some error</error> ' )
242
- );
243
- $ this ->assertEquals (
244
- 'some info ' , $ formatter ->format ('<info>some info</info> ' )
245
- );
246
- $ this ->assertEquals (
247
- 'some comment ' , $ formatter ->format ('<comment>some comment</comment> ' )
248
- );
249
- $ this ->assertEquals (
250
- 'some question ' , $ formatter ->format ('<question>some question</question> ' )
251
- );
252
- $ this ->assertEquals (
253
- 'some text with inline style ' , $ formatter ->format ('<fg=red>some text with inline style</> ' )
254
- );
255
-
256
- $ formatter ->setDecorated (true );
241
+ /**
242
+ * @dataProvider provideDecoratedAndNonDecoratedOutput
243
+ */
244
+ public function testNotDecoratedFormatter (string $ input , string $ expectedNonDecoratedOutput , string $ expectedDecoratedOutput )
245
+ {
246
+ $ this ->assertEquals ($ expectedDecoratedOutput , (new OutputFormatter (true ))->format ($ input ));
247
+ $ this ->assertEquals ($ expectedNonDecoratedOutput , (new OutputFormatter (false ))->format ($ input ));
248
+ }
257
249
258
- $ this ->assertEquals (
259
- "\033[37;41msome error \033[39;49m " , $ formatter ->format ('<error>some error</error> ' )
260
- );
261
- $ this ->assertEquals (
262
- "\033[32msome info \033[39m " , $ formatter ->format ('<info>some info</info> ' )
263
- );
264
- $ this ->assertEquals (
265
- "\033[33msome comment \033[39m " , $ formatter ->format ('<comment>some comment</comment> ' )
266
- );
267
- $ this ->assertEquals (
268
- "\033[30;46msome question \033[39;49m " , $ formatter ->format ('<question>some question</question> ' )
269
- );
270
- $ this ->assertEquals (
271
- "\033[31msome text with inline style \033[39m " , $ formatter ->format ('<fg=red>some text with inline style</> ' )
250
+ public function provideDecoratedAndNonDecoratedOutput ()
251
+ {
252
+ return array (
253
+ array ('<error>some error</error> ' , 'some error ' , "\033[37;41msome error \033[39;49m " ),
254
+ array ('<info>some info</info> ' , 'some info ' , "\033[32msome info \033[39m " ),
255
+ array ('<comment>some comment</comment> ' , 'some comment ' , "\033[33msome comment \033[39m " ),
256
+ array ('<question>some question</question> ' , 'some question ' , "\033[30;46msome question \033[39;49m " ),
257
+ array ('<fg=red>some text with inline style</> ' , 'some text with inline style ' , "\033[31msome text with inline style \033[39m " ),
258
+ array ('<href=idea://open/?file=/path/somefile.php&line=12>some URL</> ' , 'some URL ' , "\033]8;;idea://open/?file=/path/somefile.php&line=12 \033\\some URL \033]8;; \033\\" ),
272
259
);
273
260
}
274
261
0 commit comments