Skip to content

Commit 67191f7

Browse files
Rindulafabpot
authored andcommitted
[Console] Fix division by 0 error
1 parent f1fc6f4 commit 67191f7

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

Helper/ProgressBar.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ public function getEstimated(): float
229229

230230
public function getRemaining(): float
231231
{
232-
if (!$this->step) {
232+
if (0 === $this->step || $this->step === $this->startingStep) {
233233
return 0;
234234
}
235235

Tests/Helper/ProgressBarTest.php

+8
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,14 @@ public function testRegularTimeEstimation()
110110
);
111111
}
112112

113+
public function testRegularTimeRemainingWithDifferentStartAtAndCustomDisplay()
114+
{
115+
ProgressBar::setFormatDefinition('custom', ' %current%/%max% [%bar%] %percent:3s%% %remaining% %estimated%');
116+
$bar = new ProgressBar($output = $this->getOutputStream(), 1_200, 0);
117+
$bar->setFormat('custom');
118+
$bar->start(1_200, 600);
119+
}
120+
113121
public function testResumedTimeEstimation()
114122
{
115123
$bar = new ProgressBar($output = $this->getOutputStream(), 1_200, 0);

0 commit comments

Comments
 (0)