platform/api/symfony/Component/Console/Tests/Helper/ProgressBarTest.yaml
2024-09-02 10:44:11 -07:00

526 lines
41 KiB
YAML

name: ProgressBarTest
class_comment: '# * @group time-sensitive'
dependencies:
- name: TestCase
type: class
source: PHPUnit\Framework\TestCase
- name: OutputFormatter
type: class
source: Symfony\Component\Console\Formatter\OutputFormatter
- name: Helper
type: class
source: Symfony\Component\Console\Helper\Helper
- name: ProgressBar
type: class
source: Symfony\Component\Console\Helper\ProgressBar
- name: ConsoleSectionOutput
type: class
source: Symfony\Component\Console\Output\ConsoleSectionOutput
- name: StreamOutput
type: class
source: Symfony\Component\Console\Output\StreamOutput
properties: []
methods:
- name: testFormatsWithoutMax
visibility: public
parameters:
- name: format
comment: "# * @group time-sensitive\n# */\n# class ProgressBarTest extends TestCase\n\
# {\n# private string|false $colSize;\n# \n# protected function setUp(): void\n\
# {\n# $this->colSize = getenv('COLUMNS');\n# putenv('COLUMNS=120');\n# }\n# \n\
# protected function tearDown(): void\n# {\n# putenv($this->colSize ? 'COLUMNS='.$this->colSize\
\ : 'COLUMNS');\n# }\n# \n# public function testMultipleStart()\n# {\n# $bar =\
\ new ProgressBar($output = $this->getOutputStream(), 0, 0);\n# $bar->start();\n\
# $bar->advance();\n# $bar->start();\n# \n# rewind($output->getStream());\n# $this->assertEquals(\n\
# ' 0 [>---------------------------]'.\n# $this->generateOutput(' 1 [->--------------------------]').\n\
# $this->generateOutput(' 0 [>---------------------------]'),\n# stream_get_contents($output->getStream())\n\
# );\n# }\n# \n# public function testAdvance()\n# {\n# $bar = new ProgressBar($output\
\ = $this->getOutputStream(), 0, 0);\n# $bar->start();\n# $bar->advance();\n#\
\ \n# rewind($output->getStream());\n# $this->assertEquals(\n# ' 0 [>---------------------------]'.\n\
# $this->generateOutput(' 1 [->--------------------------]'),\n# stream_get_contents($output->getStream())\n\
# );\n# }\n# \n# public function testResumeNoMax()\n# {\n# $bar = new ProgressBar($output\
\ = $this->getOutputStream(), 0, 0);\n# $bar->start(null, 15);\n# $bar->advance();\n\
# \n# rewind($output->getStream());\n# \n# $this->assertEquals(\n# ' 15 [--------------->------------]'.\n\
# $this->generateOutput(' 16 [---------------->-----------]'),\n# stream_get_contents($output->getStream())\n\
# );\n# }\n# \n# public function testResumeWithMax()\n# {\n# $bar = new ProgressBar($output\
\ = $this->getOutputStream(), 5000, 0);\n# $bar->start(null, 1000);\n# \n# rewind($output->getStream());\n\
# \n# $this->assertEquals(\n# ' 1000/5000 [=====>----------------------] 20%',\n\
# stream_get_contents($output->getStream())\n# );\n# }\n# \n# public function\
\ testRegularTimeEstimation()\n# {\n# $bar = new ProgressBar($output = $this->getOutputStream(),\
\ 1_200, 0);\n# $bar->start();\n# \n# $bar->advance();\n# $bar->advance();\n#\
\ \n# sleep(1);\n# \n# $this->assertEquals(\n# 600.0,\n# $bar->getEstimated()\n\
# );\n# }\n# \n# public function testResumedTimeEstimation()\n# {\n# $bar = new\
\ ProgressBar($output = $this->getOutputStream(), 1_200, 0);\n# $bar->start(null,\
\ 599);\n# $bar->advance();\n# \n# sleep(1);\n# \n# $this->assertEquals(\n# 1_200.0,\n\
# $bar->getEstimated()\n# );\n# \n# $this->assertEquals(\n# 600.0,\n# $bar->getRemaining()\n\
# );\n# }\n# \n# public function testAdvanceWithStep()\n# {\n# $bar = new ProgressBar($output\
\ = $this->getOutputStream(), 0, 0);\n# $bar->start();\n# $bar->advance(5);\n\
# \n# rewind($output->getStream());\n# $this->assertEquals(\n# ' 0 [>---------------------------]'.\n\
# $this->generateOutput(' 5 [----->----------------------]'),\n# stream_get_contents($output->getStream())\n\
# );\n# }\n# \n# public function testAdvanceMultipleTimes()\n# {\n# $bar = new\
\ ProgressBar($output = $this->getOutputStream(), 0, 0);\n# $bar->start();\n#\
\ $bar->advance(3);\n# $bar->advance(2);\n# \n# rewind($output->getStream());\n\
# $this->assertEquals(\n# ' 0 [>---------------------------]'.\n# $this->generateOutput('\
\ 3 [--->------------------------]').\n# $this->generateOutput(' 5 [----->----------------------]'),\n\
# stream_get_contents($output->getStream())\n# );\n# }\n# \n# public function\
\ testAdvanceOverMax()\n# {\n# $bar = new ProgressBar($output = $this->getOutputStream(),\
\ 10, 0);\n# $bar->setProgress(9);\n# $bar->advance();\n# $bar->advance();\n#\
\ \n# rewind($output->getStream());\n# $this->assertEquals(\n# ' 9/10 [=========================>--]\
\ 90%'.\n# $this->generateOutput(' 10/10 [============================] 100%').\n\
# $this->generateOutput(' 11/11 [============================] 100%'),\n# stream_get_contents($output->getStream())\n\
# );\n# }\n# \n# public function testRegress()\n# {\n# $bar = new ProgressBar($output\
\ = $this->getOutputStream(), 0, 0);\n# $bar->start();\n# $bar->advance();\n#\
\ $bar->advance();\n# $bar->advance(-1);\n# \n# rewind($output->getStream());\n\
# $this->assertEquals(\n# ' 0 [>---------------------------]'.\n# $this->generateOutput('\
\ 1 [->--------------------------]').\n# $this->generateOutput(' 2 [-->-------------------------]').\n\
# $this->generateOutput(' 1 [->--------------------------]'),\n# stream_get_contents($output->getStream())\n\
# );\n# }\n# \n# public function testRegressWithStep()\n# {\n# $bar = new ProgressBar($output\
\ = $this->getOutputStream(), 0, 0);\n# $bar->start();\n# $bar->advance(4);\n\
# $bar->advance(4);\n# $bar->advance(-2);\n# \n# rewind($output->getStream());\n\
# $this->assertEquals(\n# ' 0 [>---------------------------]'.\n# $this->generateOutput('\
\ 4 [---->-----------------------]').\n# $this->generateOutput(' 8 [-------->-------------------]').\n\
# $this->generateOutput(' 6 [------>---------------------]'),\n# stream_get_contents($output->getStream())\n\
# );\n# }\n# \n# public function testRegressMultipleTimes()\n# {\n# $bar = new\
\ ProgressBar($output = $this->getOutputStream(), 0, 0);\n# $bar->start();\n#\
\ $bar->advance(3);\n# $bar->advance(3);\n# $bar->advance(-1);\n# $bar->advance(-2);\n\
# \n# rewind($output->getStream());\n# $this->assertEquals(\n# ' 0 [>---------------------------]'.\n\
# $this->generateOutput(' 3 [--->------------------------]').\n# $this->generateOutput('\
\ 6 [------>---------------------]').\n# $this->generateOutput(' 5 [----->----------------------]').\n\
# $this->generateOutput(' 3 [--->------------------------]'),\n# stream_get_contents($output->getStream())\n\
# );\n# }\n# \n# public function testRegressBelowMin()\n# {\n# $bar = new ProgressBar($output\
\ = $this->getOutputStream(), 10, 0);\n# $bar->setProgress(1);\n# $bar->advance(-1);\n\
# $bar->advance(-1);\n# \n# rewind($output->getStream());\n# $this->assertEquals(\n\
# ' 1/10 [==>-------------------------] 10%'.\n# $this->generateOutput(' 0/10\
\ [>---------------------------] 0%'),\n# stream_get_contents($output->getStream())\n\
# );\n# }\n# \n# public function testFormat()\n# {\n# $expected =\n# ' 0/10 [>---------------------------]\
\ 0%'.\n# $this->generateOutput(' 10/10 [============================] 100%')\n\
# ;\n# \n# // max in construct, no format\n# $bar = new ProgressBar($output =\
\ $this->getOutputStream(), 10, 0);\n# $bar->start();\n# $bar->advance(10);\n\
# $bar->finish();\n# \n# rewind($output->getStream());\n# $this->assertEquals($expected,\
\ stream_get_contents($output->getStream()));\n# \n# // max in start, no format\n\
# $bar = new ProgressBar($output = $this->getOutputStream(), 0, 0);\n# $bar->start(10);\n\
# $bar->advance(10);\n# $bar->finish();\n# \n# rewind($output->getStream());\n\
# $this->assertEquals($expected, stream_get_contents($output->getStream()));\n\
# \n# // max in construct, explicit format before\n# $bar = new ProgressBar($output\
\ = $this->getOutputStream(), 10, 0);\n# $bar->setFormat(ProgressBar::FORMAT_NORMAL);\n\
# $bar->start();\n# $bar->advance(10);\n# $bar->finish();\n# \n# rewind($output->getStream());\n\
# $this->assertEquals($expected, stream_get_contents($output->getStream()));\n\
# \n# // max in start, explicit format before\n# $bar = new ProgressBar($output\
\ = $this->getOutputStream(), 0, 0);\n# $bar->setFormat(ProgressBar::FORMAT_NORMAL);\n\
# $bar->start(10);\n# $bar->advance(10);\n# $bar->finish();\n# \n# rewind($output->getStream());\n\
# $this->assertEquals($expected, stream_get_contents($output->getStream()));\n\
# }\n# \n# public function testCustomizations()\n# {\n# $bar = new ProgressBar($output\
\ = $this->getOutputStream(), 10, 0);\n# $bar->setBarWidth(10);\n# $bar->setBarCharacter('_');\n\
# $bar->setEmptyBarCharacter(' ');\n# $bar->setProgressCharacter('/');\n# $bar->setFormat('\
\ %current%/%max% [%bar%] %percent:3s%%');\n# $bar->start();\n# $bar->advance();\n\
# \n# rewind($output->getStream());\n# $this->assertEquals(\n# ' 0/10 [/ \
\ ] 0%'.\n# $this->generateOutput(' 1/10 [_/ ] 10%'),\n# stream_get_contents($output->getStream())\n\
# );\n# }\n# \n# public function testDisplayWithoutStart()\n# {\n# $bar = new\
\ ProgressBar($output = $this->getOutputStream(), 50, 0);\n# $bar->display();\n\
# \n# rewind($output->getStream());\n# $this->assertEquals(\n# ' 0/50 [>---------------------------]\
\ 0%',\n# stream_get_contents($output->getStream())\n# );\n# }\n# \n# public\
\ function testDisplayWithQuietVerbosity()\n# {\n# $bar = new ProgressBar($output\
\ = $this->getOutputStream(true, StreamOutput::VERBOSITY_QUIET), 50, 0);\n# $bar->display();\n\
# \n# rewind($output->getStream());\n# $this->assertEquals(\n# '',\n# stream_get_contents($output->getStream())\n\
# );\n# }\n# \n# public function testFinishWithoutStart()\n# {\n# $bar = new ProgressBar($output\
\ = $this->getOutputStream(), 50, 0);\n# $bar->finish();\n# \n# rewind($output->getStream());\n\
# $this->assertEquals(\n# ' 50/50 [============================] 100%',\n# stream_get_contents($output->getStream())\n\
# );\n# }\n# \n# public function testPercent()\n# {\n# $bar = new ProgressBar($output\
\ = $this->getOutputStream(), 50, 0);\n# $bar->start();\n# $bar->display();\n\
# $bar->advance();\n# $bar->advance();\n# \n# rewind($output->getStream());\n\
# $this->assertEquals(\n# ' 0/50 [>---------------------------] 0%'.\n# $this->generateOutput('\
\ 1/50 [>---------------------------] 2%').\n# $this->generateOutput(' 2/50\
\ [=>--------------------------] 4%'),\n# stream_get_contents($output->getStream())\n\
# );\n# }\n# \n# public function testOverwriteWithShorterLine()\n# {\n# $bar =\
\ new ProgressBar($output = $this->getOutputStream(), 50, 0);\n# $bar->setFormat('\
\ %current%/%max% [%bar%] %percent:3s%%');\n# $bar->start();\n# $bar->display();\n\
# $bar->advance();\n# \n# // set shorter format\n# $bar->setFormat(' %current%/%max%\
\ [%bar%]');\n# $bar->advance();\n# \n# rewind($output->getStream());\n# $this->assertEquals(\n\
# ' 0/50 [>---------------------------] 0%'.\n# $this->generateOutput(' 1/50\
\ [>---------------------------] 2%').\n# $this->generateOutput(' 2/50 [=>--------------------------]'),\n\
# stream_get_contents($output->getStream())\n# );\n# }\n# \n# public function\
\ testOverwriteWithSectionOutput()\n# {\n# $sections = [];\n# $stream = $this->getOutputStream(true);\n\
# $output = new ConsoleSectionOutput($stream->getStream(), $sections, $stream->getVerbosity(),\
\ $stream->isDecorated(), new OutputFormatter());\n# \n# $bar = new ProgressBar($output,\
\ 50, 0);\n# $bar->start();\n# $bar->display();\n# $bar->advance();\n# $bar->advance();\n\
# \n# rewind($output->getStream());\n# $this->assertEquals(\n# ' 0/50 [>---------------------------]\
\ 0%'.\\PHP_EOL.\n# \"\\x1b[1A\\x1b[0J\".' 1/50 [>---------------------------]\
\ 2%'.\\PHP_EOL.\n# \"\\x1b[1A\\x1b[0J\".' 2/50 [=>--------------------------]\
\ 4%'.\\PHP_EOL,\n# stream_get_contents($output->getStream())\n# );\n# }\n#\
\ \n# public function testOverwriteWithAnsiSectionOutput()\n# {\n# // output has\
\ 43 visible characters plus 2 invisible ANSI characters\n# putenv('COLUMNS=43');\n\
# $sections = [];\n# $stream = $this->getOutputStream(true);\n# $output = new\
\ ConsoleSectionOutput($stream->getStream(), $sections, $stream->getVerbosity(),\
\ $stream->isDecorated(), new OutputFormatter());\n# \n# $bar = new ProgressBar($output,\
\ 50, 0);\n# $bar->setFormat(\" \\033[44;37m%current%/%max%\\033[0m [%bar%] %percent:3s%%\"\
);\n# $bar->start();\n# $bar->display();\n# $bar->advance();\n# $bar->advance();\n\
# \n# rewind($output->getStream());\n# $this->assertSame(\n# \" \\033[44;37m 0/50\\\
033[0m [>---------------------------] 0%\".\\PHP_EOL.\n# \"\\x1b[1A\\x1b[0J\
\ \\033[44;37m 1/50\\033[0m [>---------------------------] 2%\".\\PHP_EOL.\n\
# \"\\x1b[1A\\x1b[0J \\033[44;37m 2/50\\033[0m [=>--------------------------]\
\ 4%\".\\PHP_EOL,\n# stream_get_contents($output->getStream())\n# );\n# putenv('COLUMNS=120');\n\
# }\n# \n# public function testOverwriteMultipleProgressBarsWithSectionOutputs()\n\
# {\n# $sections = [];\n# $stream = $this->getOutputStream(true);\n# $output1\
\ = new ConsoleSectionOutput($stream->getStream(), $sections, $stream->getVerbosity(),\
\ $stream->isDecorated(), new OutputFormatter());\n# $output2 = new ConsoleSectionOutput($stream->getStream(),\
\ $sections, $stream->getVerbosity(), $stream->isDecorated(), new OutputFormatter());\n\
# \n# $progress = new ProgressBar($output1, 50, 0);\n# $progress2 = new ProgressBar($output2,\
\ 50, 0);\n# \n# $progress->start();\n# $progress2->start();\n# \n# $progress2->advance();\n\
# $progress->advance();\n# \n# rewind($stream->getStream());\n# \n# $this->assertEquals(\n\
# ' 0/50 [>---------------------------] 0%'.\\PHP_EOL.\n# ' 0/50 [>---------------------------]\
\ 0%'.\\PHP_EOL.\n# \"\\x1b[1A\\x1b[0J\".' 1/50 [>---------------------------]\
\ 2%'.\\PHP_EOL.\n# \"\\x1b[2A\\x1b[0J\".' 1/50 [>---------------------------]\
\ 2%'.\\PHP_EOL.\n# \"\\x1b[1A\\x1b[0J\".' 1/50 [>---------------------------]\
\ 2%'.\\PHP_EOL.\n# ' 1/50 [>---------------------------] 2%'.\\PHP_EOL,\n\
# stream_get_contents($stream->getStream())\n# );\n# }\n# \n# public function\
\ testOverwritWithNewlinesInMessage()\n# {\n# ProgressBar::setFormatDefinition('test',\
\ '%current%/%max% [%bar%] %percent:3s%% %message% Fruitcake marzipan toffee.\
\ Cupcake gummi bears tart dessert ice cream chupa chups cupcake chocolate bar\
\ sesame snaps. Croissant halvah cookie jujubes powder macaroon. Fruitcake bear\
\ claw bonbon jelly beans oat cake pie muffin Fruitcake marzipan toffee.');\n\
# \n# $bar = new ProgressBar($output = $this->getOutputStream(), 50, 0);\n# $bar->setFormat('test');\n\
# $bar->start();\n# $bar->display();\n# $bar->setMessage(\"Twas brillig, and the\
\ slithy toves. Did gyre and gimble in the wabe: All mimsy were the borogoves,\
\ And the mome raths outgrabe.\\nBeware the Jabberwock, my son! The jaws that\
\ bite, the claws that catch! Beware the Jubjub bird, and shun The frumious Bandersnatch!\"\
);\n# $bar->advance();\n# $bar->setMessage(\"He took his vorpal sword in hand;\
\ Long time the manxome foe he sought\u2014 So rested he by the Tumtum tree And\
\ stood awhile in thought.\\nAnd, as in uffish thought he stood, The Jabberwock,\
\ with eyes of flame, Came whiffling through the tulgey wood, And burbled as it\
\ came!\");\n# $bar->advance();\n# \n# rewind($output->getStream());\n# $this->assertEquals(\n\
# \" 0/50 [>] 0% %message% Fruitcake marzipan toffee. Cupcake gummi bears tart\
\ dessert ice cream chupa chups cupcake chocolate bar sesame snaps. Croissant\
\ halvah cookie jujubes powder macaroon. Fruitcake bear claw bonbon jelly beans\
\ oat cake pie muffin Fruitcake marzipan toffee.\\x1b[1G\\x1b[2K 1/50 [>] 2%\
\ Twas brillig, and the slithy toves. Did gyre and gimble in the wabe: All mimsy\
\ were the borogoves, And the mome raths outgrabe.\n# Beware the Jabberwock, my\
\ son! The jaws that bite, the claws that catch! Beware the Jubjub bird, and shun\
\ The frumious Bandersnatch! Fruitcake marzipan toffee. Cupcake gummi bears tart\
\ dessert ice cream chupa chups cupcake chocolate bar sesame snaps. Croissant\
\ halvah cookie jujubes powder macaroon. Fruitcake bear claw bonbon jelly beans\
\ oat cake pie muffin Fruitcake marzipan toffee.\\x1b[1G\\x1b[2K\\x1b[1A\\x1b[1G\\\
x1b[2K 2/50 [>] 4% He took his vorpal sword in hand; Long time the manxome foe\
\ he sought\u2014 So rested he by the Tumtum tree And stood awhile in thought.\n\
# And, as in uffish thought he stood, The Jabberwock, with eyes of flame, Came\
\ whiffling through the tulgey wood, And burbled as it came! Fruitcake marzipan\
\ toffee. Cupcake gummi bears tart dessert ice cream chupa chups cupcake chocolate\
\ bar sesame snaps. Croissant halvah cookie jujubes powder macaroon. Fruitcake\
\ bear claw bonbon jelly beans oat cake pie muffin Fruitcake marzipan toffee.\"\
,\n# stream_get_contents($output->getStream())\n# );\n# }\n# \n# public function\
\ testOverwriteWithSectionOutputWithNewlinesInMessage()\n# {\n# $sections = [];\n\
# $stream = $this->getOutputStream(true);\n# $output = new ConsoleSectionOutput($stream->getStream(),\
\ $sections, $stream->getVerbosity(), $stream->isDecorated(), new OutputFormatter());\n\
# \n# ProgressBar::setFormatDefinition('test', '%current%/%max% [%bar%] %percent:3s%%\
\ %message% Fruitcake marzipan toffee. Cupcake gummi bears tart dessert ice cream\
\ chupa chups cupcake chocolate bar sesame snaps. Croissant halvah cookie jujubes\
\ powder macaroon. Fruitcake bear claw bonbon jelly beans oat cake pie muffin\
\ Fruitcake marzipan toffee.');\n# \n# $bar = new ProgressBar($output, 50, 0);\n\
# $bar->setFormat('test');\n# $bar->start();\n# $bar->display();\n# $bar->setMessage(\"\
Twas brillig, and the slithy toves. Did gyre and gimble in the wabe: All mimsy\
\ were the borogoves, And the mome raths outgrabe.\\nBeware the Jabberwock, my\
\ son! The jaws that bite, the claws that catch! Beware the Jubjub bird, and shun\
\ The frumious Bandersnatch!\");\n# $bar->advance();\n# $bar->setMessage(\"He\
\ took his vorpal sword in hand; Long time the manxome foe he sought\u2014 So\
\ rested he by the Tumtum tree And stood awhile in thought.\\nAnd, as in uffish\
\ thought he stood, The Jabberwock, with eyes of flame, Came whiffling through\
\ the tulgey wood, And burbled as it came!\");\n# $bar->advance();\n# \n# rewind($output->getStream());\n\
# $this->assertEquals(\n# ' 0/50 [>] 0% %message% Fruitcake marzipan toffee.\
\ Cupcake gummi bears tart dessert ice cream chupa chups cupcake chocolate bar\
\ sesame snaps. Croissant halvah cookie jujubes powder macaroon. Fruitcake bear\
\ claw bonbon jelly beans oat cake pie muffin Fruitcake marzipan toffee.'.\\PHP_EOL.\n\
# \"\\x1b[3A\\x1b[0J 1/50 [>] 2% Twas brillig, and the slithy toves. Did gyre\
\ and gimble in the wabe: All mimsy were the borogoves, And the mome raths outgrabe.\n\
# Beware the Jabberwock, my son! The jaws that bite, the claws that catch! Beware\
\ the Jubjub bird, and shun The frumious Bandersnatch! Fruitcake marzipan toffee.\
\ Cupcake gummi bears tart dessert ice cream chupa chups cupcake chocolate bar\
\ sesame snaps. Croissant halvah cookie jujubes powder macaroon. Fruitcake bear\
\ claw bonbon jelly beans oat cake pie muffin Fruitcake marzipan toffee.\".\\\
PHP_EOL.\n# \"\\x1b[6A\\x1b[0J 2/50 [>] 4% He took his vorpal sword in hand;\
\ Long time the manxome foe he sought\u2014 So rested he by the Tumtum tree And\
\ stood awhile in thought.\n# And, as in uffish thought he stood, The Jabberwock,\
\ with eyes of flame, Came whiffling through the tulgey wood, And burbled as it\
\ came! Fruitcake marzipan toffee. Cupcake gummi bears tart dessert ice cream\
\ chupa chups cupcake chocolate bar sesame snaps. Croissant halvah cookie jujubes\
\ powder macaroon. Fruitcake bear claw bonbon jelly beans oat cake pie muffin\
\ Fruitcake marzipan toffee.\".\\PHP_EOL,\n# stream_get_contents($output->getStream())\n\
# );\n# }\n# \n# public function testMultipleSectionsWithCustomFormat()\n# {\n\
# $sections = [];\n# $stream = $this->getOutputStream(true);\n# $output1 = new\
\ ConsoleSectionOutput($stream->getStream(), $sections, $stream->getVerbosity(),\
\ $stream->isDecorated(), new OutputFormatter());\n# $output2 = new ConsoleSectionOutput($stream->getStream(),\
\ $sections, $stream->getVerbosity(), $stream->isDecorated(), new OutputFormatter());\n\
# \n# ProgressBar::setFormatDefinition('test', '%current%/%max% [%bar%] %percent:3s%%\
\ Fruitcake marzipan toffee. Cupcake gummi bears tart dessert ice cream chupa\
\ chups cupcake chocolate bar sesame snaps. Croissant halvah cookie jujubes powder\
\ macaroon. Fruitcake bear claw bonbon jelly beans oat cake pie muffin Fruitcake\
\ marzipan toffee.');\n# \n# $progress = new ProgressBar($output1, 50, 0);\n#\
\ $progress2 = new ProgressBar($output2, 50, 0);\n# $progress2->setFormat('test');\n\
# \n# $progress->start();\n# $progress2->start();\n# \n# $progress->advance();\n\
# $progress2->advance();\n# \n# rewind($stream->getStream());\n# \n# $this->assertEquals('\
\ 0/50 [>---------------------------] 0%'.\\PHP_EOL.\n# ' 0/50 [>] 0% Fruitcake\
\ marzipan toffee. Cupcake gummi bears tart dessert ice cream chupa chups cupcake\
\ chocolate bar sesame snaps. Croissant halvah cookie jujubes powder macaroon.\
\ Fruitcake bear claw bonbon jelly beans oat cake pie muffin Fruitcake marzipan\
\ toffee.'.\\PHP_EOL.\n# \"\\x1b[4A\\x1b[0J\".' 0/50 [>] 0% Fruitcake marzipan\
\ toffee. Cupcake gummi bears tart dessert ice cream chupa chups cupcake chocolate\
\ bar sesame snaps. Croissant halvah cookie jujubes powder macaroon. Fruitcake\
\ bear claw bonbon jelly beans oat cake pie muffin Fruitcake marzipan toffee.'.\\\
PHP_EOL.\n# \"\\x1b[3A\\x1b[0J\".' 1/50 [>---------------------------] 2%'.\\\
PHP_EOL.\n# ' 0/50 [>] 0% Fruitcake marzipan toffee. Cupcake gummi bears tart\
\ dessert ice cream chupa chups cupcake chocolate bar sesame snaps. Croissant\
\ halvah cookie jujubes powder macaroon. Fruitcake bear claw bonbon jelly beans\
\ oat cake pie muffin Fruitcake marzipan toffee.'.\\PHP_EOL.\n# \"\\x1b[3A\\x1b[0J\"\
.' 1/50 [>] 2% Fruitcake marzipan toffee. Cupcake gummi bears tart dessert ice\
\ cream chupa chups cupcake chocolate bar sesame snaps. Croissant halvah cookie\
\ jujubes powder macaroon. Fruitcake bear claw bonbon jelly beans oat cake pie\
\ muffin Fruitcake marzipan toffee.'.\\PHP_EOL,\n# stream_get_contents($stream->getStream())\n\
# );\n# }\n# \n# public function testStartWithMax()\n# {\n# $bar = new ProgressBar($output\
\ = $this->getOutputStream(), 0, 0);\n# $bar->setFormat('%current%/%max% [%bar%]');\n\
# $bar->start(50);\n# $bar->advance();\n# \n# rewind($output->getStream());\n\
# $this->assertEquals(\n# ' 0/50 [>---------------------------]'.\n# $this->generateOutput('\
\ 1/50 [>---------------------------]'),\n# stream_get_contents($output->getStream())\n\
# );\n# }\n# \n# public function testSetCurrentProgress()\n# {\n# $bar = new ProgressBar($output\
\ = $this->getOutputStream(), 50, 0);\n# $bar->start();\n# $bar->display();\n\
# $bar->advance();\n# $bar->setProgress(15);\n# $bar->setProgress(25);\n# \n#\
\ rewind($output->getStream());\n# $this->assertEquals(\n# ' 0/50 [>---------------------------]\
\ 0%'.\n# $this->generateOutput(' 1/50 [>---------------------------] 2%').\n\
# $this->generateOutput(' 15/50 [========>-------------------] 30%').\n# $this->generateOutput('\
\ 25/50 [==============>-------------] 50%'),\n# stream_get_contents($output->getStream())\n\
# );\n# }\n# \n# public function testSetCurrentBeforeStarting()\n# {\n# $bar =\
\ new ProgressBar($this->getOutputStream(), 0, 0);\n# $bar->setProgress(15);\n\
# $this->assertNotNull($bar->getStartTime());\n# }\n# \n# public function testRedrawFrequency()\n\
# {\n# $bar = new ProgressBar($output = $this->getOutputStream(), 6, 0);\n# $bar->setRedrawFrequency(2);\n\
# $bar->start();\n# $bar->setProgress(1);\n# $bar->advance(2);\n# $bar->advance(2);\n\
# $bar->advance(1);\n# \n# rewind($output->getStream());\n# $this->assertEquals(\n\
# ' 0/6 [>---------------------------] 0%'.\n# $this->generateOutput(' 3/6 [==============>-------------]\
\ 50%').\n# $this->generateOutput(' 5/6 [=======================>----] 83%').\n\
# $this->generateOutput(' 6/6 [============================] 100%'),\n# stream_get_contents($output->getStream())\n\
# );\n# }\n# \n# public function testRedrawFrequencyIsAtLeastOneIfZeroGiven()\n\
# {\n# $bar = new ProgressBar($output = $this->getOutputStream(), 0, 0);\n# $bar->setRedrawFrequency(0);\n\
# $bar->start();\n# $bar->advance();\n# \n# rewind($output->getStream());\n# $this->assertEquals(\n\
# ' 0 [>---------------------------]'.\n# $this->generateOutput(' 1 [->--------------------------]'),\n\
# stream_get_contents($output->getStream())\n# );\n# }\n# \n# public function\
\ testRedrawFrequencyIsAtLeastOneIfSmallerOneGiven()\n# {\n# $bar = new ProgressBar($output\
\ = $this->getOutputStream(), 0, 0);\n# $bar->setRedrawFrequency(0);\n# $bar->start();\n\
# $bar->advance();\n# \n# rewind($output->getStream());\n# $this->assertEquals(\n\
# ' 0 [>---------------------------]'.\n# $this->generateOutput(' 1 [->--------------------------]'),\n\
# stream_get_contents($output->getStream())\n# );\n# }\n# \n# public function\
\ testMultiByteSupport()\n# {\n# $bar = new ProgressBar($output = $this->getOutputStream(),\
\ 0, 0);\n# $bar->start();\n# $bar->setBarCharacter('\u25A0');\n# $bar->advance(3);\n\
# \n# rewind($output->getStream());\n# $this->assertEquals(\n# ' 0 [>---------------------------]'.\n\
# $this->generateOutput(' 3 [\u25A0\u25A0\u25A0>------------------------]'),\n\
# stream_get_contents($output->getStream())\n# );\n# }\n# \n# public function\
\ testClear()\n# {\n# $bar = new ProgressBar($output = $this->getOutputStream(),\
\ 50, 0);\n# $bar->start();\n# $bar->setProgress(25);\n# $bar->clear();\n# \n\
# rewind($output->getStream());\n# $this->assertEquals(\n# ' 0/50 [>---------------------------]\
\ 0%'.\n# $this->generateOutput(' 25/50 [==============>-------------] 50%').\n\
# $this->generateOutput(''),\n# stream_get_contents($output->getStream())\n# );\n\
# }\n# \n# public function testPercentNotHundredBeforeComplete()\n# {\n# $bar\
\ = new ProgressBar($output = $this->getOutputStream(), 200, 0);\n# $bar->start();\n\
# $bar->display();\n# $bar->advance(199);\n# $bar->advance();\n# \n# rewind($output->getStream());\n\
# $this->assertEquals(\n# ' 0/200 [>---------------------------] 0%'.\n# $this->generateOutput('\
\ 199/200 [===========================>] 99%').\n# $this->generateOutput(' 200/200\
\ [============================] 100%'),\n# stream_get_contents($output->getStream())\n\
# );\n# }\n# \n# public function testNonDecoratedOutput()\n# {\n# $bar = new ProgressBar($output\
\ = $this->getOutputStream(false), 200, 0);\n# $bar->start();\n# \n# for ($i =\
\ 0; $i < 200; ++$i) {\n# $bar->advance();\n# }\n# \n# $bar->finish();\n# \n#\
\ rewind($output->getStream());\n# $this->assertEquals(\n# ' 0/200 [>---------------------------]\
\ 0%'.\\PHP_EOL.\n# ' 20/200 [==>-------------------------] 10%'.\\PHP_EOL.\n\
# ' 40/200 [=====>----------------------] 20%'.\\PHP_EOL.\n# ' 60/200 [========>-------------------]\
\ 30%'.\\PHP_EOL.\n# ' 80/200 [===========>----------------] 40%'.\\PHP_EOL.\n\
# ' 100/200 [==============>-------------] 50%'.\\PHP_EOL.\n# ' 120/200 [================>-----------]\
\ 60%'.\\PHP_EOL.\n# ' 140/200 [===================>--------] 70%'.\\PHP_EOL.\n\
# ' 160/200 [======================>-----] 80%'.\\PHP_EOL.\n# ' 180/200 [=========================>--]\
\ 90%'.\\PHP_EOL.\n# ' 200/200 [============================] 100%',\n# stream_get_contents($output->getStream())\n\
# );\n# }\n# \n# public function testNonDecoratedOutputWithClear()\n# {\n# $bar\
\ = new ProgressBar($output = $this->getOutputStream(false), 50, 0);\n# $bar->start();\n\
# $bar->setProgress(25);\n# $bar->clear();\n# $bar->setProgress(50);\n# $bar->finish();\n\
# \n# rewind($output->getStream());\n# $this->assertEquals(\n# ' 0/50 [>---------------------------]\
\ 0%'.\\PHP_EOL.\n# ' 25/50 [==============>-------------] 50%'.\\PHP_EOL.\n\
# ' 50/50 [============================] 100%',\n# stream_get_contents($output->getStream())\n\
# );\n# }\n# \n# public function testNonDecoratedOutputWithoutMax()\n# {\n# $bar\
\ = new ProgressBar($output = $this->getOutputStream(false), 0, 0);\n# $bar->start();\n\
# $bar->advance();\n# \n# rewind($output->getStream());\n# $this->assertEquals(\n\
# ' 0 [>---------------------------]'.\\PHP_EOL.\n# ' 1 [->--------------------------]',\n\
# stream_get_contents($output->getStream())\n# );\n# }\n# \n# public function\
\ testParallelBars()\n# {\n# $output = $this->getOutputStream();\n# $bar1 = new\
\ ProgressBar($output, 2, 0);\n# $bar2 = new ProgressBar($output, 3, 0);\n# $bar2->setProgressCharacter('#');\n\
# $bar3 = new ProgressBar($output, 0, 0);\n# \n# $bar1->start();\n# $output->write(\"\
\\n\");\n# $bar2->start();\n# $output->write(\"\\n\");\n# $bar3->start();\n# \n\
# for ($i = 1; $i <= 3; ++$i) {\n# // up two lines\n# $output->write(\"\\033[2A\"\
);\n# if ($i <= 2) {\n# $bar1->advance();\n# }\n# $output->write(\"\\n\");\n#\
\ $bar2->advance();\n# $output->write(\"\\n\");\n# $bar3->advance();\n# }\n# $output->write(\"\
\\033[2A\");\n# $output->write(\"\\n\");\n# $output->write(\"\\n\");\n# $bar3->finish();\n\
# \n# rewind($output->getStream());\n# $this->assertEquals(\n# ' 0/2 [>---------------------------]\
\ 0%'.\"\\n\".\n# ' 0/3 [#---------------------------] 0%'.\"\\n\".\n# rtrim('\
\ 0 [>---------------------------]').\n# \n# \"\\033[2A\".\n# $this->generateOutput('\
\ 1/2 [==============>-------------] 50%').\"\\n\".\n# $this->generateOutput('\
\ 1/3 [=========#------------------] 33%').\"\\n\".\n# rtrim($this->generateOutput('\
\ 1 [->--------------------------]')).\n# \n# \"\\033[2A\".\n# $this->generateOutput('\
\ 2/2 [============================] 100%').\"\\n\".\n# $this->generateOutput('\
\ 2/3 [==================#---------] 66%').\"\\n\".\n# rtrim($this->generateOutput('\
\ 2 [-->-------------------------]')).\n# \n# \"\\033[2A\".\n# \"\\n\".\n#\
\ $this->generateOutput(' 3/3 [============================] 100%').\"\\n\".\n\
# rtrim($this->generateOutput(' 3 [--->------------------------]')).\n# \n\
# \"\\033[2A\".\n# \"\\n\".\n# \"\\n\".\n# rtrim($this->generateOutput(' 3\
\ [============================]')),\n# stream_get_contents($output->getStream())\n\
# );\n# }\n# \n# public function testWithoutMax()\n# {\n# $output = $this->getOutputStream();\n\
# \n# $bar = new ProgressBar($output, 0, 0);\n# $bar->start();\n# $bar->advance();\n\
# $bar->advance();\n# $bar->advance();\n# $bar->finish();\n# \n# rewind($output->getStream());\n\
# $this->assertEquals(\n# rtrim(' 0 [>---------------------------]').\n# rtrim($this->generateOutput('\
\ 1 [->--------------------------]')).\n# rtrim($this->generateOutput(' \
\ 2 [-->-------------------------]')).\n# rtrim($this->generateOutput(' 3 [--->------------------------]')).\n\
# rtrim($this->generateOutput(' 3 [============================]')),\n# stream_get_contents($output->getStream())\n\
# );\n# }\n# \n# public function testSettingMaxStepsDuringProgressing()\n# {\n\
# $output = $this->getOutputStream();\n# $bar = new ProgressBar($output, 0, 0);\n\
# $bar->start();\n# $bar->setProgress(2);\n# $bar->setMaxSteps(10);\n# $bar->setProgress(5);\n\
# $bar->setMaxSteps(100);\n# $bar->setProgress(10);\n# $bar->finish();\n# \n#\
\ rewind($output->getStream());\n# $this->assertEquals(\n# rtrim(' 0 [>---------------------------]').\n\
# rtrim($this->generateOutput(' 2 [-->-------------------------]')).\n# rtrim($this->generateOutput('\
\ 5/10 [==============>-------------] 50%')).\n# rtrim($this->generateOutput('\
\ 10/100 [==>-------------------------] 10%')).\n# rtrim($this->generateOutput('\
\ 100/100 [============================] 100%')),\n# stream_get_contents($output->getStream())\n\
# );\n# }\n# \n# public function testWithSmallScreen()\n# {\n# $output = $this->getOutputStream();\n\
# \n# $bar = new ProgressBar($output, 0, 0);\n# putenv('COLUMNS=12');\n# $bar->start();\n\
# $bar->advance();\n# putenv('COLUMNS=120');\n# \n# rewind($output->getStream());\n\
# $this->assertEquals(\n# ' 0 [>---]'.\n# $this->generateOutput(' 1 [->--]'),\n\
# stream_get_contents($output->getStream())\n# );\n# }\n# \n# public function\
\ testAddingPlaceholderFormatter()\n# {\n# ProgressBar::setPlaceholderFormatterDefinition('remaining_steps',\
\ fn (ProgressBar $bar) => $bar->getMaxSteps() - $bar->getProgress());\n# $bar\
\ = new ProgressBar($output = $this->getOutputStream(), 3, 0);\n# $bar->setFormat('\
\ %remaining_steps% [%bar%]');\n# \n# $bar->start();\n# $bar->advance();\n# $bar->finish();\n\
# \n# rewind($output->getStream());\n# $this->assertEquals(\n# ' 3 [>---------------------------]'.\n\
# $this->generateOutput(' 2 [=========>------------------]').\n# $this->generateOutput('\
\ 0 [============================]'),\n# stream_get_contents($output->getStream())\n\
# );\n# }\n# \n# public function testAddingInstancePlaceholderFormatter()\n# {\n\
# $bar = new ProgressBar($output = $this->getOutputStream(), 3, 0);\n# $bar->setFormat('\
\ %countdown% [%bar%]');\n# $bar->setPlaceholderFormatter('countdown', $function\
\ = fn (ProgressBar $bar) => $bar->getMaxSteps() - $bar->getProgress());\n# \n\
# $this->assertSame($function, $bar->getPlaceholderFormatter('countdown'));\n\
# \n# $bar->start();\n# $bar->advance();\n# $bar->finish();\n# \n# rewind($output->getStream());\n\
# $this->assertEquals(\n# ' 3 [>---------------------------]'.\n# $this->generateOutput('\
\ 2 [=========>------------------]').\n# $this->generateOutput(' 0 [============================]'),\n\
# stream_get_contents($output->getStream())\n# );\n# }\n# \n# public function\
\ testMultilineFormat()\n# {\n# $bar = new ProgressBar($output = $this->getOutputStream(),\
\ 3, 0);\n# $bar->setFormat(\"%bar%\\nfoobar\");\n# \n# $bar->start();\n# $bar->advance();\n\
# $bar->clear();\n# $bar->finish();\n# \n# rewind($output->getStream());\n# $this->assertEquals(\n\
# \">---------------------------\\nfoobar\".\n# $this->generateOutput(\"=========>------------------\\\
nfoobar\").\n# \"\\x1B[1G\\x1B[2K\\x1B[1A\".\n# $this->generateOutput('').\n#\
\ $this->generateOutput('============================').\n# \"\\nfoobar\",\n#\
\ stream_get_contents($output->getStream())\n# );\n# }\n# \n# public function\
\ testAnsiColorsAndEmojis()\n# {\n# putenv('COLUMNS=156');\n# \n# $bar = new ProgressBar($output\
\ = $this->getOutputStream(), 15, 0);\n# ProgressBar::setPlaceholderFormatterDefinition('memory',\
\ function (ProgressBar $bar) {\n# static $i = 0;\n# $mem = 100000 * $i;\n# $colors\
\ = $i++ ? '41;37' : '44;37';\n# \n# return \"\\033[\".$colors.'m '.Helper::formatMemory($mem).\"\
\ \\033[0m\";\n# });\n# $bar->setFormat(\" \\033[44;37m %title:-37s% \\033[0m\\\
n %current%/%max% %bar% %percent:3s%%\\n \U0001F3C1 %remaining:-10s% %memory:37s%\"\
);\n# $bar->setBarCharacter($done = \"\\033[32m\u25CF\\033[0m\");\n# $bar->setEmptyBarCharacter($empty\
\ = \"\\033[31m\u25CF\\033[0m\");\n# $bar->setProgressCharacter($progress = \"\
\\033[32m\u27A4 \\033[0m\");\n# \n# $bar->setMessage('Starting the demo... fingers\
\ crossed', 'title');\n# $bar->start();\n# \n# rewind($output->getStream());\n\
# $this->assertEquals(\n# \" \\033[44;37m Starting the demo... fingers crossed\
\ \\033[0m\\n\".\n# ' 0/15 '.$progress.str_repeat($empty, 26).\" 0%\\n\".\n\
# \" \\xf0\\x9f\\x8f\\x81 < 1 sec \\033[44;37m 0 B \\\
033[0m\",\n# stream_get_contents($output->getStream())\n# );\n# ftruncate($output->getStream(),\
\ 0);\n# rewind($output->getStream());\n# \n# $bar->setMessage('Looks good to\
\ me...', 'title');\n# $bar->advance(4);\n# \n# rewind($output->getStream());\n\
# $this->assertEquals(\n# $this->generateOutput(\n# \" \\033[44;37m Looks good\
\ to me... \\033[0m\\n\".\n# ' 4/15 '.str_repeat($done, 7).$progress.str_repeat($empty,\
\ 19).\" 26%\\n\".\n# \" \\xf0\\x9f\\x8f\\x81 < 1 sec \\\
033[41;37m 97 KiB \\033[0m\"\n# ),\n# stream_get_contents($output->getStream())\n\
# );\n# ftruncate($output->getStream(), 0);\n# rewind($output->getStream());\n\
# \n# $bar->setMessage('Thanks, bye', 'title');\n# $bar->finish();\n# \n# rewind($output->getStream());\n\
# $this->assertEquals(\n# $this->generateOutput(\n# \" \\033[44;37m Thanks, bye\
\ \\033[0m\\n\".\n# ' 15/15 '.str_repeat($done, 28).\"\
\ 100%\\n\".\n# \" \\xf0\\x9f\\x8f\\x81 < 1 sec \\033[41;37m\
\ 195 KiB \\033[0m\"\n# ),\n# stream_get_contents($output->getStream())\n# );\n\
# putenv('COLUMNS=120');\n# }\n# \n# public function testSetFormat()\n# {\n# $bar\
\ = new ProgressBar($output = $this->getOutputStream(), 0, 0);\n# $bar->setFormat(ProgressBar::FORMAT_NORMAL);\n\
# $bar->start();\n# rewind($output->getStream());\n# $this->assertEquals(\n# '\
\ 0 [>---------------------------]',\n# stream_get_contents($output->getStream())\n\
# );\n# \n# $bar = new ProgressBar($output = $this->getOutputStream(), 10, 0);\n\
# $bar->setFormat(ProgressBar::FORMAT_NORMAL);\n# $bar->start();\n# rewind($output->getStream());\n\
# $this->assertEquals(\n# ' 0/10 [>---------------------------] 0%',\n# stream_get_contents($output->getStream())\n\
# );\n# }\n# \n# public function testSetFormatWithTimes()\n# {\n# $bar = new ProgressBar($output\
\ = $this->getOutputStream(), 15, 0);\n# $bar->setFormat('%current%/%max% [%bar%]\
\ %percent:3s%% %elapsed:6s%/%estimated:-6s%/%remaining:-6s%');\n# $bar->start();\n\
# rewind($output->getStream());\n# $this->assertEquals(\n# ' 0/15 [>---------------------------]\
\ 0% < 1 sec/< 1 sec/< 1 sec',\n# stream_get_contents($output->getStream())\n\
# );\n# }\n# \n# public function testUnicode()\n# {\n# $bar = new ProgressBar($output\
\ = $this->getOutputStream(), 10, 0);\n# ProgressBar::setFormatDefinition('test',\
\ '%current%/%max% [%bar%] %percent:3s%% %message% Fruitcake marzipan toffee.\
\ Cupcake gummi bears tart dessert ice cream chupa chups cupcake chocolate bar\
\ sesame snaps. Croissant halvah cookie jujubes powder macaroon. Fruitcake bear\
\ claw bonbon jelly beans oat cake pie muffin Fruitcake marzipan toffee.');\n\
# $bar->setFormat('test');\n# $bar->setProgressCharacter('\U0001F4A7');\n# $bar->start();\n\
# rewind($output->getStream());\n# $this->assertStringContainsString(\n# ' 0/10\
\ [\U0001F4A7] 0%',\n# stream_get_contents($output->getStream())\n# );\n# $bar->finish();\n\
# }\n# \n# /**\n# * @dataProvider provideFormat"
- name: provideFormat
visibility: public
parameters: []
comment: '# * Provides each defined format.'
- name: testIterate
visibility: public
parameters: []
comment: null
- name: testIterateUncountable
visibility: public
parameters: []
comment: null
- name: testEmptyInputWithDebugFormat
visibility: public
parameters: []
comment: null
- name: getOutputStream
visibility: protected
parameters:
- name: decorated
default: 'true'
- name: verbosity
default: StreamOutput::VERBOSITY_NORMAL
comment: null
- name: generateOutput
visibility: protected
parameters:
- name: expected
comment: null
- name: testBarWidthWithMultilineFormat
visibility: public
parameters: []
comment: null
- name: testMinAndMaxSecondsBetweenRedraws
visibility: public
parameters: []
comment: null
- name: testMaxSecondsBetweenRedraws
visibility: public
parameters: []
comment: null
- name: testMinSecondsBetweenRedraws
visibility: public
parameters: []
comment: null
- name: testNoWriteWhenMessageIsSame
visibility: public
parameters: []
comment: null
- name: testMultiLineFormatIsFullyCleared
visibility: public
parameters: []
comment: null
- name: testMultiLineFormatIsFullyCorrectlyWithManuallyCleanup
visibility: public
parameters: []
comment: null
- name: testGetNotSetMessage
visibility: public
parameters: []
comment: null
traits:
- PHPUnit\Framework\TestCase
- Symfony\Component\Console\Formatter\OutputFormatter
- Symfony\Component\Console\Helper\Helper
- Symfony\Component\Console\Helper\ProgressBar
- Symfony\Component\Console\Output\ConsoleSectionOutput
- Symfony\Component\Console\Output\StreamOutput
interfaces: []