Skip to content

Commit

Permalink
Ensure we can output checkboxes when the terminal width is unknown
Browse files Browse the repository at this point in the history
  • Loading branch information
duncan3dc committed Dec 1, 2019
1 parent 04c8aba commit 6b53a28
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Expand Up @@ -3,6 +3,14 @@ Changelog

--------

## 3.5.2 - 2019-12-01

### Fixed

* [Checkbox] Ensure we can output when the terminal width is unknown. [#156](https://github.com/thephpleague/climate/pull/156)

--------

## 3.5.1 - 2019-11-24

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion src/TerminalObject/Dynamic/Checkbox/Checkbox.php
Expand Up @@ -173,7 +173,7 @@ protected function buildCheckboxString()
*/
protected function getPaddingString($line)
{
$length = $this->util->system->width() - $this->lengthWithoutTags($line);
$length = $this->util->width() - $this->lengthWithoutTags($line);

return str_repeat(' ', $length);
}
Expand Down
24 changes: 24 additions & 0 deletions tests/CheckboxesTest.php
Expand Up @@ -2,6 +2,12 @@

namespace League\CLImate\Tests;

use League\CLImate\Util\System\Linux;
use League\CLImate\Util\UtilFactory;
use Mockery;

use function str_repeat;

class CheckboxesTest extends TestBase
{
protected function shouldHideCursor()
Expand Down Expand Up @@ -149,4 +155,22 @@ public function it_can_toggle_a_checkbox()

$this->assertSame([], $response);
}


/**
* Ensure we can output checkboxes when the terminal width is unknown
*/
public function test1(): void
{
$system = Mockery::mock(Linux::class);
$system->shouldReceive("hasAnsiSupport")->andReturn(true);

# When the width is unknown then a default of 80 should be used
$system->shouldReceive("width")->andReturn(null);

$this->util = new UtilFactory($system);
$this->cli->setUtil($this->util);

$this->it_can_select_a_checkbox();
}
}

0 comments on commit 6b53a28

Please sign in to comment.