Skip to content

Commit

Permalink
give to phpcs what it wants
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkingmedia committed Jun 27, 2016
1 parent 41289ed commit d751087
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/Shell/Helper/TableHelper.php
Expand Up @@ -78,7 +78,7 @@ protected function _rowSeparator($widths)
*/
protected function _render($row, $widths, $options = [])
{
if(!$row || !is_array($row)) {
if (!$row || !is_array($row)) {
return;
}

Expand All @@ -102,7 +102,7 @@ protected function _render($row, $widths, $options = [])
*/
public function output($rows)
{
if(!$rows || !is_array($rows)) {
if (!$rows || !is_array($rows)) {
return;
}

Expand All @@ -115,7 +115,7 @@ public function output($rows)
$this->_rowSeparator($widths);
}

if(!$rows) {
if (!$rows) {
return;
}

Expand Down
38 changes: 37 additions & 1 deletion tests/TestCase/Shell/Helper/TableHelperTest.php
Expand Up @@ -64,7 +64,7 @@ public function testDefaultOutput()
}

/**
* Test output with multibyte characters
* Test output with multi-byte characters
*
* @return void
*/
Expand Down Expand Up @@ -209,4 +209,40 @@ public function testOutputWithRowSeparatorAndHeaders()
];
$this->assertEquals($expected, $this->stub->messages());
}

/**
* Test output when there is no data.
*/
public function testOutputWithNoData()
{
$this->helper->output([]);
$this->assertEquals([], $this->stub->messages());
}

/**
* Test output with a header but no data.
*/
public function testOutputWithHeaderAndNoData()
{
$data = [
['Header 1', 'Header', 'Long Header']
];
$this->helper->output($data);
$expected = [
'+----------+--------+-------------+',
'| <info>Header 1</info> | <info>Header</info> | <info>Long Header</info> |',
'+----------+--------+-------------+',
];
$this->assertEquals($expected, $this->stub->messages());
}

/**
* Test no data when headers are disabled.
*/
public function testOutputHeaderDisabledNoData()
{
$this->helper->config(['header' => false]);
$this->helper->output([]);
$this->assertEquals([], $this->stub->messages());
}
}

0 comments on commit d751087

Please sign in to comment.