@@ -812,7 +812,7 @@ public function testMultilineFormat()
812
812
$ this ->assertEquals (
813
813
">--------------------------- \nfoobar " .
814
814
$ this ->generateOutput ("=========>------------------ \nfoobar " ).
815
- "\x1B[1A \x1B[1G \x1B[2K " .
815
+ "\x1B[1G \x1B [2K \x1B [ 1A \x1B[1G \x1B[2K " .
816
816
$ this ->generateOutput ("============================ \nfoobar " ),
817
817
stream_get_contents ($ output ->getStream ())
818
818
);
@@ -983,7 +983,7 @@ protected function generateOutput($expected)
983
983
{
984
984
$ count = substr_count ($ expected , "\n" );
985
985
986
- return ($ count ? sprintf ("\x1B[%dA \x1B [ 1G \x1b[2K " , $ count ) : "\x1B[1G \x1B[2K " ) .$ expected ;
986
+ return ($ count ? str_repeat ("\x1B[1G \x1b[2K \x1B [1A " , $ count ) : '' ). "\x1B[1G \x1B[2K " .$ expected ;
987
987
}
988
988
989
989
public function testBarWidthWithMultilineFormat ()
@@ -1095,4 +1095,33 @@ public function testNoWriteWhenMessageIsSame()
1095
1095
stream_get_contents ($ output ->getStream ())
1096
1096
);
1097
1097
}
1098
+
1099
+ public function testMultiLineFormatIsFullyCleared ()
1100
+ {
1101
+ $ bar = new ProgressBar ($ output = $ this ->getOutputStream (), 3 );
1102
+ $ bar ->setFormat ("%current%/%max% \n%message% \nFoo " );
1103
+
1104
+ $ bar ->setMessage ('1234567890 ' );
1105
+ $ bar ->start ();
1106
+ $ bar ->display ();
1107
+
1108
+ $ bar ->setMessage ('ABC ' );
1109
+ $ bar ->advance ();
1110
+ $ bar ->display ();
1111
+
1112
+ $ bar ->setMessage ('A ' );
1113
+ $ bar ->advance ();
1114
+ $ bar ->display ();
1115
+
1116
+ $ bar ->finish ();
1117
+
1118
+ rewind ($ output ->getStream ());
1119
+ $ this ->assertEquals (
1120
+ "0/3 \n1234567890 \nFoo " .
1121
+ $ this ->generateOutput ("1/3 \nABC \nFoo " ).
1122
+ $ this ->generateOutput ("2/3 \nA \nFoo " ).
1123
+ $ this ->generateOutput ("3/3 \nA \nFoo " ),
1124
+ stream_get_contents ($ output ->getStream ())
1125
+ );
1126
+ }
1098
1127
}
0 commit comments