Skip to content

Commit d751087

Browse files
author
thinkingmedia
committed
give to phpcs what it wants
1 parent 41289ed commit d751087

File tree

2 files changed

+40
-4
lines changed

2 files changed

+40
-4
lines changed

src/Shell/Helper/TableHelper.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ protected function _rowSeparator($widths)
7878
*/
7979
protected function _render($row, $widths, $options = [])
8080
{
81-
if(!$row || !is_array($row)) {
81+
if (!$row || !is_array($row)) {
8282
return;
8383
}
8484

@@ -102,7 +102,7 @@ protected function _render($row, $widths, $options = [])
102102
*/
103103
public function output($rows)
104104
{
105-
if(!$rows || !is_array($rows)) {
105+
if (!$rows || !is_array($rows)) {
106106
return;
107107
}
108108

@@ -115,7 +115,7 @@ public function output($rows)
115115
$this->_rowSeparator($widths);
116116
}
117117

118-
if(!$rows) {
118+
if (!$rows) {
119119
return;
120120
}
121121

tests/TestCase/Shell/Helper/TableHelperTest.php

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function testDefaultOutput()
6464
}
6565

6666
/**
67-
* Test output with multibyte characters
67+
* Test output with multi-byte characters
6868
*
6969
* @return void
7070
*/
@@ -209,4 +209,40 @@ public function testOutputWithRowSeparatorAndHeaders()
209209
];
210210
$this->assertEquals($expected, $this->stub->messages());
211211
}
212+
213+
/**
214+
* Test output when there is no data.
215+
*/
216+
public function testOutputWithNoData()
217+
{
218+
$this->helper->output([]);
219+
$this->assertEquals([], $this->stub->messages());
220+
}
221+
222+
/**
223+
* Test output with a header but no data.
224+
*/
225+
public function testOutputWithHeaderAndNoData()
226+
{
227+
$data = [
228+
['Header 1', 'Header', 'Long Header']
229+
];
230+
$this->helper->output($data);
231+
$expected = [
232+
'+----------+--------+-------------+',
233+
'| <info>Header 1</info> | <info>Header</info> | <info>Long Header</info> |',
234+
'+----------+--------+-------------+',
235+
];
236+
$this->assertEquals($expected, $this->stub->messages());
237+
}
238+
239+
/**
240+
* Test no data when headers are disabled.
241+
*/
242+
public function testOutputHeaderDisabledNoData()
243+
{
244+
$this->helper->config(['header' => false]);
245+
$this->helper->output([]);
246+
$this->assertEquals([], $this->stub->messages());
247+
}
212248
}

0 commit comments

Comments
 (0)