Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 159bd27

Browse filesBrowse files
committed
ProgressBar clears too many lines on update (test only, should fail)
1 parent bbf786c commit 159bd27
Copy full SHA for 159bd27

File tree

Expand file treeCollapse file tree

1 file changed

+26
-0
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+26
-0
lines changed

‎src/Symfony/Component/Console/Tests/Helper/ProgressBarTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Tests/Helper/ProgressBarTest.php
+26Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,32 @@ public function testOverwriteWithSectionOutput()
343343
);
344344
}
345345

346+
// ensure that ANSI characters are excluded when calculating line length
347+
public function testOverwriteWithAnsiSectionOutput()
348+
{
349+
// output has 43 visible characters plus 2 invisible ANSI characters
350+
putenv('COLUMNS=43');
351+
$sections = [];
352+
$stream = $this->getOutputStream(true);
353+
$output = new ConsoleSectionOutput($stream->getStream(), $sections, $stream->getVerbosity(), $stream->isDecorated(), new OutputFormatter());
354+
355+
$bar = new ProgressBar($output, 50, 0);
356+
$bar->setFormat(" \033[44;37m%current%/%max%\033[0m [%bar%] %percent:3s%%");
357+
$bar->start();
358+
$bar->display();
359+
$bar->advance();
360+
$bar->advance();
361+
362+
rewind($output->getStream());
363+
$this->assertEquals(
364+
" \033[44;37m 0/50\033[0m [>---------------------------] 0%".\PHP_EOL.
365+
"\x1b[1A\x1b[0J"." \033[44;37m 1/50\033[0m [>---------------------------] 2%".\PHP_EOL.
366+
"\x1b[1A\x1b[0J"." \033[44;37m 2/50\033[0m [=>--------------------------] 4%".\PHP_EOL,
367+
stream_get_contents($output->getStream())
368+
);
369+
putenv('COLUMNS=120');
370+
}
371+
346372
public function testOverwriteMultipleProgressBarsWithSectionOutputs()
347373
{
348374
$sections = [];

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.