@@ -81,14 +81,14 @@ public function testSetPrefix(): void
8181
8282 $ this ->assertSameTargetMessages ([
8383 [5 , '➤ Foo: bar ' ],
84- [6 , "- Foo: \n bar " ],
84+ [6 , "- Foo: \n bar " ],
8585 [6 , 'foo bar ' ],
8686 ], $ this ->TtyTarget );
8787
8888 $ this ->assertSameTargetOutput (
8989 "\e[2mDRY RUN \e[22m \e[1m \e[36m➤ \e[39m \e[22m \e[1mFoo: \e[22m \e[36m bar \e[39m \n"
9090 . "\e[2mDRY RUN \e[22m \e[33m- \e[39mFoo: \e[33m \n"
91- . "\e[2mDRY RUN \e[22m bar \e[39m \n"
91+ . "\e[2mDRY RUN \e[22m bar \e[39m \n"
9292 . "\e[2mDRY RUN \e[22mfoo bar \n" ,
9393 ["\n" => '"\n" ' . \PHP_EOL ],
9494 );
@@ -279,6 +279,110 @@ public function testOutput(): void
279279 $ this ->assertSame (7 , $ console ->warnings ());
280280 }
281281
282+ public function testOutputWithNewlines (): void
283+ {
284+ $ target3 = new MockTarget (null , false , false , false , null , new Formatter (null , null , null , [5 => '=> ' , 6 => '-> ' ], [4 => '>> ' ]));
285+ $ target4 = new MockTarget (null , false , false , false , null , new Formatter (null , null , null , [5 => '==> ' , 6 => ' -> ' ], [4 => '>>> ' ]));
286+ $ console = $ this ->Console ;
287+ $ console ->registerTarget ($ target3 );
288+ $ console ->registerTarget ($ target4 );
289+ $ console ->info ('foo: ' , "\nbar " );
290+ $ console ->info ('foo: ' , "bar \nbaz " );
291+ $ console ->info ("foo \nbar: " , 'baz ' );
292+ $ console ->info ("foo \nbar: " , "\nbaz " );
293+ $ console ->info ("foo \nbar: " , "baz \nqux " );
294+ $ console ->log ('foo: ' , "\nbar " );
295+ $ console ->log ('foo: ' , "bar \nbaz " );
296+ $ console ->log ("foo \nbar: " , 'baz ' );
297+ $ console ->log ("foo \nbar: " , "\nbaz " );
298+ $ console ->log ("foo \nbar: " , "baz \nqux " );
299+ $ console ->group ('foo ' );
300+ $ console ->group ('bar ' );
301+ $ console ->info ('foo: ' , "\nbar " );
302+ $ console ->info ('foo: ' , "bar \nbaz " );
303+ $ console ->info ("foo \nbar: " , 'baz ' );
304+ $ console ->info ("foo \nbar: " , "\nbaz " );
305+ $ console ->info ("foo \nbar: " , "baz \nqux " );
306+ $ console ->log ('foo: ' , "\nbar " );
307+ $ console ->log ('foo: ' , "bar \nbaz " );
308+ $ console ->log ("foo \nbar: " , 'baz ' );
309+ $ console ->log ("foo \nbar: " , "\nbaz " );
310+ $ console ->log ("foo \nbar: " , "baz \nqux " );
311+
312+ $ this ->assertSameTargetMessages ([
313+ [5 , "➤ foo: \n bar " ],
314+ [5 , "➤ foo: \n bar \n baz " ],
315+ [5 , "➤ foo \n bar: baz " ],
316+ [5 , "➤ foo \n bar: \n baz " ],
317+ [5 , "➤ foo \n bar: \n baz \n qux " ],
318+ [6 , "- foo: \n bar " ],
319+ [6 , "- foo: \n bar \n baz " ],
320+ [6 , "- foo \n bar: baz " ],
321+ [6 , "- foo \n bar: \n baz " ],
322+ [6 , "- foo \n bar: \n baz \n qux " ],
323+ [5 , '» foo ' ],
324+ [5 , ' » bar ' ],
325+ [5 , " ➤ foo: \n bar " ],
326+ [5 , " ➤ foo: \n bar \n baz " ],
327+ [5 , " ➤ foo \n bar: baz " ],
328+ [5 , " ➤ foo \n bar: \n baz " ],
329+ [5 , " ➤ foo \n bar: \n baz \n qux " ],
330+ [6 , " - foo: \n bar " ],
331+ [6 , " - foo: \n bar \n baz " ],
332+ [6 , " - foo \n bar: baz " ],
333+ [6 , " - foo \n bar: \n baz " ],
334+ [6 , " - foo \n bar: \n baz \n qux " ],
335+ ], $ this ->TtyTarget );
336+ $ this ->assertSameTargetMessages ([
337+ [5 , "=> foo: \n bar " ],
338+ [5 , "=> foo: \n bar \n baz " ],
339+ [5 , "=> foo \n bar: baz " ],
340+ [5 , "=> foo \n bar: \n baz " ],
341+ [5 , "=> foo \n bar: \n baz \n qux " ],
342+ [6 , "-> foo: \n bar " ],
343+ [6 , "-> foo: \n bar \n baz " ],
344+ [6 , "-> foo \n bar: baz " ],
345+ [6 , "-> foo \n bar: \n baz " ],
346+ [6 , "-> foo \n bar: \n baz \n qux " ],
347+ [5 , '>> foo ' ],
348+ [5 , ' >> bar ' ],
349+ [5 , " => foo: \n bar " ],
350+ [5 , " => foo: \n bar \n baz " ],
351+ [5 , " => foo \n bar: baz " ],
352+ [5 , " => foo \n bar: \n baz " ],
353+ [5 , " => foo \n bar: \n baz \n qux " ],
354+ [6 , " -> foo: \n bar " ],
355+ [6 , " -> foo: \n bar \n baz " ],
356+ [6 , " -> foo \n bar: baz " ],
357+ [6 , " -> foo \n bar: \n baz " ],
358+ [6 , " -> foo \n bar: \n baz \n qux " ],
359+ ], $ target3 );
360+ $ this ->assertSameTargetMessages ([
361+ [5 , "==> foo: \n bar " ],
362+ [5 , "==> foo: \n bar \n baz " ],
363+ [5 , "==> foo \n bar: baz " ],
364+ [5 , "==> foo \n bar: \n baz " ],
365+ [5 , "==> foo \n bar: \n baz \n qux " ],
366+ [6 , " -> foo: \n bar " ],
367+ [6 , " -> foo: \n bar \n baz " ],
368+ [6 , " -> foo \n bar: baz " ],
369+ [6 , " -> foo \n bar: \n baz " ],
370+ [6 , " -> foo \n bar: \n baz \n qux " ],
371+ [5 , '>>> foo ' ],
372+ [5 , ' >>> bar ' ],
373+ [5 , " ==> foo: \n bar " ],
374+ [5 , " ==> foo: \n bar \n baz " ],
375+ [5 , " ==> foo \n bar: baz " ],
376+ [5 , " ==> foo \n bar: \n baz " ],
377+ [5 , " ==> foo \n bar: \n baz \n qux " ],
378+ [6 , " -> foo: \n bar " ],
379+ [6 , " -> foo: \n bar \n baz " ],
380+ [6 , " -> foo \n bar: baz " ],
381+ [6 , " -> foo \n bar: \n baz " ],
382+ [6 , " -> foo \n bar: \n baz \n qux " ],
383+ ], $ target4 );
384+ }
385+
282386 public function testLogProgress (): void
283387 {
284388 $ console = $ this ->Console ;
0 commit comments