Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions test/CliMenuTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,67 @@ public function testSimpleOpenClose() : void
static::assertStringEqualsFile($this->getTestFile(), $this->output->fetch());
}

public function testSimpleOpenCloseWithBorders() : void
{
$this->terminal->expects($this->once())
->method('read')
->willReturn("\n");

$style = $this->getStyle($this->terminal);
$style->setBorder(1, 2, 'red');

$item = new SelectableItem('Item 1', function (CliMenu $menu) {
$menu->close();
});

$menu = new CliMenu('PHP School FTW', [$item], $this->terminal, $style);
$menu->open();

static::assertStringEqualsFile($this->getTestFile(), $this->output->fetch());
}

public function testSimpleOpenCloseWithLeftAndRightBorders() : void
{
$this->terminal->expects($this->once())
->method('read')
->willReturn("\n");

$style = $this->getStyle($this->terminal);
$style->setBorderLeftWidth(2);
$style->setBorderRightWidth(2);
$style->setBorderColour('red');

$item = new SelectableItem('Item 1', function (CliMenu $menu) {
$menu->close();
});

$menu = new CliMenu('PHP School FTW', [$item], $this->terminal, $style);
$menu->open();

static::assertStringEqualsFile($this->getTestFile(), $this->output->fetch());
}

public function testSimpleOpenCloseWithMarginAutoAndBorders() : void
{
$this->terminal->expects($this->once())
->method('read')
->willReturn("\n");

$style = $this->getStyle($this->terminal);
$style->setBorder(1, 2, 'red');
$style->setMarginAuto();
$style->setWidth(30);

$item = new SelectableItem('Item 1', function (CliMenu $menu) {
$menu->close();
});

$menu = new CliMenu('PHP School FTW', [$item], $this->terminal, $style);
$menu->open();

static::assertStringEqualsFile($this->getTestFile(), $this->output->fetch());
}

public function testReDrawReDrawsImmediately() : void
{
$this->terminal->expects($this->once())
Expand Down
11 changes: 11 additions & 0 deletions test/res/testSimpleOpenCloseWithBorders.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@


 
   
  PHP School FTW  
  ======================================  
  ● Item 1  
   
 


9 changes: 9 additions & 0 deletions test/res/testSimpleOpenCloseWithLeftAndRightBorders.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@


   
  PHP School FTW  
  ======================================  
  ● Item 1  
   


11 changes: 11 additions & 0 deletions test/res/testSimpleOpenCloseWithMarginAutoAndBorders.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@


 
   
  PHP School FTW  
  ======================  
  ● Item 1