@@ -133,6 +133,40 @@ public function testMaxHeight()
133133 $ this ->assertEquals ($ expected , stream_get_contents ($ output ->getStream ()));
134134 }
135135
136+ public function testMaxHeightMultipleSections ()
137+ {
138+ $ expected = '' ;
139+ $ sections = [];
140+
141+ $ firstSection = new ConsoleSectionOutput ($ this ->stream , $ sections , OutputInterface::VERBOSITY_NORMAL , true , new OutputFormatter ());
142+ $ firstSection ->setMaxHeight (3 );
143+
144+ $ secondSection = new ConsoleSectionOutput ($ this ->stream , $ sections , OutputInterface::VERBOSITY_NORMAL , true , new OutputFormatter ());
145+ $ secondSection ->setMaxHeight (3 );
146+
147+ // fill the first section
148+ $ firstSection ->writeln (['One ' , 'Two ' , 'Three ' ]);
149+ $ expected .= 'One ' .\PHP_EOL .'Two ' .\PHP_EOL .'Three ' .\PHP_EOL ;
150+
151+ // fill the second section
152+ $ secondSection ->writeln (['One ' , 'Two ' , 'Three ' ]);
153+ $ expected .= 'One ' .\PHP_EOL .'Two ' .\PHP_EOL .'Three ' .\PHP_EOL ;
154+
155+ // cause overflow of second section (redraw whole section, without first line)
156+ $ secondSection ->writeln ('Four ' );
157+ $ expected .= "\x1b[3A \x1b[0J " ;
158+ $ expected .= 'Two ' .\PHP_EOL .'Three ' .\PHP_EOL .'Four ' .\PHP_EOL ;
159+
160+ // cause overflow of first section (redraw whole section, without first line)
161+ $ firstSection ->writeln ("Four \nFive \nSix " );
162+ $ expected .= "\x1b[6A \x1b[0J " ;
163+ $ expected .= 'Four ' .\PHP_EOL .'Five ' .\PHP_EOL .'Six ' .\PHP_EOL ;
164+ $ expected .= 'Two ' .\PHP_EOL .'Three ' .\PHP_EOL .'Four ' .\PHP_EOL ;
165+
166+ rewind ($ this ->stream );
167+ $ this ->assertEquals (escapeshellcmd ($ expected ), escapeshellcmd (stream_get_contents ($ this ->stream )));
168+ }
169+
136170 public function testMaxHeightWithoutNewLine ()
137171 {
138172 $ expected = '' ;
0 commit comments