Fix ProgressHelper redraw when redrawFreq is greater than 1
This commit is contained in:
parent
25160e39d2
commit
5eca1fb01a
@ -235,8 +235,12 @@ class ProgressHelper extends Helper
|
||||
$redraw = true;
|
||||
}
|
||||
|
||||
$prevPeriod = intval($this->current / $this->redrawFreq);
|
||||
|
||||
$this->current += $step;
|
||||
if ($redraw || 0 === $this->current % $this->redrawFreq) {
|
||||
|
||||
$currPeriod = intval($this->current / $this->redrawFreq);
|
||||
if ($redraw || $prevPeriod !== $currPeriod || $this->max === $this->current) {
|
||||
$this->display();
|
||||
}
|
||||
}
|
||||
@ -265,8 +269,12 @@ class ProgressHelper extends Helper
|
||||
$redraw = true;
|
||||
}
|
||||
|
||||
$prevPeriod = intval($this->current / $this->redrawFreq);
|
||||
|
||||
$this->current = $current;
|
||||
if ($redraw || 0 === $this->current % $this->redrawFreq) {
|
||||
|
||||
$currPeriod = intval($this->current / $this->redrawFreq);
|
||||
if ($redraw || $prevPeriod !== $currPeriod || $this->max === $this->current) {
|
||||
$this->display();
|
||||
}
|
||||
}
|
||||
|
@ -136,6 +136,21 @@ class ProgressHelperTest extends \PHPUnit_Framework_TestCase
|
||||
$progress->setCurrent(10);
|
||||
}
|
||||
|
||||
public function testRedrawFrequency()
|
||||
{
|
||||
$progress = $this->getMock('Symfony\Component\Console\Helper\ProgressHelper', array('display'));
|
||||
$progress->expects($this->exactly(4))
|
||||
->method('display');
|
||||
|
||||
$progress->setRedrawFrequency(2);
|
||||
|
||||
$progress->start($output = $this->getOutputStream(), 6);
|
||||
$progress->setCurrent(1);
|
||||
$progress->advance(2);
|
||||
$progress->advance(2);
|
||||
$progress->advance(1);
|
||||
}
|
||||
|
||||
public function testMultiByteSupport()
|
||||
{
|
||||
if (!function_exists('mb_strlen') || (false === $encoding = mb_detect_encoding('■'))) {
|
||||
|
Reference in New Issue
Block a user