@@ -94,9 +94,48 @@ public function testStartWithTitleDifferentColor(): void
9494 ob_clean ();
9595 }
9696
97- /**
98- * @test ->advance() without calling ->start() -> does not do anything
99- */
97+ public function testTitleWithSinglePercentageSign (): void
98+ {
99+ // Test with a single percentage sign
100+ (new ProgressBar (5 ))->setTitle ('Progress: 50% ' , Foreground::GREEN )->start ();
101+
102+ $ this ->assertStringStartsWith (
103+ "\n\n\e[1A \e[1000D \33[2K " . Style::stylize ("\tProgress: 50% " , fg: Foreground::GREEN )
104+ . "\e[1B \e[1000D \33[2K \t0 / 5 [ ] 0% " ,
105+ ob_get_contents ()
106+ );
107+
108+ ob_clean ();
109+ }
110+
111+ public function testTitleWithDoublePercentageSign (): void
112+ {
113+ // Test with a double percentage sign
114+ (new ProgressBar (5 ))->setTitle ('Progress: 100%% ' )->start ();
115+
116+ $ this ->assertStringStartsWith (
117+ "\n\n\e[1A \e[1000D \33[2K " . Style::stylize ("\tProgress: 100%% " , fg: Foreground::BLUE )
118+ . "\e[1B \e[1000D \33[2K \t0 / 5 [ ] 0% " ,
119+ ob_get_contents ()
120+ );
121+
122+ ob_clean ();
123+ }
124+
125+ public function testTitleWithMultiplePercentageSigns (): void
126+ {
127+ // Test with multiple percentage signs
128+ (new ProgressBar (5 ))->setTitle ('Progress: 25% and 75% ' )->start ();
129+
130+ $ this ->assertStringStartsWith (
131+ "\n\n\e[1A \e[1000D \33[2K " . Style::stylize ("\tProgress: 25% and 75% " , fg: Foreground::BLUE )
132+ . "\e[1B \e[1000D \33[2K \t0 / 5 [ ] 0% " ,
133+ ob_get_contents ()
134+ );
135+
136+ ob_clean ();
137+ }
138+
100139 public function testAdvanceWithoutStarting (): void
101140 {
102141 $ this ->expectOutputString ('' );
0 commit comments