Skip to content

Commit cb26c20

Browse files
authored
Merge pull request #109 from php-school/border-tests
Add border tests
2 parents c521563 + ace9a88 commit cb26c20

File tree

4 files changed

+92
-0
lines changed

4 files changed

+92
-0
lines changed

test/CliMenuTest.php

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,67 @@ public function testSimpleOpenClose() : void
8484
static::assertStringEqualsFile($this->getTestFile(), $this->output->fetch());
8585
}
8686

87+
public function testSimpleOpenCloseWithBorders() : void
88+
{
89+
$this->terminal->expects($this->once())
90+
->method('read')
91+
->willReturn("\n");
92+
93+
$style = $this->getStyle($this->terminal);
94+
$style->setBorder(1, 2, 'red');
95+
96+
$item = new SelectableItem('Item 1', function (CliMenu $menu) {
97+
$menu->close();
98+
});
99+
100+
$menu = new CliMenu('PHP School FTW', [$item], $this->terminal, $style);
101+
$menu->open();
102+
103+
static::assertStringEqualsFile($this->getTestFile(), $this->output->fetch());
104+
}
105+
106+
public function testSimpleOpenCloseWithLeftAndRightBorders() : void
107+
{
108+
$this->terminal->expects($this->once())
109+
->method('read')
110+
->willReturn("\n");
111+
112+
$style = $this->getStyle($this->terminal);
113+
$style->setBorderLeftWidth(2);
114+
$style->setBorderRightWidth(2);
115+
$style->setBorderColour('red');
116+
117+
$item = new SelectableItem('Item 1', function (CliMenu $menu) {
118+
$menu->close();
119+
});
120+
121+
$menu = new CliMenu('PHP School FTW', [$item], $this->terminal, $style);
122+
$menu->open();
123+
124+
static::assertStringEqualsFile($this->getTestFile(), $this->output->fetch());
125+
}
126+
127+
public function testSimpleOpenCloseWithMarginAutoAndBorders() : void
128+
{
129+
$this->terminal->expects($this->once())
130+
->method('read')
131+
->willReturn("\n");
132+
133+
$style = $this->getStyle($this->terminal);
134+
$style->setBorder(1, 2, 'red');
135+
$style->setMarginAuto();
136+
$style->setWidth(30);
137+
138+
$item = new SelectableItem('Item 1', function (CliMenu $menu) {
139+
$menu->close();
140+
});
141+
142+
$menu = new CliMenu('PHP School FTW', [$item], $this->terminal, $style);
143+
$menu->open();
144+
145+
static::assertStringEqualsFile($this->getTestFile(), $this->output->fetch());
146+
}
147+
87148
public function testReDrawReDrawsImmediately() : void
88149
{
89150
$this->terminal->expects($this->once())
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
3+
 
4+
   
5+
  PHP School FTW  
6+
  ======================================  
7+
  ● Item 1  
8+
   
9+
 
10+
11+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
3+
   
4+
  PHP School FTW  
5+
  ======================================  
6+
  ● Item 1  
7+
   
8+
9+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
3+
 
4+
   
5+
  PHP School FTW  
6+
  ======================  
7+
  ● Item 1  
8+
   
9+
 
10+
11+

0 commit comments

Comments
 (0)