diff --git a/test/CliMenuTest.php b/test/CliMenuTest.php index af288b9c..a1d987e1 100644 --- a/test/CliMenuTest.php +++ b/test/CliMenuTest.php @@ -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()) diff --git a/test/res/testSimpleOpenCloseWithBorders.txt b/test/res/testSimpleOpenCloseWithBorders.txt new file mode 100644 index 00000000..f5859c27 --- /dev/null +++ b/test/res/testSimpleOpenCloseWithBorders.txt @@ -0,0 +1,11 @@ + + +   +     +   PHP School FTW   +   ======================================   +   ● Item 1   +     +   + + diff --git a/test/res/testSimpleOpenCloseWithLeftAndRightBorders.txt b/test/res/testSimpleOpenCloseWithLeftAndRightBorders.txt new file mode 100644 index 00000000..df89ab68 --- /dev/null +++ b/test/res/testSimpleOpenCloseWithLeftAndRightBorders.txt @@ -0,0 +1,9 @@ + + +     +   PHP School FTW   +   ======================================   +   ● Item 1   +     + + diff --git a/test/res/testSimpleOpenCloseWithMarginAutoAndBorders.txt b/test/res/testSimpleOpenCloseWithMarginAutoAndBorders.txt new file mode 100644 index 00000000..b6996228 --- /dev/null +++ b/test/res/testSimpleOpenCloseWithMarginAutoAndBorders.txt @@ -0,0 +1,11 @@ + + +   +     +   PHP School FTW   +   ======================   +   ● Item 1   +     +   + +