Skip to content

Commit

Permalink
[Console] Fix division by 0 error
Browse files Browse the repository at this point in the history
  • Loading branch information
Rindula authored and fabpot committed Dec 6, 2024
1 parent f1fc6f4 commit 67191f7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Helper/ProgressBar.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ public function getEstimated(): float

public function getRemaining(): float
{
if (!$this->step) {
if (0 === $this->step || $this->step === $this->startingStep) {
return 0;
}

Expand Down
8 changes: 8 additions & 0 deletions Tests/Helper/ProgressBarTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,14 @@ public function testRegularTimeEstimation()
);
}

public function testRegularTimeRemainingWithDifferentStartAtAndCustomDisplay()
{
ProgressBar::setFormatDefinition('custom', ' %current%/%max% [%bar%] %percent:3s%% %remaining% %estimated%');
$bar = new ProgressBar($output = $this->getOutputStream(), 1_200, 0);
$bar->setFormat('custom');
$bar->start(1_200, 600);
}

public function testResumedTimeEstimation()
{
$bar = new ProgressBar($output = $this->getOutputStream(), 1_200, 0);
Expand Down

0 comments on commit 67191f7

Please sign in to comment.