You are here

public function ProgressBarTest::testAddingPlaceholderFormatter 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::testAddingPlaceholderFormatter()

File

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

Class

ProgressBarTest

Namespace

Symfony\Component\Console\Tests\Helper

Code

public function testAddingPlaceholderFormatter() {
  ProgressBar::setPlaceholderFormatterDefinition('remaining_steps', function (ProgressBar $bar) {
    return $bar
      ->getMaxSteps() - $bar
      ->getProgress();
  });
  $bar = new ProgressBar($output = $this
    ->getOutputStream(), 3);
  $bar
    ->setFormat(' %remaining_steps% [%bar%]');
  $bar
    ->start();
  $bar
    ->advance();
  $bar
    ->finish();
  rewind($output
    ->getStream());
  $this
    ->assertEquals($this
    ->generateOutput(' 3 [>---------------------------]') . $this
    ->generateOutput(' 2 [=========>------------------]') . $this
    ->generateOutput(' 0 [============================]'), stream_get_contents($output
    ->getStream()));
}