/** * */ public function testDraw() { $output = m::mock('mako\\cli\\output\\Output'); $output->shouldReceive('getFormatter')->once()->andReturn(null); $expected = ''; $expected .= '---------' . PHP_EOL; $expected .= '| Col1 |' . PHP_EOL; $expected .= '---------' . PHP_EOL; $expected .= '| Cell1 |' . PHP_EOL; $expected .= '---------' . PHP_EOL; $output->shouldReceive('write')->once()->with($expected, 1); $table = new Table($output); $table->draw(['Col1'], [['Cell1']]); }
/** * Draws information table. * * @access protected * @param string $heading Table heading * @param array $headers Table headers * @param array $rows Table rows */ protected function drawTable($heading, array $headers, array $rows) { if (!empty($rows)) { $this->output->write(PHP_EOL); $this->output->writeLn('<yellow>' . $heading . '</yellow>'); $this->output->write(PHP_EOL); $table = new Table($this->output); $headers = array_map(function ($value) { return '<green>' . $value . '</green>'; }, $headers); $table->draw($headers, $rows); } }