File tree 2 files changed +24
-0
lines changed
src/Symfony/Component/Console
2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -364,6 +364,7 @@ private function setRealFormat(string $format)
364
364
365
365
public function setMaxSteps (int $ max )
366
366
{
367
+ $ this ->format = null ;
367
368
$ this ->max = max (0 , $ max );
368
369
$ this ->stepWidth = $ this ->max ? Helper::strlen ((string ) $ this ->max ) : 4 ;
369
370
}
Original file line number Diff line number Diff line change @@ -592,6 +592,29 @@ public function testWithoutMax()
592
592
);
593
593
}
594
594
595
+ public function testSettingMaxStepsDuringProgressing ()
596
+ {
597
+ $ output = $ this ->getOutputStream ();
598
+ $ bar = new ProgressBar ($ output );
599
+ $ bar ->start ();
600
+ $ bar ->setProgress (2 );
601
+ $ bar ->setMaxSteps (10 );
602
+ $ bar ->setProgress (5 );
603
+ $ bar ->setMaxSteps (100 );
604
+ $ bar ->setProgress (10 );
605
+ $ bar ->finish ();
606
+
607
+ rewind ($ output ->getStream ());
608
+ $ this ->assertEquals (
609
+ rtrim (' 0 [>---------------------------] ' ).
610
+ rtrim ($ this ->generateOutput (' 2 [-->-------------------------] ' )).
611
+ rtrim ($ this ->generateOutput (' 5/10 [==============>-------------] 50% ' )).
612
+ rtrim ($ this ->generateOutput (' 10/100 [==>-------------------------] 10% ' )).
613
+ rtrim ($ this ->generateOutput (' 100/100 [============================] 100% ' )),
614
+ stream_get_contents ($ output ->getStream ())
615
+ );
616
+ }
617
+
595
618
public function testWithSmallScreen ()
596
619
{
597
620
$ output = $ this ->getOutputStream ();
You can’t perform that action at this time.
0 commit comments