-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cleaner way of customizing spinner frames and progress bars
- Loading branch information
Showing
6 changed files
with
114 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
tests/unit/cli/output/components/progress/ProgressBarTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
/** | ||
* @copyright Frederic G. Østby | ||
* @license http://www.makoframework.com/license | ||
*/ | ||
|
||
namespace mako\tests\unit\cli\output\components\progress; | ||
|
||
use mako\cli\output\components\progress\ProgressBar; | ||
use mako\tests\TestCase; | ||
use PHPUnit\Framework\Attributes\Group; | ||
|
||
#[Group('unit')] | ||
class ProgressBarTest extends TestCase | ||
{ | ||
/** | ||
* | ||
*/ | ||
public function testWithDefaultTemplate(): void | ||
{ | ||
$progressBar = new ProgressBar; | ||
|
||
$this->assertSame('─', $progressBar->getEmpty()); | ||
|
||
$this->assertSame('█', $progressBar->getFilled()); | ||
} | ||
|
||
/** | ||
* | ||
*/ | ||
public function testWithCustomTemplate(): void | ||
{ | ||
$progressBar = new ProgressBar('x%sx', 'y%sy'); | ||
|
||
$this->assertSame('x─x', $progressBar->getEmpty()); | ||
|
||
$this->assertSame('y█y', $progressBar->getFilled()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
/** | ||
* @copyright Frederic G. Østby | ||
* @license http://www.makoframework.com/license | ||
*/ | ||
|
||
namespace mako\tests\unit\cli\output\components\progress; | ||
|
||
use mako\cli\output\components\spinner\Frames; | ||
use mako\tests\TestCase; | ||
use PHPUnit\Framework\Attributes\Group; | ||
|
||
#[Group('unit')] | ||
class FramesTest extends TestCase | ||
{ | ||
/** | ||
* | ||
*/ | ||
public function testWithDefaultTemplate(): void | ||
{ | ||
$frames = new Frames; | ||
|
||
$this->assertSame(['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'], $frames->getFrames()); | ||
} | ||
|
||
/** | ||
* | ||
*/ | ||
public function testWithCustomTemplate(): void | ||
{ | ||
$frames = new Frames('x%sx'); | ||
|
||
$this->assertSame(['x⠋x', 'x⠙x', 'x⠹x', 'x⠸x', 'x⠼x', 'x⠴x', 'x⠦x', 'x⠧x', 'x⠇x', 'x⠏x'], $frames->getFrames()); | ||
} | ||
} |