You are here

public function ProgressBarTest::testParallelBars in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/console/Tests/Helper/ProgressBarTest.php \Symfony\Component\Console\Tests\Helper\ProgressBarTest::testParallelBars()

File

vendor/symfony/console/Tests/Helper/ProgressBarTest.php, line 384

Class

ProgressBarTest

Namespace

Symfony\Component\Console\Tests\Helper

Code

public function testParallelBars() {
  $output = $this
    ->getOutputStream();
  $bar1 = new ProgressBar($output, 2);
  $bar2 = new ProgressBar($output, 3);
  $bar2
    ->setProgressCharacter('#');
  $bar3 = new ProgressBar($output);
  $bar1
    ->start();
  $output
    ->write("\n");
  $bar2
    ->start();
  $output
    ->write("\n");
  $bar3
    ->start();
  for ($i = 1; $i <= 3; ++$i) {

    // up two lines
    $output
      ->write("\33[2A");
    if ($i <= 2) {
      $bar1
        ->advance();
    }
    $output
      ->write("\n");
    $bar2
      ->advance();
    $output
      ->write("\n");
    $bar3
      ->advance();
  }
  $output
    ->write("\33[2A");
  $output
    ->write("\n");
  $output
    ->write("\n");
  $bar3
    ->finish();
  rewind($output
    ->getStream());
  $this
    ->assertEquals($this
    ->generateOutput(' 0/2 [>---------------------------]   0%') . "\n" . $this
    ->generateOutput(' 0/3 [#---------------------------]   0%') . "\n" . rtrim($this
    ->generateOutput('    0 [>---------------------------]')) . "\33[2A" . $this
    ->generateOutput(' 1/2 [==============>-------------]  50%') . "\n" . $this
    ->generateOutput(' 1/3 [=========#------------------]  33%') . "\n" . rtrim($this
    ->generateOutput('    1 [->--------------------------]')) . "\33[2A" . $this
    ->generateOutput(' 2/2 [============================] 100%') . "\n" . $this
    ->generateOutput(' 2/3 [==================#---------]  66%') . "\n" . rtrim($this
    ->generateOutput('    2 [-->-------------------------]')) . "\33[2A" . "\n" . $this
    ->generateOutput(' 3/3 [============================] 100%') . "\n" . rtrim($this
    ->generateOutput('    3 [--->------------------------]')) . "\33[2A" . "\n" . "\n" . rtrim($this
    ->generateOutput('    3 [============================]')), stream_get_contents($output
    ->getStream()));
}