Browse Source

add a test for spaces

thinkingmedia 9 years ago
parent
commit
a15f006d86
1 changed files with 36 additions and 0 deletions
  1. 36 0
      tests/TestCase/Shell/Helper/TableHelperTest.php

+ 36 - 0
tests/TestCase/Shell/Helper/TableHelperTest.php

@@ -24,6 +24,20 @@ use Cake\TestSuite\TestCase;
  */
 class TableHelperTest extends TestCase
 {
+    /**
+     * @var ConsoleOutput
+     */
+    public $stub;
+
+    /**
+     * @var ConsoleIo
+     */
+    public $io;
+
+    /**
+     * @var TableHelper
+     */
+    public $helper;
 
     /**
      * setUp method
@@ -64,6 +78,28 @@ class TableHelperTest extends TestCase
     }
 
     /**
+     * Test that output works when data contains just empty strings.
+     */
+    public function testEmptyStrings()
+    {
+        $data = [
+            ['Header 1', 'Header', 'Empty'],
+            ['short', 'Longish thing', ''],
+            ['Longer thing', 'short', ''],
+        ];
+        $this->helper->output($data);
+        $expected = [
+            '+--------------+---------------+-------+',
+            '| <info>Header 1</info>     | <info>Header</info>        | <info>Empty</info> |',
+            '+--------------+---------------+-------+',
+            '| short        | Longish thing |       |',
+            '| Longer thing | short         |       |',
+            '+--------------+---------------+-------+',
+        ];
+        $this->assertEquals($expected, $this->stub->messages());
+    }
+
+    /**
      * Test output with multi-byte characters
      *
      * @return void