stub = new ConsoleOutput(); $this->io = new ConsoleIo($this->stub); $this->helper = new TableHelper($this->io); } /** * Test output * * @return voi */ public function testOutput() { $data = [ ['Header 1', 'Header', 'Long Header'], ['short', 'Longish thing', 'short'], ['Longer thing', 'short', 'Longest Value'], ]; $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 array shifting * * @return voi */ public function testOutputShifting() { $data = [ ['Header 1', 'Header', 'Long Header'], ['short', 'Longish thing', 'short'], ]; $this->helper->output([$data]); $expected = [ '+----------+---------------+-------------+', '| Header 1 | Header | Long Header |', '+----------+---------------+-------------+', '| short | Longish thing | short |', '+----------+---------------+-------------+', ]; $this->assertEquals($expected, $this->stub->messages()); } /** * Test output with multibyte characters * * @return voi */ public function testOutputUtf8() { $data = [ ['Header 1', 'Head', 'Long Header'], ['short', 'ÄÄÄÜÜÜ', 'short'], ['Longer thing', 'longerish', 'Longest Value'], ]; $this->helper->output($data); $expected = [ '+--------------+-----------+---------------+', '| Header 1 | Head | Long Header |', '+--------------+-----------+---------------+', '| short | ÄÄÄÜÜÜ | short |', '| Longer thing | longerish | Longest Value |', '+--------------+-----------+---------------+', ]; $this->assertEquals($expected, $this->stub->messages()); } }