|
@@ -42,9 +42,9 @@ class TableHelperTest extends TestCase
|
|
|
/**
|
|
/**
|
|
|
* Test output
|
|
* Test output
|
|
|
*
|
|
*
|
|
|
- * @return voi
|
|
|
|
|
|
|
+ * @return void
|
|
|
*/
|
|
*/
|
|
|
- public function testOutput()
|
|
|
|
|
|
|
+ public function testDefaultOutput()
|
|
|
{
|
|
{
|
|
|
$data = [
|
|
$data = [
|
|
|
['Header 1', 'Header', 'Long Header'],
|
|
['Header 1', 'Header', 'Long Header'],
|
|
@@ -54,7 +54,7 @@ class TableHelperTest extends TestCase
|
|
|
$this->helper->output($data);
|
|
$this->helper->output($data);
|
|
|
$expected = [
|
|
$expected = [
|
|
|
'+--------------+---------------+---------------+',
|
|
'+--------------+---------------+---------------+',
|
|
|
- '| Header 1 | Header | Long Header |',
|
|
|
|
|
|
|
+ '| <info>Header 1</info> | <info>Header</info> | <info>Long Header</info> |',
|
|
|
'+--------------+---------------+---------------+',
|
|
'+--------------+---------------+---------------+',
|
|
|
'| short | Longish thing | short |',
|
|
'| short | Longish thing | short |',
|
|
|
'| Longer thing | short | Longest Value |',
|
|
'| Longer thing | short | Longest Value |',
|
|
@@ -66,7 +66,7 @@ class TableHelperTest extends TestCase
|
|
|
/**
|
|
/**
|
|
|
* Test output with multibyte characters
|
|
* Test output with multibyte characters
|
|
|
*
|
|
*
|
|
|
- * @return voi
|
|
|
|
|
|
|
+ * @return void
|
|
|
*/
|
|
*/
|
|
|
public function testOutputUtf8()
|
|
public function testOutputUtf8()
|
|
|
{
|
|
{
|
|
@@ -78,7 +78,7 @@ class TableHelperTest extends TestCase
|
|
|
$this->helper->output($data);
|
|
$this->helper->output($data);
|
|
|
$expected = [
|
|
$expected = [
|
|
|
'+--------------+-----------+---------------+',
|
|
'+--------------+-----------+---------------+',
|
|
|
- '| Header 1 | Head | Long Header |',
|
|
|
|
|
|
|
+ '| <info>Header 1</info> | <info>Head</info> | <info>Long Header</info> |',
|
|
|
'+--------------+-----------+---------------+',
|
|
'+--------------+-----------+---------------+',
|
|
|
'| short | ÄÄÄÜÜÜ | short |',
|
|
'| short | ÄÄÄÜÜÜ | short |',
|
|
|
'| Longer thing | longerish | Longest Value |',
|
|
'| Longer thing | longerish | Longest Value |',
|
|
@@ -86,4 +86,124 @@ class TableHelperTest extends TestCase
|
|
|
];
|
|
];
|
|
|
$this->assertEquals($expected, $this->stub->messages());
|
|
$this->assertEquals($expected, $this->stub->messages());
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Test output without headers
|
|
|
|
|
+ *
|
|
|
|
|
+ * @return void
|
|
|
|
|
+ */
|
|
|
|
|
+ public function testOutputWithoutHeaderStyle()
|
|
|
|
|
+ {
|
|
|
|
|
+ $data = [
|
|
|
|
|
+ ['Header 1', 'Header', 'Long Header'],
|
|
|
|
|
+ ['short', 'Longish thing', 'short'],
|
|
|
|
|
+ ['Longer thing', 'short', 'Longest Value'],
|
|
|
|
|
+ ];
|
|
|
|
|
+ $this->helper->config(['headerStyle' => false]);
|
|
|
|
|
+ $this->helper->output($data);
|
|
|
|
|
+ $expected = [
|
|
|
|
|
+ '+--------------+---------------+---------------+',
|
|
|
|
|
+ '| Header 1 | Header | Long Header |',
|
|
|
|
|
+ '+--------------+---------------+---------------+',
|
|
|
|
|
+ '| short | Longish thing | short |',
|
|
|
|
|
+ '| Longer thing | short | Longest Value |',
|
|
|
|
|
+ '+--------------+---------------+---------------+',
|
|
|
|
|
+ ];
|
|
|
|
|
+ $this->assertEquals($expected, $this->stub->messages());
|
|
|
|
|
+ }
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Test output with different header style
|
|
|
|
|
+ *
|
|
|
|
|
+ * @return void
|
|
|
|
|
+ */
|
|
|
|
|
+ public function testOutputWithDifferentHeaderStyle()
|
|
|
|
|
+ {
|
|
|
|
|
+ $data = [
|
|
|
|
|
+ ['Header 1', 'Header', 'Long Header'],
|
|
|
|
|
+ ['short', 'Longish thing', 'short'],
|
|
|
|
|
+ ['Longer thing', 'short', 'Longest Value'],
|
|
|
|
|
+ ];
|
|
|
|
|
+ $this->helper->config(['headerStyle' => 'error']);
|
|
|
|
|
+ $this->helper->output($data);
|
|
|
|
|
+ $expected = [
|
|
|
|
|
+ '+--------------+---------------+---------------+',
|
|
|
|
|
+ '| <error>Header 1</error> | <error>Header</error> | <error>Long Header</error> |',
|
|
|
|
|
+ '+--------------+---------------+---------------+',
|
|
|
|
|
+ '| short | Longish thing | short |',
|
|
|
|
|
+ '| Longer thing | short | Longest Value |',
|
|
|
|
|
+ '+--------------+---------------+---------------+',
|
|
|
|
|
+ ];
|
|
|
|
|
+ $this->assertEquals($expected, $this->stub->messages());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Test output without table headers
|
|
|
|
|
+ *
|
|
|
|
|
+ * @return void
|
|
|
|
|
+ */
|
|
|
|
|
+ public function testOutputWithoutHeaders() {
|
|
|
|
|
+ $data = [
|
|
|
|
|
+ ['short', 'Longish thing', 'short'],
|
|
|
|
|
+ ['Longer thing', 'short', 'Longest Value'],
|
|
|
|
|
+ ];
|
|
|
|
|
+ $this->helper->config(['headers' => false]);
|
|
|
|
|
+ $this->helper->output($data);
|
|
|
|
|
+ $expected = [
|
|
|
|
|
+ '+--------------+---------------+---------------+',
|
|
|
|
|
+ '| short | Longish thing | short |',
|
|
|
|
|
+ '| Longer thing | short | Longest Value |',
|
|
|
|
|
+ '+--------------+---------------+---------------+',
|
|
|
|
|
+ ];
|
|
|
|
|
+ $this->assertEquals($expected, $this->stub->messages());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Test output with row separator
|
|
|
|
|
+ *
|
|
|
|
|
+ * @return void
|
|
|
|
|
+ */
|
|
|
|
|
+ public function testOutputWithRowSeparator() {
|
|
|
|
|
+ $data = [
|
|
|
|
|
+ ['Header 1', 'Header', 'Long Header'],
|
|
|
|
|
+ ['short', 'Longish thing', 'short'],
|
|
|
|
|
+ ['Longer thing', 'short', 'Longest Value']
|
|
|
|
|
+ ];
|
|
|
|
|
+ $this->helper->config(['rowSeparator' => true]);
|
|
|
|
|
+ $this->helper->output($data);
|
|
|
|
|
+ $expected = [
|
|
|
|
|
+ '+--------------+---------------+---------------+',
|
|
|
|
|
+ '| <info>Header 1</info> | <info>Header</info> | <info>Long Header</info> |',
|
|
|
|
|
+ '+--------------+---------------+---------------+',
|
|
|
|
|
+ '| short | Longish thing | short |',
|
|
|
|
|
+ '+--------------+---------------+---------------+',
|
|
|
|
|
+ '| Longer thing | short | Longest Value |',
|
|
|
|
|
+ '+--------------+---------------+---------------+',
|
|
|
|
|
+ ];
|
|
|
|
|
+ $this->assertEquals($expected, $this->stub->messages());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Test output with row separator and no headers
|
|
|
|
|
+ *
|
|
|
|
|
+ * @return void
|
|
|
|
|
+ */
|
|
|
|
|
+ public function testOutputWithRowSeparatorAndHeaders() {
|
|
|
|
|
+ $data = [
|
|
|
|
|
+ ['Header 1', 'Header', 'Long Header'],
|
|
|
|
|
+ ['short', 'Longish thing', 'short'],
|
|
|
|
|
+ ['Longer thing', 'short', 'Longest Value'],
|
|
|
|
|
+ ];
|
|
|
|
|
+ $this->helper->config(['rowSeparator' => true]);
|
|
|
|
|
+ $this->helper->output($data);
|
|
|
|
|
+ $expected = [
|
|
|
|
|
+ '+--------------+---------------+---------------+',
|
|
|
|
|
+ '| <info>Header 1</info> | <info>Header</info> | <info>Long Header</info> |',
|
|
|
|
|
+ '+--------------+---------------+---------------+',
|
|
|
|
|
+ '| short | Longish thing | short |',
|
|
|
|
|
+ '+--------------+---------------+---------------+',
|
|
|
|
|
+ '| Longer thing | short | Longest Value |',
|
|
|
|
|
+ '+--------------+---------------+---------------+',
|
|
|
|
|
+ ];
|
|
|
|
|
+ $this->assertEquals($expected, $this->stub->messages());
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|